datapath: Make 'struct work_struct' consistent with kernel definition.
[openvswitch] / datapath / linux / compat / include / linux / if_vlan.h
index f418407487d890feb63910f4893207ac052c04a1..dc4b15e36e3e33660d27186d9910310c7fe8ae43 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef __LINUX_IF_VLAN_WRAPPER_H
 #define __LINUX_IF_VLAN_WRAPPER_H 1
 
-#include_next <linux/if_vlan.h>
 #include <linux/skbuff.h>
+#include <linux/version.h>
+#include_next <linux/if_vlan.h>
 
 /*
  * The behavior of __vlan_put_tag() has changed over time:
@@ -30,7 +31,7 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
        veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
 
        /* Move the mac addresses to the beginning of the new header. */
-       memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
+       memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN);
        skb->mac_header -= VLAN_HLEN;
 
        /* first, the ethernet type */
@@ -54,4 +55,38 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
 #define VLAN_TAG_PRESENT       VLAN_CFI_MASK
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
+static inline void vlan_set_encap_proto(struct sk_buff *skb, struct vlan_hdr *vhdr)
+{
+       __be16 proto;
+       unsigned char *rawp;
+
+       /*
+        * Was a VLAN packet, grab the encapsulated protocol, which the layer
+        * three protocols care about.
+        */
+
+       proto = vhdr->h_vlan_encapsulated_proto;
+       if (ntohs(proto) >= 1536) {
+               skb->protocol = proto;
+               return;
+       }
+
+       rawp = skb->data;
+       if (*(unsigned short *) rawp == 0xFFFF)
+               /*
+                * This is a magic hack to spot IPX packets. Older Novell
+                * breaks the protocol design and runs IPX over 802.3 without
+                * an 802.2 LLC layer. We look for FFFF which isn't a used
+                * 802.2 SSAP/DSAP. This won't work for fault tolerant netware
+                * but does for the rest.
+                */
+               skb->protocol = htons(ETH_P_802_3);
+       else
+               /*
+                * Real 802.2 LLC
+                */
+               skb->protocol = htons(ETH_P_802_2);
+}
+#endif
 #endif /* linux/if_vlan.h wrapper */