Skip to content
Permalink
Browse files

Reinstate TC filter flow mapping override and expand it to hosts as well

This re-enables the ability to override the flow hashing from tc filter,
but makes sure cake_hash() is always called so the bookkeeping code is run
correctly.

In addition, the major number of the class ID can now be set to override
the host mapping in host isolation mode. If both host and flow are
overridden (or if the respective modes are disabled), flow dissection and
hashing will be skipped entirely; otherwise, the hashing will be kept for
the portions that are not set by the filter.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
  • Loading branch information
tohojo committed Aug 21, 2018
1 parent e678b38 commit b6c21ad5e57c9d80fe519b96cfb6fb55bc68a82d
Showing with 19 additions and 4 deletions.
  1. +19 −4 sch_cake.c
@@ -689,9 +689,9 @@ static bool cake_ddst(int flow_mode)
}

static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb,
int flow_mode)
int flow_mode, u16 flow_override, u16 host_override)
{
u32 flow_hash = 0, srchost_hash, dsthost_hash;
u32 flow_hash = 0, srchost_hash = 0, dsthost_hash = 0;
u16 reduced_hash, srchost_idx, dsthost_idx;
#if KERNEL_VERSION(4, 2, 0) > LINUX_VERSION_CODE
struct flow_keys keys;
@@ -702,6 +702,11 @@ static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb,
if (unlikely(flow_mode == CAKE_FLOW_NONE))
return 0;

/* If both overrides are set we can skip packet dissection entirely */
if ((flow_override || !(flow_mode & CAKE_FLOW_FLOWS)) &&
(host_override || !(flow_mode & CAKE_FLOW_HOSTS)))
goto skip_hash;

#if KERNEL_VERSION(4, 2, 0) > LINUX_VERSION_CODE
skb_flow_dissect(skb, &keys);

@@ -781,6 +786,14 @@ static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb,
flow_hash ^= dsthost_hash;
}

skip_hash:
if (flow_override)
flow_hash = flow_override - 1;
if (host_override) {
dsthost_hash = host_override - 1;
srchost_hash = host_override - 1;
}

reduced_hash = flow_hash % CAKE_QUEUES;

/* set-associative hashing */
@@ -1675,7 +1688,7 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t,
struct cake_sched_data *q = qdisc_priv(sch);
struct tcf_proto *filter;
struct tcf_result res;
u32 flow = 0;
u16 flow = 0, host = 0;
int result;

filter = rcu_dereference_bh(q->filter_list);
@@ -1705,10 +1718,12 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t,
#endif
if (TC_H_MIN(res.classid) <= CAKE_QUEUES)
flow = TC_H_MIN(res.classid);
if (TC_H_MAJ(res.classid) <= (CAKE_QUEUES << 16))
host = TC_H_MAJ(res.classid) >> 16;
}
hash:
*t = cake_select_tin(sch, skb);
return /* flow ?: */ cake_hash(*t, skb, flow_mode) + 1;
return cake_hash(*t, skb, flow_mode, flow, host) + 1;
}

static void cake_reconfigure(struct Qdisc *sch);

0 comments on commit b6c21ad

Please sign in to comment.
You can’t perform that action at this time.