1

I just started learning Linux development and for the training purpose I wrote a simple loadable kernel module. When I try to add it by issuing the following command - make -C /lib/modules/$(uname -r)/build M=$PWD modules

I get the following error:

error: too many arguments to function ‘netlink_kernel_create’ nl_sk = netlink_kernel_create(&init_net, NETLINK_EXAMPLE, 0, recv_msg, NULL, THIS_MODULE);

Limon Monte
  • 52,539
  • 45
  • 182
  • 213
niko85
  • 303
  • 2
  • 12

1 Answers1

1

You get this error because netlink_kernel_create takes three arguments but you pass 6.

static inline struct sock *
netlink_kernel_create(struct net *net, int unit, struct netlink_kernel_cfg *cfg)
{
        return __netlink_kernel_create(net, unit, THIS_MODULE, cfg);
}

netlink_kernel_create

Many functions has changed both implementation and signature since 2.6 kernel, and is changing still between kernel releases, so always check.

Fix:

struct netlink_kernel_cfg cfg = {
    .input = recv_msg,
};

nl_sk = netlink_kernel_create(&init_net, NETLINK_EXAMPLE, &cfg);
4pie0
  • 29,204
  • 9
  • 82
  • 118
  • Hi and thank you for your help. I just made the changes in the file and saved it but I still get exactly the same error. any suggestions? – niko85 Sep 27 '15 at 11:19
  • 1
    Sorry, I was working with the wrong file, my bad. Thank you for for your help. The problem is solved. – niko85 Sep 27 '15 at 11:25