The Linux kernel receives the Ethernet frame processing program-general Linux technology-Linux programming and kernel information. The following is a detailed description. 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 need to add the corresponding code. The following is the Linux kernel 2.6 code.
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 ).