How does the Linux kernel receive different types of ethereframes-general Linux technology-Linux programming and kernel information? For more information, see the following.
1. Preface
In addition to the 6-byte destination MAC address and 6-byte source MAC address, the Ethernet frame type value of the two bytes also exists in the Ethernet header, for example, IPv4 is 0x0800, ARP is 0x0806, etc, after the NIC driver receives the Ethernet frame, it uses the interface function netif_receive_skb () (netif_rx actually calls netif_receive_skb) to deliver it to the upper layer, and this interface function completes the distinction between the Ethernet frame types, deliver to different protocol handlers. If you want to write a processing program for an Ethernet frame, you must add the corresponding
The following Linux kernel code is 2.6.17.11.
2. Data Structure
Each protocol must define a packet_type structure, which leads to relevant protocol data processing functions. All nodes form a linked list (HASH linked list ).