sunzixun 发表于 2013-1-17 02:52:13

<Linux Network 2.6.38> L2-L3

 
__netif_receive_skb 是一个很关键的函数 ,可以看成L2-L3 的分水岭(如果该协议需要到L3的话)
 
net_rx_action 做完了之后基本上 
 
struct sk_buff
{
        //... ... ...
        unsigned short  protocol;
       // ... ... ...
}; 就已经被设置了
 
 
在看 __netif_receive_skb 之前 先看一下这几个东西
 
  这是网络协议解包的主要注册结构体
 
 
struct net_protocol {int(*handler)(struct sk_buff *skb);void(*err_handler)(struct sk_buff *skb, u32 info);int(*gso_send_check)(struct sk_buff *skb);struct sk_buff       *(*gso_segment)(struct sk_buff *skb,       int features);struct sk_buff      **(*gro_receive)(struct sk_buff **head,       struct sk_buff *skb);int(*gro_complete)(struct sk_buff *skb);unsigned intno_policy:1,netns_ok:1;}; 
 
他们会用一个 hash 链表链接起来
 
 
#define PTYPE_HASH_SIZE(16)
#define PTYPE_HASH_MASK(PTYPE_HASH_SIZE - 1)
 

static struct list_head ptype_base __read_mostly;
 
 
<div class="quote_title">kernel 写道
页: [1]
查看完整版本: <Linux Network 2.6.38> L2-L3