net: Add and use skb_mark_not_on_list().
authorDavid S. Miller <davem@davemloft.net>
Mon, 30 Jul 2018 03:42:53 +0000 (20:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Sep 2018 17:06:54 +0000 (10:06 -0700)
An SKB is not on a list if skb->next is NULL.

Codify this convention into a helper function and use it
where we are dequeueing an SKB and need to mark it as such.

Signed-off-by: David S. Miller <davem@davemloft.net>
22 files changed:
include/linux/skbuff.h
net/core/dev.c
net/core/sock.c
net/ieee802154/6lowpan/reassembly.c
net/ipv4/ip_fragment.c
net/ipv4/ip_input.c
net/ipv4/ip_output.c
net/ipv6/ip6_output.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/reassembly.c
net/netfilter/nfnetlink_queue.c
net/rxrpc/input.c
net/sched/sch_cake.c
net/sched/sch_fq.c
net/sched/sch_fq_codel.c
net/sched/sch_generic.c
net/sched/sch_hhf.c
net/sched/sch_netem.c
net/sched/sch_tbf.c
net/tipc/bearer.c
net/xfrm/xfrm_device.c
net/xfrm/xfrm_output.c

index 89283b77294d7a2ed57aac75e8297e1f0cf556c0..c4c9e3f5cd9ac280a2c49719da202633d98d568b 100644 (file)
@@ -1339,6 +1339,11 @@ static inline void skb_zcopy_abort(struct sk_buff *skb)
        }
 }
 
+static inline void skb_mark_not_on_list(struct sk_buff *skb)
+{
+       skb->next = NULL;
+}
+
 /**
  *     skb_queue_empty - check if a queue is empty
  *     @list: queue head
index ca78dc5a79a36a1c2e2cc04d65fe1646bafd4015..f76dd7e14dd616de4fe65304b477eae5b94fa89f 100644 (file)
@@ -3231,7 +3231,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *first, struct net_device *de
        while (skb) {
                struct sk_buff *next = skb->next;
 
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
                rc = xmit_one(skb, dev, txq, next != NULL);
                if (unlikely(!dev_xmit_complete(rc))) {
                        skb->next = next;
@@ -3331,7 +3331,7 @@ struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *d
 
        for (; skb != NULL; skb = next) {
                next = skb->next;
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
 
                /* in case skb wont be segmented, point to itself */
                skb->prev = skb;
@@ -5296,7 +5296,7 @@ static void __napi_gro_flush_chain(struct napi_struct *napi, u32 index,
                if (flush_old && NAPI_GRO_CB(skb)->age == jiffies)
                        return;
                list_del(&skb->list);
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
                napi_gro_complete(skb);
                napi->gro_hash[index].count--;
        }
@@ -5482,7 +5482,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
 
        if (pp) {
                list_del(&pp->list);
-               pp->next = NULL;
+               skb_mark_not_on_list(pp);
                napi_gro_complete(pp);
                napi->gro_hash[hash].count--;
        }
index 3730eb855095429b36018d006c82283d9a810577..8537b6ca72c5013a75c70978c079646f6278aabf 100644 (file)
@@ -2332,7 +2332,7 @@ static void __release_sock(struct sock *sk)
                        next = skb->next;
                        prefetch(next);
                        WARN_ON_ONCE(skb_dst_is_noref(skb));
-                       skb->next = NULL;
+                       skb_mark_not_on_list(skb);
                        sk_backlog_rcv(sk, skb);
 
                        cond_resched();
index e7857a8ac86db517cccd0e0a14b95d9c975c6b09..09ffbf5ce8fa99783ed7421e37d68e1217d69b04 100644 (file)
@@ -260,7 +260,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
        }
        sub_frag_mem_limit(fq->q.net, sum_truesize);
 
-       head->next = NULL;
+       skb_mark_not_on_list(head);
        head->dev = ldev;
        head->tstamp = fq->q.stamp;
 
index 330f62353b1191fc79b1ba75f71a30241224cc15..cab3e4a5124bfbdc7eccc171f987f611e1d44d94 100644 (file)
@@ -623,7 +623,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb,
        sub_frag_mem_limit(qp->q.net, head->truesize);
 
        *nextp = NULL;
-       head->next = NULL;
+       skb_mark_not_on_list(head);
        head->prev = NULL;
        head->dev = dev;
        head->tstamp = qp->q.stamp;
index 3196cf58f4189d4d11c3b895b15f430c720e0a2d..eba7f3883230a0cab5da9a789c9f20228d95b0c1 100644 (file)
@@ -535,7 +535,7 @@ static void ip_sublist_rcv_finish(struct list_head *head)
                /* Handle ip{6}_forward case, as sch_direct_xmit have
                 * another kind of SKB-list usage (see validate_xmit_skb_list)
                 */
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
                dst_input(skb);
        }
 }
index 9c4e72e9c60a7e2cfacdd45ce15f510d1db71a40..c09219e7f23048636836d52daf748bf7e81369e1 100644 (file)
@@ -278,7 +278,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk,
                struct sk_buff *nskb = segs->next;
                int err;
 
-               segs->next = NULL;
+               skb_mark_not_on_list(segs);
                err = ip_fragment(net, sk, segs, mtu, ip_finish_output2);
 
                if (err && ret == 0)
@@ -684,7 +684,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
 
                        skb = frag;
                        frag = skb->next;
-                       skb->next = NULL;
+                       skb_mark_not_on_list(skb);
                }
 
                if (err == 0) {
index 16f200f06500758c4cae84ea16229d5dbce912cb..9a8934ac053b81717f75f9d2d686009aaa1b9d3a 100644 (file)
@@ -727,7 +727,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
 
                        skb = frag;
                        frag = skb->next;
-                       skb->next = NULL;
+                       skb_mark_not_on_list(skb);
                }
 
                kfree(tmp_hdr);
index 2a14d8b65924d56c79380fed6d867cf62db42e33..00e20004d241113af71eef024c4ead380911c1e4 100644 (file)
@@ -449,7 +449,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev,  struct net_devic
        sub_frag_mem_limit(fq->q.net, head->truesize);
 
        head->ignore_df = 1;
-       head->next = NULL;
+       skb_mark_not_on_list(head);
        head->dev = dev;
        head->tstamp = fq->q.stamp;
        ipv6_hdr(head)->payload_len = htons(payload_len);
index 5c5b4f79296e3d18b66f074b415331893b13f367..f1b1ff30fe5bc36cc415358c0c92354a68e4268c 100644 (file)
@@ -388,7 +388,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
        }
        sub_frag_mem_limit(fq->q.net, sum_truesize);
 
-       head->next = NULL;
+       skb_mark_not_on_list(head);
        head->dev = dev;
        head->tstamp = fq->q.stamp;
        ipv6_hdr(head)->payload_len = htons(payload_len);
index ea4ba551abb28cb25c833dc408e23d1313b21bb4..5207eb8a5864ebb916783d37a8e0eddac99c8fc3 100644 (file)
@@ -764,7 +764,7 @@ __nfqnl_enqueue_packet_gso(struct net *net, struct nfqnl_instance *queue,
                return ret;
        }
 
-       skb->next = NULL;
+       skb_mark_not_on_list(skb);
 
        entry_seg = nf_queue_entry_dup(entry);
        if (entry_seg) {
index cfdc199c63510255c1d8cd60baed3c5f66b93d28..ee8e7e1d5c0fffd0f14a0c78afdf9a7ff479665b 100644 (file)
@@ -259,7 +259,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
        while (list) {
                skb = list;
                list = skb->next;
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
                rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
        }
 }
index c07c30b916d5e4d7b7fef5586f92df366194da85..dc539295ae6561d9698cab390538f47c3738c81f 100644 (file)
@@ -812,7 +812,7 @@ static struct sk_buff *dequeue_head(struct cake_flow *flow)
 
        if (skb) {
                flow->head = skb->next;
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
        }
 
        return skb;
@@ -1252,7 +1252,7 @@ found:
        else
                flow->head = elig_ack->next;
 
-       elig_ack->next = NULL;
+       skb_mark_not_on_list(elig_ack);
 
        return elig_ack;
 }
@@ -1675,7 +1675,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 
                while (segs) {
                        nskb = segs->next;
-                       segs->next = NULL;
+                       skb_mark_not_on_list(segs);
                        qdisc_skb_cb(segs)->pkt_len = segs->len;
                        cobalt_set_enqueue_time(segs, now);
                        get_cobalt_cb(segs)->adjusted_len = cake_overhead(q,
index 4808713c73b988cc3e536cff866cf18de05375fa..b27ba36a269cc72cd716da19dcfa27018ec01490 100644 (file)
@@ -319,7 +319,7 @@ static struct sk_buff *fq_dequeue_head(struct Qdisc *sch, struct fq_flow *flow)
 
        if (skb) {
                flow->head = skb->next;
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
                flow->qlen--;
                qdisc_qstats_backlog_dec(sch, skb);
                sch->q.qlen--;
index 6c0a9d5dbf9441d00a832915e23d6b82bd8ab313..cd04d40c30b672ef755b66a50ff42bf8240367db 100644 (file)
@@ -124,7 +124,7 @@ static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow)
        struct sk_buff *skb = flow->head;
 
        flow->head = skb->next;
-       skb->next = NULL;
+       skb_mark_not_on_list(skb);
        return skb;
 }
 
index 69078c82963ef1502820f0a4f372f83dc45b584e..a64132a5db3659d47ff0b4cfeea8510fd456680e 100644 (file)
@@ -184,7 +184,7 @@ static void try_bulk_dequeue_skb(struct Qdisc *q,
                skb = nskb;
                (*packets)++; /* GSO counts as one pkt */
        }
-       skb->next = NULL;
+       skb_mark_not_on_list(skb);
 }
 
 /* This variant of try_bulk_dequeue_skb() makes sure
@@ -210,7 +210,7 @@ static void try_bulk_dequeue_skb_slow(struct Qdisc *q,
                skb = nskb;
        } while (++cnt < 8);
        (*packets) += cnt;
-       skb->next = NULL;
+       skb_mark_not_on_list(skb);
 }
 
 /* Note that dequeue_skb can possibly return a SKB list (via skb->next).
index c3a8388dcdf6bcd5e8fc34f16c3104ce5c0de075..9d6a47697406091ba6fda460889f01923f658c77 100644 (file)
@@ -330,7 +330,7 @@ static struct sk_buff *dequeue_head(struct wdrr_bucket *bucket)
        struct sk_buff *skb = bucket->head;
 
        bucket->head = skb->next;
-       skb->next = NULL;
+       skb_mark_not_on_list(skb);
        return skb;
 }
 
index b9541ce4d67233839719e201f537a7b9b2254083..506e1960ed7f8ac52a6fbc9b68de66e246c3d249 100644 (file)
@@ -568,7 +568,7 @@ finish_segs:
        if (segs) {
                while (segs) {
                        skb2 = segs->next;
-                       segs->next = NULL;
+                       skb_mark_not_on_list(segs);
                        qdisc_skb_cb(segs)->pkt_len = segs->len;
                        last_len = segs->len;
                        rc = qdisc_enqueue(segs, sch, to_free);
index 6f74a426f159e440f33755e13656c849408bbc18..a4530e85bd023dfb0c01336c4aabdb13f33ac4b0 100644 (file)
@@ -162,7 +162,7 @@ static int tbf_segment(struct sk_buff *skb, struct Qdisc *sch,
        nb = 0;
        while (segs) {
                nskb = segs->next;
-               segs->next = NULL;
+               skb_mark_not_on_list(segs);
                qdisc_skb_cb(segs)->pkt_len = segs->len;
                len += segs->len;
                ret = qdisc_enqueue(segs, q->qdisc, to_free);
index 418f03d0be90f076cf34b1ee96495ceb3a3d68de..91891041e5e1bd905b30af890ba1f807aa88cb87 100644 (file)
@@ -577,7 +577,7 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,
                rcu_dereference_rtnl(orig_dev->tipc_ptr);
        if (likely(b && test_bit(0, &b->up) &&
                   (skb->pkt_type <= PACKET_MULTICAST))) {
-               skb->next = NULL;
+               skb_mark_not_on_list(skb);
                tipc_rcv(dev_net(b->pt.dev), skb, b);
                rcu_read_unlock();
                return NET_RX_SUCCESS;
index 5611b75210208cd3594922ede88f7c13c393cf3f..260fbba4f03eea65cb344d0ffad85a60aabbb17b 100644 (file)
@@ -99,7 +99,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
 
        do {
                struct sk_buff *nskb = skb2->next;
-               skb2->next = NULL;
+               skb_mark_not_on_list(skb2);
 
                xo = xfrm_offload(skb2);
                xo->flags |= XFRM_DEV_RESUME;
index 45ba07ab3e4f8d322e564c902774706ec09bcf9c..2d42cb0c94b823ce1d6b7872d73ef705c96077c2 100644 (file)
@@ -189,7 +189,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb
                struct sk_buff *nskb = segs->next;
                int err;
 
-               segs->next = NULL;
+               skb_mark_not_on_list(segs);
                err = xfrm_output2(net, sk, segs);
 
                if (unlikely(err)) {