initialization from incompatible pointer type

Hello all, I'm facing a problem when compiling a new module to the Linux kernel 2.6 (Ubuntu 8.04), through the command 'make myfile.ko'.

I have the following structure inside the files:

linux/netfilter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//begin netfilter
...
typedef unsigned int nf_hookfn(unsigned int hooknum, struct sk_buff *skb, const struct net_devide *in, const struct net_device *out, int (*okfn)(struct sk_buff *));
...
struct nf_hook_ops {
struct list_head list;
nf_hookfn *hook;
struct module *owner;
int pf;
int hooknum;
int priority;
};
...
// end netfilter 


myfile.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// begin myfile
...
#include <netfilter.h>
...
unsigned int my_nf_hook(unsigned int hook, struct sk_buff **skb, const struct net_device *indev, const struct net_device *outdev, int (*okfn)(struct sk_buff *));
...
static struct nf_hook_ops nfh_pre = {
{NULL, NULL},
my_nf_hook,
THIS_MODULE,
PF_INET,
NF_IP_PRE_ROUTING,
NF_IP_PRI_FILTER+1
}
...
// end myfile 


When I execute the 'make myfile.ko' to compile the module, it gives me the following warning:

... warning: initialization from incompatible pointer type

This warning is pointing the line '9. my_nf_hook' inside the struct nfh_pre initialization.

Well, after compiling, the ko file is generated. However, when I execute the command 'insmod myfile.ko' to load the module, it results in kernel panic. I believe that the warning is directed related to the problem.

Finally, my question: does anybody know where is the problem in the code above? What could be missing?

Thanks a lot in advance for repliers.
Your second parameter is a double pointer, but the typedef requires it to be a single pointer.
Actually that's right... according to tutorials I followed it must be **
If that is the case (I have not verified) then the nf_hookfn typedef is stupid and the warning can be ignored.

In that case, you have to post your module's init_module() function or equivalent. What does the panic say?
hey jsmith... indeed you were right!
I was confused by the recently changes in netfilter.h
From kernel version 2.6.20 (i guess) and higher ones, the "struct sk_buff skb" parameter in the my_nf_hook function is a single pointer.
However, for lower versions (< 2.6.20), it is a double pointer to the skb sk_buff struct.
Thanks for your help!
you're welcome.

i learned something here too. been a while since i've been into the netfilter code in the kernel.
Topic archived. No new replies allowed.