I have written a pre route hook function in my LKM. When I try to compile it, it gives me below warning
/home/sample/kmod-sample/kernel/kmod_sample.h:159:9: warning: initialization from incompatible pointer type [enabled by default]
.hook = sample_prerouting_hook,
^
/home/sample/kmod-sample/kernel/kmod_sample.h:159:9: warning: (near initialization for ‘sample_prerouting_ops.hook’) [enabled by default]
Below is my code in module header file named sample.h
static unsigned int sample_prerouting_hook (
unsigned int hook,
struct sk_buff *pskb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff*)
);
static struct nf_hook_ops sample_prerouting_ops = {
.hook = sample_prerouting_hook,
.owner = THIS_MODULE,
.pf = PF_INET,
.hooknum = NF_INET_PRE_ROUTING,
.priority = NF_IP_PRI_LAST,
};
What can I do to resolve this warning ??