Skip to content

Commit a8305bf

Browse files
committed
net: Add and use skb_mark_not_on_list().
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 <[email protected]>
1 parent 776f07e commit a8305bf

File tree

22 files changed

+33
-28
lines changed

22 files changed

+33
-28
lines changed

include/linux/skbuff.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,11 @@ static inline void skb_zcopy_abort(struct sk_buff *skb)
13391339
}
13401340
}
13411341

1342+
static inline void skb_mark_not_on_list(struct sk_buff *skb)
1343+
{
1344+
skb->next = NULL;
1345+
}
1346+
13421347
/**
13431348
* skb_queue_empty - check if a queue is empty
13441349
* @list: queue head

net/core/dev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *first, struct net_device *de
32313231
while (skb) {
32323232
struct sk_buff *next = skb->next;
32333233

3234-
skb->next = NULL;
3234+
skb_mark_not_on_list(skb);
32353235
rc = xmit_one(skb, dev, txq, next != NULL);
32363236
if (unlikely(!dev_xmit_complete(rc))) {
32373237
skb->next = next;
@@ -3331,7 +3331,7 @@ struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *d
33313331

33323332
for (; skb != NULL; skb = next) {
33333333
next = skb->next;
3334-
skb->next = NULL;
3334+
skb_mark_not_on_list(skb);
33353335

33363336
/* in case skb wont be segmented, point to itself */
33373337
skb->prev = skb;
@@ -5296,7 +5296,7 @@ static void __napi_gro_flush_chain(struct napi_struct *napi, u32 index,
52965296
if (flush_old && NAPI_GRO_CB(skb)->age == jiffies)
52975297
return;
52985298
list_del(&skb->list);
5299-
skb->next = NULL;
5299+
skb_mark_not_on_list(skb);
53005300
napi_gro_complete(skb);
53015301
napi->gro_hash[index].count--;
53025302
}
@@ -5482,7 +5482,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
54825482

54835483
if (pp) {
54845484
list_del(&pp->list);
5485-
pp->next = NULL;
5485+
skb_mark_not_on_list(pp);
54865486
napi_gro_complete(pp);
54875487
napi->gro_hash[hash].count--;
54885488
}

net/core/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ static void __release_sock(struct sock *sk)
23322332
next = skb->next;
23332333
prefetch(next);
23342334
WARN_ON_ONCE(skb_dst_is_noref(skb));
2335-
skb->next = NULL;
2335+
skb_mark_not_on_list(skb);
23362336
sk_backlog_rcv(sk, skb);
23372337

23382338
cond_resched();

net/ieee802154/6lowpan/reassembly.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
260260
}
261261
sub_frag_mem_limit(fq->q.net, sum_truesize);
262262

263-
head->next = NULL;
263+
skb_mark_not_on_list(head);
264264
head->dev = ldev;
265265
head->tstamp = fq->q.stamp;
266266

net/ipv4/ip_fragment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb,
623623
sub_frag_mem_limit(qp->q.net, head->truesize);
624624

625625
*nextp = NULL;
626-
head->next = NULL;
626+
skb_mark_not_on_list(head);
627627
head->prev = NULL;
628628
head->dev = dev;
629629
head->tstamp = qp->q.stamp;

net/ipv4/ip_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static void ip_sublist_rcv_finish(struct list_head *head)
535535
/* Handle ip{6}_forward case, as sch_direct_xmit have
536536
* another kind of SKB-list usage (see validate_xmit_skb_list)
537537
*/
538-
skb->next = NULL;
538+
skb_mark_not_on_list(skb);
539539
dst_input(skb);
540540
}
541541
}

net/ipv4/ip_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk,
278278
struct sk_buff *nskb = segs->next;
279279
int err;
280280

281-
segs->next = NULL;
281+
skb_mark_not_on_list(segs);
282282
err = ip_fragment(net, sk, segs, mtu, ip_finish_output2);
283283

284284
if (err && ret == 0)
@@ -684,7 +684,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
684684

685685
skb = frag;
686686
frag = skb->next;
687-
skb->next = NULL;
687+
skb_mark_not_on_list(skb);
688688
}
689689

690690
if (err == 0) {

net/ipv6/ip6_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
727727

728728
skb = frag;
729729
frag = skb->next;
730-
skb->next = NULL;
730+
skb_mark_not_on_list(skb);
731731
}
732732

733733
kfree(tmp_hdr);

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devic
449449
sub_frag_mem_limit(fq->q.net, head->truesize);
450450

451451
head->ignore_df = 1;
452-
head->next = NULL;
452+
skb_mark_not_on_list(head);
453453
head->dev = dev;
454454
head->tstamp = fq->q.stamp;
455455
ipv6_hdr(head)->payload_len = htons(payload_len);

net/ipv6/reassembly.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
388388
}
389389
sub_frag_mem_limit(fq->q.net, sum_truesize);
390390

391-
head->next = NULL;
391+
skb_mark_not_on_list(head);
392392
head->dev = dev;
393393
head->tstamp = fq->q.stamp;
394394
ipv6_hdr(head)->payload_len = htons(payload_len);

0 commit comments

Comments
 (0)