Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    netlink_kernel_create() always returns NULL

    Hi everybody,

    I am programming a kernel module using netfilter to monitor the traffic. However, whenever I call the netlink_kernel_create like this: nl_sk = netlink_kernel_create(&init_net,NETLINK_TEST,0, testFunction,NULL, THIS_MODULE), I always get a NULL. I have defined the NETLINK_TEST in the netlink.h. And the testFunction is supposed to be correct (I tested it on a sample kernel module which only sends and receives msg from user space). I don't have the code by my hand right now (may be provided later today if necessary), but if anybody can give some opinions e.g on what are the usual reasons for such failure, or how to track the reason of it (normally I only see the program doing it so that only prints an error message saying the creation of the socket has failed and then just returns) it would be great. Any thoughts will be appreciated. Thanks!

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    What happens if yuo leave the & off of init_net in the netlink_kernel_create() arguments? According to my kernel headers (RHEL/CentOS 5, 2.6.18 kernel) the first argument is supposted to be an integer type, not an address.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Thanks Rubber,

    I rechecked my netfilter hooks and there was some problem with that. Now it is working with the call nl_sk = netlink_kernel_create(&init_net,NETLINK_TEST,0, testFunction,NULL, THIS_MODULE). (Although I still don't know what is had to do with the testFunction since that function didn't involve with the hooks). And I still don't know how to generally deal with such an error, namely, how to track the source that caused such a problem in generating sockets.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts