netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* nf_unregister_hook crashing kernel
@ 2004-04-22 20:51 Andre Correa
  0 siblings, 0 replies; 2+ messages in thread
From: Andre Correa @ 2004-04-22 20:51 UTC (permalink / raw)
  To: netdev


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nf_unregister_hook crashing kernel
@ 2004-04-22 21:08 Krishna Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Krishna Kumar @ 2004-04-22 21:08 UTC (permalink / raw)
  To: Andre Correa; +Cc: netdev


[-- Attachment #1.1: Type: text/plain, Size: 3311 bytes --]





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



|---------+---------------------------->
|         |           Andre Correa     |
|         |           <andre.correa@pob|
|         |           ox.com>          |
|         |           Sent by:         |
|         |           netdev-bounce@oss|
|         |           .sgi.com         |
|         |                            |
|         |                            |
|         |           04/22/2004 04:51 |
|         |           PM               |
|         |                            |
|---------+---------------------------->
  >-------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                         |
  |       To:       netdev@oss.sgi.com                                                                                      |
  |       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





[-- Attachment #1.2: Type: text/html, Size: 3658 bytes --]

[-- Attachment #2: graycol.gif --]
[-- Type: image/gif, Size: 105 bytes --]

[-- Attachment #3: ecblank.gif --]
[-- Type: image/gif, Size: 45 bytes --]

[-- Attachment #4: pic14315.gif --]
[-- Type: image/gif, Size: 1255 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-22 21:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-22 20:51 nf_unregister_hook crashing kernel Andre Correa
  -- strict thread matches above, loose matches on Subject: below --
2004-04-22 21:08 Krishna Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).