参考一下博客:
http://yaoyang.blog.51cto.com/7657153/1269713
http://blog.csdn.net/eric_liufeng/article/details/10475583
网络驱动接收到报文后,会初始化skb->protocol字段,再通过netif_rx(skb);传输给3层协议,3层协议根据skb->protocol字段决定使用哪个协议实例处理。
某一mac协议类型的全部网络设备都是使用相同的xx_type_trans()函数来获取protocol的:以太网设备驱动调用eth_type_trans(), FDDI网络设备驱动调用fddi_type_trans().
/**
* eth_type_trans - determine the packet's protocol ID.
* @skb: received socket data
* @dev: receiving network device
*
* The rule here is that we
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*/
__be16 eth_type_t