netdev
[Top] [All Lists]

Re: nf_unregister_hook crashing kernel

To: Andre Correa <andre.correa@xxxxxxxxx>
Subject: Re: nf_unregister_hook crashing kernel
From: Krishna Kumar <kumarkr@xxxxxxxxxx>
Date: Thu, 22 Apr 2004 14:08:04 -0700
Cc: netdev@xxxxxxxxxxx
Sender: netdev-bounce@xxxxxxxxxxx

If you do a nf_register_queue_handler, you need nf_unregister_queue_handler. Can't mix
and match :-) Basically what is happening is that your list is not initialized (actually set to
NULL being global), and when you do a de-register, it panics.

- KK

Inactive hide details for Andre Correa <andre.correa@xxxxxxxxx>Andre Correa <andre.correa@xxxxxxxxx>




          Andre Correa <andre.correa@xxxxxxxxx>
          Sent by: netdev-bounce@xxxxxxxxxxx

          04/22/2004 04:51 PM



To: netdev@xxxxxxxxxxx
cc:
Subject: nf_unregister_hook crashing kernel



Hi list, I'm playing with a module that uses netfilter hooks. It
register using nf_register_hook without problems, but when I try
nf_unregister_hook in my "cleanup" function the kernel crashs. I've
found that it crashs calling nf_unregister_hook, but have no idea how to
debug it further...

Here goes some snips from my code. Nothing new. I've searched other
modules and found that everybody makes the same.


...<snip>...

static nf_hookfn my_nf_hook;


static struct nf_hook_ops my_ingress_ipv4 = {
.hook = my_nf_hook,
.owner = THIS_MODULE,
.pf = PF_INET,
.hooknum = NF_IP_PRE_ROUTING,
.priority = NF_IP_PRI_MANGLE + 1
};

...<snip>...

static unsigned int my_nf_hook(unsigned int hook, struct sk_buff **pskb,
const struct net_device *indev,
const struct net_device *outdev,
int (*okfn)(struct sk_buff *))
{
if ((*pskb)->my_flags & MY_F_ENQUEUE)
return NF_QUEUE;


return NF_ACCEPT;
}

...<snip>...

static int __init my_init_hooks(void)
{
int err;


if ((err = nf_register_queue_handler(PF_INET, my_nf_queue, NULL)))
return err;
}

...<snip>....

static void __exit my_unhook(void)
{

nf_unregister_hook(&my_ingress_ipv4);
}

...<snip>...

module_init(my_init_module);
module_exit(my_cleanup_module);
MODULE_LICENSE("GPL");


Like I said, nothing new. Is there anybody who can give me some info on
how/when can nf_unregister_hook crash the kernel? How can I debug some
more?!

Tks in advance for any help.

Andre



GIF image

<Prev in Thread] Current Thread [Next in Thread>