kernel: remove linux 3.18 support
[openwrt/openwrt.git] / target / linux / generic / pending-4.4 / 035-fq_codel-fix-NET_XMIT_CN-behavior.patch
1 From: Eric Dumazet <edumazet@google.com>
2 Date: Sat, 4 Jun 2016 12:55:13 -0700
3 Subject: [PATCH] fq_codel: fix NET_XMIT_CN behavior
4
5 My prior attempt to fix the backlogs of parents failed.
6
7 If we return NET_XMIT_CN, our parents wont increase their backlog,
8 so our qdisc_tree_reduce_backlog() should take this into account.
9
10 v2: Florian Westphal pointed out that we could drop the packet,
11 so we need to save qdisc_pkt_len(skb) in a temp variable before
12 calling fq_codel_drop()
13
14 Fixes: 9d18562a2278 ("fq_codel: add batch ability to fq_codel_drop()")
15 Fixes: 2ccccf5fb43f ("net_sched: update hierarchical backlog too")
16 Reported-by: Stas Nichiporovich <stasn77@gmail.com>
17 Signed-off-by: Eric Dumazet <edumazet@google.com>
18 Cc: WANG Cong <xiyou.wangcong@gmail.com>
19 Cc: Jamal Hadi Salim <jhs@mojatatu.com>
20 ---
21
22 --- a/net/sched/sch_fq_codel.c
23 +++ b/net/sched/sch_fq_codel.c
24 @@ -197,6 +197,7 @@ static int fq_codel_enqueue(struct sk_bu
25 unsigned int idx, prev_backlog, prev_qlen;
26 struct fq_codel_flow *flow;
27 int uninitialized_var(ret);
28 + unsigned int pkt_len;
29 bool memory_limited;
30
31 idx = fq_codel_classify(skb, sch, &ret);
32 @@ -228,6 +229,8 @@ static int fq_codel_enqueue(struct sk_bu
33 prev_backlog = sch->qstats.backlog;
34 prev_qlen = sch->q.qlen;
35
36 + /* save this packet length as it might be dropped by fq_codel_drop() */
37 + pkt_len = qdisc_pkt_len(skb);
38 /* fq_codel_drop() is quite expensive, as it performs a linear search
39 * in q->backlogs[] to find a fat flow.
40 * So instead of dropping a single packet, drop half of its backlog
41 @@ -235,14 +238,23 @@ static int fq_codel_enqueue(struct sk_bu
42 */
43 ret = fq_codel_drop(sch, q->drop_batch_size);
44
45 - q->drop_overlimit += prev_qlen - sch->q.qlen;
46 + prev_qlen -= sch->q.qlen;
47 + prev_backlog -= sch->qstats.backlog;
48 + q->drop_overlimit += prev_qlen;
49 if (memory_limited)
50 - q->drop_overmemory += prev_qlen - sch->q.qlen;
51 - /* As we dropped packet(s), better let upper stack know this */
52 - qdisc_tree_reduce_backlog(sch, prev_qlen - sch->q.qlen,
53 - prev_backlog - sch->qstats.backlog);
54 + q->drop_overmemory += prev_qlen;
55
56 - return ret == idx ? NET_XMIT_CN : NET_XMIT_SUCCESS;
57 + /* As we dropped packet(s), better let upper stack know this.
58 + * If we dropped a packet for this flow, return NET_XMIT_CN,
59 + * but in this case, our parents wont increase their backlogs.
60 + */
61 + if (ret == idx) {
62 + qdisc_tree_reduce_backlog(sch, prev_qlen - 1,
63 + prev_backlog - pkt_len);
64 + return NET_XMIT_CN;
65 + }
66 + qdisc_tree_reduce_backlog(sch, prev_qlen, prev_backlog);
67 + return NET_XMIT_SUCCESS;
68 }
69
70 /* This is the specific function called from codel_dequeue()