Problem w/ rmmod from netlink sockets
I wrote a module that makes use of netlink sockets to talk to a user-space application among other things and I'm having some trouble getting rmmod to work once it is up. I believe it is caused by my implementation of the netlink sockets since rmmod works just fine when I don't launch the user-space application it talks to but it fails when I do. The reason it provides for the inability to rmmod is that the resource is temporarily unavailable. An lsmod shows that the module is used by 1 other process.
In my implementation I have tried to close the socket connection in the module's exit function by performing both netlink_kernel_release(nl_sock) and sock_release(nl_sock->socket). The first compiles fine and is what I have been testing and runs into the problem. The second is not compiling and the error the compiler gives me is that I'm dereferencing a pointer to an incomplete type.
One other possible source of the problem that has crossed my mind is earlier in testing after I unicasted a message I freed the corresponding skb which caused the kernel to try and access a NULL address which was clearly all bad. Am I supposed to keep track of this skb and free it at a later time?