datapath: Account for "vlan: introduce *vlan_hwaccel_push_inside helpers"
authorJesse Gross <jesse@nicira.com>
Wed, 18 Feb 2015 00:06:42 +0000 (16:06 -0800)
committerJesse Gross <jesse@nicira.com>
Fri, 20 Feb 2015 23:34:26 +0000 (15:34 -0800)
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@resnulli.us>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 5968250c ("vlan: introduce *vlan_hwaccel_push_inside helpers")
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath/linux/compat/include/linux/if_vlan.h
datapath/linux/compat/vxlan.c

index bc7d6c1..05c2876 100644 (file)
@@ -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,
index 93cb91b..78456ec 100644 (file)
@@ -205,14 +205,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);