[ovs-dev] [PATCH 11/14] datapath: Account for "vlan: introduce *vlan_hwaccel_push_inside helpers"

Jesse Gross jesse at nicira.com
Thu Feb 19 03:02:21 UTC 2015


Upstream commit:
    vlan: introduce *vlan_hwaccel_push_inside helpers

    Use them to push skb->vlan_tci into the payload and avoid code
    duplication.

    Signed-off-by: Jiri Pirko <jiri at resnulli.us>
    Acked-by: Pravin B Shelar <pshelar at nicira.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

Upstream: 5968250c ("vlan: introduce *vlan_hwaccel_push_inside helpers")
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/linux/compat/include/linux/if_vlan.h | 36 +++++++++++++++++++++++++++
 datapath/linux/compat/vxlan.c                 | 11 +++-----
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/datapath/linux/compat/include/linux/if_vlan.h b/datapath/linux/compat/include/linux/if_vlan.h
index bc7d6c1..05c2876 100644
--- a/datapath/linux/compat/include/linux/if_vlan.h
+++ b/datapath/linux/compat/include/linux/if_vlan.h
@@ -52,6 +52,42 @@ static inline struct sk_buff *rpl_vlan_insert_tag_set_proto(struct sk_buff *skb,
 }
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+/*
+ * __vlan_hwaccel_push_inside - pushes vlan tag to the payload
+ * @skb: skbuff to tag
+ *
+ * Pushes the VLAN tag from @skb->vlan_tci inside to the payload.
+ *
+ * Following the skb_unshare() example, in case of error, the calling function
+ * doesn't have to worry about freeing the original skb.
+ */
+static inline struct sk_buff *__vlan_hwaccel_push_inside(struct sk_buff *skb)
+{
+	skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
+					vlan_tx_tag_get(skb));
+	if (likely(skb))
+		skb->vlan_tci = 0;
+	return skb;
+}
+/*
+ * vlan_hwaccel_push_inside - pushes vlan tag to the payload
+ * @skb: skbuff to tag
+ *
+ * Checks is tag is present in @skb->vlan_tci and if it is, it pushes the
+ * VLAN tag from @skb->vlan_tci inside to the payload.
+ *
+ * Following the skb_unshare() example, in case of error, the calling function
+ * doesn't have to worry about freeing the original skb.
+ */
+static inline struct sk_buff *vlan_hwaccel_push_inside(struct sk_buff *skb)
+{
+	if (vlan_tx_tag_present(skb))
+		skb = __vlan_hwaccel_push_inside(skb);
+	return skb;
+}
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
 static inline struct sk_buff *rpl___vlan_hwaccel_put_tag(struct sk_buff *skb,
 						     __be16 vlan_proto,
diff --git a/datapath/linux/compat/vxlan.c b/datapath/linux/compat/vxlan.c
index 969e6a8..ddcdd10 100644
--- a/datapath/linux/compat/vxlan.c
+++ b/datapath/linux/compat/vxlan.c
@@ -207,14 +207,9 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
 		return err;
 	}
 
-	if (skb_vlan_tag_present(skb)) {
-		if (unlikely(!vlan_insert_tag_set_proto(skb,
-							skb->vlan_proto,
-							skb_vlan_tag_get(skb))))
-			return -ENOMEM;
-
-		vlan_set_tci(skb, 0);
-	}
+	skb = vlan_hwaccel_push_inside(skb);
+	if (WARN_ON(!skb))
+		return -ENOMEM;
 
 	vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
 	vxh->vx_flags = htonl(VXLAN_HF_VNI);
-- 
1.9.1




More information about the dev mailing list