Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
Just ran another quick test to see more about the relationship to the user-space process was-I brought up the two and established the link, killed the user-space process and then the module was free to rmmod.
Maybe there's some sort of netlink socket command I can use to disconnect before I release the socket?
//detach from listener