Skip to content

Commit 7087383

Browse files
committed
Merge branch 'netem-fix-further-issues-with-packet-corruption'
Jakub Kicinski says: ==================== net: netem: fix further issues with packet corruption This set is fixing two more issues with the netem packet corruption. First patch (which was previously posted) avoids NULL pointer dereference if the first frame gets freed due to allocation or checksum failure. v2 improves the clarity of the code a little as requested by Cong. Second patch ensures we don't return SUCCESS if the frame was in fact dropped. Thanks to this commit message for patch 1 no longer needs the "this will still break with a single-frame failure" disclaimer. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents bd310ac + e0ad032 commit 7087383

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

net/sched/sch_netem.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
509509
if (skb->ip_summed == CHECKSUM_PARTIAL &&
510510
skb_checksum_help(skb)) {
511511
qdisc_drop(skb, sch, to_free);
512+
skb = NULL;
512513
goto finish_segs;
513514
}
514515

@@ -593,9 +594,10 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
593594
finish_segs:
594595
if (segs) {
595596
unsigned int len, last_len;
596-
int nb = 0;
597+
int nb;
597598

598-
len = skb->len;
599+
len = skb ? skb->len : 0;
600+
nb = skb ? 1 : 0;
599601

600602
while (segs) {
601603
skb2 = segs->next;
@@ -612,7 +614,10 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
612614
}
613615
segs = skb2;
614616
}
615-
qdisc_tree_reduce_backlog(sch, -nb, prev_len - len);
617+
/* Parent qdiscs accounted for 1 skb of size @prev_len */
618+
qdisc_tree_reduce_backlog(sch, -(nb - 1), -(len - prev_len));
619+
} else if (!skb) {
620+
return NET_XMIT_DROP;
616621
}
617622
return NET_XMIT_SUCCESS;
618623
}

0 commit comments

Comments
 (0)