]> git.proxmox.com Git - mirror_ovs.git/commitdiff
datapath: use skb_list_walk_safe helper for gso segments
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 12 Oct 2020 20:25:06 +0000 (13:25 -0700)
committerIlya Maximets <i.maximets@ovn.org>
Sat, 17 Oct 2020 15:32:06 +0000 (17:32 +0200)
Upstream commit:
    commit 2cec4448db38758832c2edad439f99584bb8fa0d
    Author: Jason A. Donenfeld <Jason@zx2c4.com>
    Date:   Mon Jan 13 18:42:29 2020 -0500

    net: openvswitch: use skb_list_walk_safe helper for gso segments

    This is a straight-forward conversion case for the new function, keeping
    the flow of the existing code as intact as possible.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
datapath/datapath.c
datapath/linux/compat/include/linux/skbuff.h

index 1bc8e143934c2b19b964737d39709df942dc561c..52a59f1351c73d5ebad5669ccf8f2df643d78fd5 100644 (file)
@@ -343,8 +343,7 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
        }
 #endif
        /* Queue all of the segments. */
-       skb = segs;
-       do {
+       skb_list_walk_safe(segs, skb, nskb) {
                *OVS_CB(skb) = ovs_cb;
 #ifdef HAVE_SKB_GSO_UDP
                if (gso_type & SKB_GSO_UDP && skb != segs)
@@ -354,17 +353,15 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
                if (err)
                        break;
 
-       } while ((skb = skb->next));
+       }
 
        /* Free all of the segments. */
-       skb = segs;
-       do {
-               nskb = skb->next;
+       skb_list_walk_safe(segs, skb, nskb) {
                if (err)
                        kfree_skb(skb);
                else
                        consume_skb(skb);
-       } while ((skb = nskb));
+       }
        return err;
 }
 
index 6d248b3ed08a6a2e82eba0c8e774c7a0480cc893..204ce54975ef1fc6d41dd9abeb58a9cf4c958f37 100644 (file)
@@ -487,4 +487,11 @@ static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
 }
 #endif
 
+#ifndef skb_list_walk_safe
+/* Iterate through singly-linked GSO fragments of an skb. */
+#define skb_list_walk_safe(first, skb, next_skb)                               \
+       for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb);  \
+            (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
+#endif
+
 #endif