X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=datapath%2Fvlan.h;fp=datapath%2Fvlan.h;h=7e1084e5cb783f799092de8f8491f8f485ad62cc;hb=a52ae92c3993d7f1204288071c58d45013dfba58;hp=02a62909f5b3a08726664dd2a53d13a6b3f3536f;hpb=d2f723fde889e3b922234359f1ad6046fdcb862c;p=sliver-openvswitch.git diff --git a/datapath/vlan.h b/datapath/vlan.h index 02a62909f..7e1084e5c 100644 --- a/datapath/vlan.h +++ b/datapath/vlan.h @@ -13,6 +13,29 @@ #include #include +/** + * DOC: VLAN tag manipulation. + * + * &struct sk_buff handling of VLAN tags has evolved over time: + * + * In 2.6.26 and earlier, VLAN tags did not have any generic representation in + * an skb, other than as a raw 802.1Q header inside the packet data. + * + * In 2.6.27 &struct sk_buff added a @vlan_tci member. Between 2.6.27 and + * 2.6.32, its value was the raw contents of the 802.1Q TCI field, or zero if + * no 802.1Q header was present. This worked OK except for the corner case of + * an 802.1Q header with an all-0-bits TCI, which could not be represented. + * + * In 2.6.33, @vlan_tci semantics changed. Now, if an 802.1Q header is + * present, then the VLAN_TAG_PRESENT bit is always set. This fixes the + * all-0-bits TCI corner case. + * + * For compatibility we emulate the 2.6.33+ behavior on earlier kernel + * versions. The client must not access @vlan_tci directly. Instead, use + * vlan_get_tci() to read it or vlan_set_tci() to write it, with semantics + * equivalent to those on 2.6.33+. + */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) #define NEED_VLAN_FIELD #endif @@ -22,11 +45,18 @@ static inline void vlan_copy_skb_tci(struct sk_buff *skb) { } static inline u16 vlan_get_tci(struct sk_buff *skb) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) + if (skb->vlan_tci) + return skb->vlan_tci | VLAN_TAG_PRESENT; +#endif return skb->vlan_tci; } static inline void vlan_set_tci(struct sk_buff *skb, u16 vlan_tci) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) + vlan_tci &= ~VLAN_TAG_PRESENT; +#endif skb->vlan_tci = vlan_tci; } #else