memleak in net_rx protocol handling? or my misuse of dev_add_pack?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

  for a kernel networking project I have to fetch packets from netfilter 
and/or netrx. For this I use either netfilter_register_hook or dev_add_pack. 
When my function gets called I -- for debugging -- directly return NF_ACCEPT 
resp. NET_RX_SUCCESS, without any processing.

  the weird thing is: with netfilter everything works, but with netrx I get a 
gigantic memory leak. I suspect that no sk_buff gets deallocated. So, my 
question is: does netif expect me to decrease the skb reference count 
manually? Or did I truly notice something peculiar? 

  for inspection I added my processing code below. And I tested this on 
2.6.14.5. If anyone has an idea what I'm doing wrong, thanks. I understand 
that traffic is somewhat slow (ahem) on this list, but guess that net-dev is 
not the proper place for these questions.

cheers,

  Willem de Bruijn

-----------START-OF-CODE------------------
static inline int process(struct sk_buff *skb, const struct net_device *dev)
{
	return 1;
}

///// netfilter specific code

#ifdef CONFIG_NETFILTER
static unsigned int hook_netfilter (unsigned int hook, struct sk_buff **pskb, 
					const struct net_device *indev, 
					const struct net_device *outdev, 
					int (*okfn)(struct sk_buff *))
{
	return process(*pskb, indev) ? NF_ACCEPT : NF_DROP;
}

static struct nf_hook_ops nfops = {
	.hook		= &hook_netfilter,
	.owner		= THIS_MODULE,
	.pf		= PF_INET,
	.hooknum	= NF_IP_PRE_ROUTING,
	.priority	= 0,
};
#endif

///// netrx specific code

int hook_netrx(	struct sk_buff *skb, 
		struct net_device *dev, 
		struct packet_type *pt
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
		, struct net_device *otherdev
#endif
		)
{
	return process(skb, dev) ? NET_RX_SUCCESS : NET_RX_DROP; 
}

static struct packet_type nrops =
{
	.type			= __constant_htons(ETH_P_ALL),
	.dev			= NULL,   		 
	.func			= hook_netrx,		 
	.list			= {NULL,NULL},
	.af_packet_priv = NULL,
};

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux