summaryrefslogtreecommitdiff
path: root/datapath
diff options
context:
space:
mode:
authorYang, Yi Y <yi.y.yang@intel.com>2017-02-13 10:39:12 +0800
committerJoe Stringer <joe@ovn.org>2017-03-01 18:00:43 -0800
commit5c3f23fed6231e8df403794950c2cafe812f5a66 (patch)
tree1da13285ef02c57e52cb03ce76eb58de72bec7e4 /datapath
parent42b0cf5fe74793df27515a9f723b7619ddeae943 (diff)
downloadopenvswitch-5c3f23fed6231e8df403794950c2cafe812f5a66.tar.gz
datapath: backport: vlan: Introduce helper functions to check if skb is tagged
Upstream commit: commit f5a7fb88e1f82542ca14ba93a1d4fa35471c60ca Author: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Date: Fri Mar 27 14:31:11 2015 +0900 vlan: Introduce helper functions to check if skb is tagged Separate the two checks for single vlan and multiple vlans in netif_skb_features(). This allows us to move the check for multiple vlans to another function later. Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Acked-by: Eric Garver <e@erig.me> Signed-off-by: Joe Stringer <joe@ovn.org>
Diffstat (limited to 'datapath')
-rw-r--r--datapath/linux/compat/include/linux/if_vlan.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/datapath/linux/compat/include/linux/if_vlan.h b/datapath/linux/compat/include/linux/if_vlan.h
index 01f7bab68..e4c2ad3c8 100644
--- a/datapath/linux/compat/include/linux/if_vlan.h
+++ b/datapath/linux/compat/include/linux/if_vlan.h
@@ -230,4 +230,53 @@ static inline __be16 vlan_get_protocol(struct sk_buff *skb)
}
#endif
+
+#ifndef HAVE_SKB_VLAN_TAGGED
+/**
+ * skb_vlan_tagged - check if skb is vlan tagged.
+ * @skb: skbuff to query
+ *
+ * Returns true if the skb is tagged, regardless of whether it is hardware
+ * accelerated or not.
+ */
+static inline bool skb_vlan_tagged(const struct sk_buff *skb)
+{
+ if (!skb_vlan_tag_present(skb) &&
+ likely(skb->protocol != htons(ETH_P_8021Q) &&
+ skb->protocol != htons(ETH_P_8021AD)))
+ return false;
+
+ return true;
+}
+
+/**
+ * skb_vlan_tagged_multi - check if skb is vlan tagged with multiple headers.
+ * @skb: skbuff to query
+ *
+ * Returns true if the skb is tagged with multiple vlan headers, regardless
+ * of whether it is hardware accelerated or not.
+ */
+static inline bool skb_vlan_tagged_multi(const struct sk_buff *skb)
+{
+ __be16 protocol = skb->protocol;
+
+ if (!skb_vlan_tag_present(skb)) {
+ struct vlan_ethhdr *veh;
+
+ if (likely(protocol != htons(ETH_P_8021Q) &&
+ protocol != htons(ETH_P_8021AD)))
+ return false;
+
+ veh = (struct vlan_ethhdr *)skb->data;
+ protocol = veh->h_vlan_encapsulated_proto;
+ }
+
+ if (protocol != htons(ETH_P_8021Q) && protocol != htons(ETH_P_8021AD))
+ return false;
+
+ return true;
+}
+
+#endif /* HAVE_SKB_VLAN_TAGGED */
+
#endif /* linux/if_vlan.h wrapper */