- 论坛徽章:
- 0
|
我的code
ETH_P_ALL 的hander:
int my_new_skb_recv (struct sk_buff * skb,struct net_device * net_dev,
struct packet_type *pack_type,struct net_device *orig_dev)
{
unsigned short prot;
pepd tmp=NULL;
struct kmem_cache *cache = epd_head_cache;
struct ethhdr *eth_head = NULL;
struct eth_pck_data *newp, *last;
if (net_dev->nd_net != &init_net)
goto freeskb;
prot = eth_type_trans(skb, net_dev);
if(!(newp = have_this_type(prot,&last)))
{
tmp = (pepd)kmem_cache_alloc_node(cache, GFP_ATOMIC & ~__GFP_DMA, wc.node);
if(!tmp)
{
printk("no memory!\n");
return ENOMEM;
}
eth_head = eth_hdr(skb);
memset(tmp,0,sizeof(epd));
memcpy(tmp->de_mac_add,eth_head->h_dest,ETH_ALEN);
memcpy(tmp->sr_mac_add,eth_head->h_source,ETH_ALEN);
tmp->protcol = eth_head->h_proto;
tmp->count++;
tmp->next = NULL;
if(!wc.phead)
wc.phead = tmp;
else if(last)
last->next = tmp;
}
else
{
newp->count++;
}
return 0;
freeskb:
kfree_skb(skb);
return 0;
}
并且我加了打印, freeskb没有被调用。 |
|