Commit 90814e33 authored by Toke Høiland-Jørgensen's avatar Toke Høiland-Jørgensen Committed by Sasha Levin

sch_cake: don't call diffserv parsing code when it is not needed

[ Upstream commit 8c95eca0 ]

As a further optimisation of the diffserv parsing codepath, we can skip it
entirely if CAKE is configured to neither use diffserv-based
classification, nor to zero out the diffserv bits.

Fixes: c87b4ecd ("sch_cake: Make sure we can write the IP header before changing DSCP bits")
Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 98e4a340
...@@ -1508,7 +1508,7 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free) ...@@ -1508,7 +1508,7 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free)
return idx + (tin << 16); return idx + (tin << 16);
} }
static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) static u8 cake_handle_diffserv(struct sk_buff *skb, bool wash)
{ {
const int offset = skb_network_offset(skb); const int offset = skb_network_offset(skb);
u16 *buf, buf_; u16 *buf, buf_;
...@@ -1569,13 +1569,16 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch, ...@@ -1569,13 +1569,16 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch,
{ {
struct cake_sched_data *q = qdisc_priv(sch); struct cake_sched_data *q = qdisc_priv(sch);
u32 tin; u32 tin;
bool wash;
u8 dscp; u8 dscp;
/* Tin selection: Default to diffserv-based selection, allow overriding /* Tin selection: Default to diffserv-based selection, allow overriding
* using firewall marks or skb->priority. * using firewall marks or skb->priority. Call DSCP parsing early if
* wash is enabled, otherwise defer to below to skip unneeded parsing.
*/ */
dscp = cake_handle_diffserv(skb, wash = !!(q->rate_flags & CAKE_FLAG_WASH);
q->rate_flags & CAKE_FLAG_WASH); if (wash)
dscp = cake_handle_diffserv(skb, wash);
if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT) if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT)
tin = 0; tin = 0;
...@@ -1586,6 +1589,8 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch, ...@@ -1586,6 +1589,8 @@ static struct cake_tin_data *cake_select_tin(struct Qdisc *sch,
tin = q->tin_order[TC_H_MIN(skb->priority) - 1]; tin = q->tin_order[TC_H_MIN(skb->priority) - 1];
else { else {
if (!wash)
dscp = cake_handle_diffserv(skb, wash);
tin = q->tin_index[dscp]; tin = q->tin_index[dscp];
if (unlikely(tin >= q->tin_cnt)) if (unlikely(tin >= q->tin_cnt))
......
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