mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Imran.Patel@nokia.com
To: netfilter-devel@us5.samba.org
Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org
Subject: skb allocation problems
Date: Mon, 9 Apr 2001 19:03:46 +0300	[thread overview]
Message-ID: <2D6CADE9B0C6D411A27500508BB3CBD063CF07@eseis15nok> (raw)

hello all,

For the past week, i am having problems with (possibly BUGGY) memory
allocation by the kernel in my NAT-PT module. I posted this to netdev before
but did not get any response. So, here i am with some more proof:) 

In my IPV6-IPV4 translator module, i capture an IPV4 packet by registering
at the netfilter pre-routing hook, i translate it to an IPV6 packet and
allocate a new skb for the translated packet and put the packet back in the
IPV6 stack...but when i allocate the skb for the translated packet, i start
getting the problems. A call to alloc_skb gives me the memory area that is
already being pointed by the IPV4 packet which came into the hook...

I have written a test module which closely mirrors what my code tries to
do(attached below). This is what i get:

PRE_R: old skb:c371ee40  new skb:c371ee30 
<7>NAT: 3 dropping untracked packet c350fa00 1 192.168.102.22 ->
192.168.102.29

The above message was generated by sending a udp packet from a simple udp
client on the host 192.168.102.29 to 192.168.102.22. The test module was on
the host 192.168.102.22. 

As you can see the memory allocated to new skb is already being pointed to
by the packet that came in (old skb). Isn't that strange/BUGGY ??

And regarding the netfilter message, the packet that is being dropped by
netfilter is an ICMP protocol unreachable message since there is no udp
server listening on 192.168.102.29. Why conntrack drops the icmp error
packet is a question for the netfilter guys:)

I have been fighting this bug or whatever it is for a week now and i can't
get anywhere. And i cannot produce this behaviour reliably i.e. this test
module allocates different memory area most of the time & seems to work fine
but when it goes bad, it keeps on allocating the same overlapping
addresses...and never stops misbehaving until i reboot the machine....

Any help would be appreciated.

PS: I am not on the linux-kernel mailing list & yes, i use the 2.4.1 kernel.

TIA,
imran

-------------------------



#define __KERNEL__
#define MODULE

#include <linux/module.h>
#include <linux/netfilter_ipv4.h>
#include <linux/ip.h>

static unsigned int
          prehook(unsigned int hook, struct sk_buff **pskb,
                         const struct net_device *indev,
                         const struct net_device *outdev,
                         int (*okfn)(struct sk_buff *))            {
        struct sk_buff *skb;
        printk("\nPRE_R: old skb:%p", (*pskb)->data);

/* translation happens in the real code here */

        skb = alloc_skb((*pskb)->len, GFP_ATOMIC);
        if(!skb)
                printk("alloc failed");
        skb_reserve(skb, 16);
        printk(" new skb:%p", skb->data);
        kfree_skb(skb);

/*    actually it is something like this in my real code:
	kfree(*pskb);
	return NF_STOLEN;
*/
        return NF_ACCEPT; 
}

static struct nf_hook_ops pre =
{
        {NULL, NULL},           /* link list         */
         prehook,        /* the hook fn       */
         PF_INET,               /* protocol  family  */
         NF_IP_PRE_ROUTING,    /* hook no            */
         NF_IP_PRI_CONNTRACK    /* priority          */
};


static int init_module(void) {
           nf_register_hook(&pre);
}

static void cleanup_module(void) {
           nf_unregister_hook(&pre);
}

             reply	other threads:[~2001-04-09 16:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-09 16:03 Imran.Patel [this message]
2001-04-10  6:07 ` Andi Kleen
2001-04-10 16:27 Imran.Patel
2001-04-10 17:23 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2D6CADE9B0C6D411A27500508BB3CBD063CF07@eseis15nok \
    --to=imran.patel@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=netfilter-devel@us5.samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®