Commit 177b8007 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: netem: fix backlog accounting for corrupted GSO frames

When GSO frame has to be corrupted netem uses skb_gso_segment()
to produce the list of frames, and re-enqueues the segments one
by one.  The backlog length has to be adjusted to account for
new frames.

The current calculation is incorrect, leading to wrong backlog
lengths in the parent qdisc (both bytes and packets), and
incorrect packet backlog count in netem itself.

Parent backlog goes negative, netem's packet backlog counts
all non-first segments twice (thus remaining non-zero even
after qdisc is emptied).

Move the variables used to count the adjustment into local
scope to make 100% sure they aren't used at any stage in
backports.

Fixes: 6071bd1a ("netem: Segment GSO packets on enqueue")
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
Acked-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 94762740
...@@ -439,8 +439,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -439,8 +439,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct netem_skb_cb *cb; struct netem_skb_cb *cb;
struct sk_buff *skb2; struct sk_buff *skb2;
struct sk_buff *segs = NULL; struct sk_buff *segs = NULL;
unsigned int len = 0, last_len, prev_len = qdisc_pkt_len(skb); unsigned int prev_len = qdisc_pkt_len(skb);
int nb = 0;
int count = 1; int count = 1;
int rc = NET_XMIT_SUCCESS; int rc = NET_XMIT_SUCCESS;
int rc_drop = NET_XMIT_DROP; int rc_drop = NET_XMIT_DROP;
...@@ -497,6 +496,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -497,6 +496,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
segs = netem_segment(skb, sch, to_free); segs = netem_segment(skb, sch, to_free);
if (!segs) if (!segs)
return rc_drop; return rc_drop;
qdisc_skb_cb(segs)->pkt_len = segs->len;
} else { } else {
segs = skb; segs = skb;
} }
...@@ -593,6 +593,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -593,6 +593,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
finish_segs: finish_segs:
if (segs) { if (segs) {
unsigned int len, last_len;
int nb = 0;
len = skb->len;
while (segs) { while (segs) {
skb2 = segs->next; skb2 = segs->next;
skb_mark_not_on_list(segs); skb_mark_not_on_list(segs);
...@@ -608,9 +613,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -608,9 +613,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
} }
segs = skb2; segs = skb2;
} }
sch->q.qlen += nb; qdisc_tree_reduce_backlog(sch, -nb, prev_len - len);
if (nb > 1)
qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len);
} }
return NET_XMIT_SUCCESS; return NET_XMIT_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment