1 From 8c95eca0bb8c4bd2231a0d581f1ad0d50c90488c Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com>
3 Date: Thu, 25 Jun 2020 22:12:08 +0200
4 Subject: [PATCH] sch_cake: don't call diffserv parsing code when it is not
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 As a further optimisation of the diffserv parsing codepath, we can skip it
11 entirely if CAKE is configured to neither use diffserv-based
12 classification, nor to zero out the diffserv bits.
14 Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits")
15 Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
19 net/sched/sch_cake.c | 13 +++++++++----
20 1 file changed, 9 insertions(+), 4 deletions(-)
22 --- a/net/sched/sch_cake.c
23 +++ b/net/sched/sch_cake.c
24 @@ -1551,7 +1551,7 @@ static unsigned int cake_drop(struct Qdi
25 return idx + (tin << 16);
28 -static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash)
29 +static u8 cake_handle_diffserv(struct sk_buff *skb, bool wash)
31 const int offset = skb_network_offset(skb);
33 @@ -1612,14 +1612,17 @@ static struct cake_tin_data *cake_select
35 struct cake_sched_data *q = qdisc_priv(sch);
40 /* Tin selection: Default to diffserv-based selection, allow overriding
41 - * using firewall marks or skb->priority.
42 + * using firewall marks or skb->priority. Call DSCP parsing early if
43 + * wash is enabled, otherwise defer to below to skip unneeded parsing.
45 - dscp = cake_handle_diffserv(skb,
46 - q->rate_flags & CAKE_FLAG_WASH);
47 mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft;
48 + wash = !!(q->rate_flags & CAKE_FLAG_WASH);
50 + dscp = cake_handle_diffserv(skb, wash);
52 if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT)
54 @@ -1633,6 +1636,8 @@ static struct cake_tin_data *cake_select
55 tin = q->tin_order[TC_H_MIN(skb->priority) - 1];
59 + dscp = cake_handle_diffserv(skb, wash);
60 tin = q->tin_index[dscp];
62 if (unlikely(tin >= q->tin_cnt))