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);

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

2 Comments

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?
Sorry, I was working with the wrong file, my bad. Thank you for for your help. The problem is solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.