VLAN Learning

A. VLAN data packet format

· Type: length of 2 bytes, frame type, frame 802.1Q Tag Type field set to a fixed value of 0x8100, if the device does not support 802.1Q 802.1Q frame is received, it is discarded.
· PRI: priority field, a length of 3 bit, indicating the priority of the Ethernet frame, in the range from 0 to 7, the greater the value, the higher the priority. When the switch / router traffic congestion occurs preferentially transmit high priority data frames.
· CFI: Canonical Format Indicator, length is 1bit, indicate whether the MAC address is a classic format. CFI 0 format described classical, non-classical CFI 1 indicates format. This field is used to distinguish the Ethernet frame, FDDI frame and token ring frame in an Ethernet frame, the CFI value of 0
· the VID: the VLAN ID, a length of 12 bit, in the range 0 to 4095, wherein 0 and 4095 are reserved values can not be used to the user.

Two. Vlan kernel source code analysis

VLAN network packets sent by the network interface vlan_dev_hard_start_xmit function processing

 

 

1) All through bridging / routing and forwarding via Example: a network interface that the packet network by the eth1.101 VLAN function processing vlan_dev_hard_start_xmit
2) Example: obtaining the VLAN configuration eth1.101 VLAN network interface, to configure the VLANID VLAN, VLAN priority
3) check the network packet meets add VLAN header information, updated in line with the VLAN header information in the skb by __vlan_hwaccel_put_tag according to vlan_tci update VLAN information skb

Guess you like

Origin www.cnblogs.com/mysky007/p/11223046.html