Commit 3aa26055 authored by Davide Caratti's avatar Davide Caratti Committed by David S. Miller
Browse files

net/sched: store the last executed chain also for clsact egress



currently, only 'ingress' and 'clsact ingress' qdiscs store the tc 'chain
id' in the skb extension. However, userspace programs (like ovs) are able
to setup egress rules, and datapath gets confused in case it doesn't find
the 'chain id' for a packet that's "recirculated" by tc.
Change tcf_classify() to have the same semantic as tcf_classify_ingress()
so that a single function can be called in ingress / egress, using the tc
ingress / egress block respectively.

Suggested-by: default avatarAlaa Hleilel <alaa@nvidia.com>
Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
Reviewed-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b2492d50
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -76,10 +76,8 @@ static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
	return block->q;
}

int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
		 struct tcf_result *res, bool compat_mode);
int tcf_classify_ingress(struct sk_buff *skb,
			 const struct tcf_block *ingress_block,
int tcf_classify(struct sk_buff *skb,
		 const struct tcf_block *block,
		 const struct tcf_proto *tp, struct tcf_result *res,
		 bool compat_mode);

@@ -138,14 +136,8 @@ void tc_setup_cb_block_unregister(struct tcf_block *block, flow_setup_cb_t *cb,
{
}

static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
			       struct tcf_result *res, bool compat_mode)
{
	return TC_ACT_UNSPEC;
}

static inline int tcf_classify_ingress(struct sk_buff *skb,
				       const struct tcf_block *ingress_block,
static inline int tcf_classify(struct sk_buff *skb,
			       const struct tcf_block *block,
			       const struct tcf_proto *tp,
			       struct tcf_result *res, bool compat_mode)
{
+2 −3
Original line number Diff line number Diff line
@@ -4012,7 +4012,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
	qdisc_skb_cb(skb)->post_ct = false;
	mini_qdisc_bstats_cpu_update(miniq, skb);

	switch (tcf_classify(skb, miniq->filter_list, &cl_res, false)) {
	switch (tcf_classify(skb, miniq->block, miniq->filter_list, &cl_res, false)) {
	case TC_ACT_OK:
	case TC_ACT_RECLASSIFY:
		skb->tc_index = TC_H_MIN(cl_res.classid);
@@ -5164,8 +5164,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
	skb->tc_at_ingress = 1;
	mini_qdisc_bstats_cpu_update(miniq, skb);

	switch (tcf_classify_ingress(skb, miniq->block, miniq->filter_list,
				     &cl_res, false)) {
	switch (tcf_classify(skb, miniq->block, miniq->filter_list, &cl_res, false)) {
	case TC_ACT_OK:
	case TC_ACT_RECLASSIFY:
		skb->tc_index = TC_H_MIN(cl_res.classid);
+17 −25
Original line number Diff line number Diff line
@@ -1577,18 +1577,8 @@ static inline int __tcf_classify(struct sk_buff *skb,
#endif
}

int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
		 struct tcf_result *res, bool compat_mode)
{
	u32 last_executed_chain = 0;

	return __tcf_classify(skb, tp, tp, res, compat_mode,
			      &last_executed_chain);
}
EXPORT_SYMBOL(tcf_classify);

int tcf_classify_ingress(struct sk_buff *skb,
			 const struct tcf_block *ingress_block,
int tcf_classify(struct sk_buff *skb,
		 const struct tcf_block *block,
		 const struct tcf_proto *tp,
		 struct tcf_result *res, bool compat_mode)
{
@@ -1603,12 +1593,13 @@ int tcf_classify_ingress(struct sk_buff *skb,
	struct tc_skb_ext *ext;
	int ret;

	if (block) {
		ext = skb_ext_find(skb, TC_SKB_EXT);

		if (ext && ext->chain) {
			struct tcf_chain *fchain;

		fchain = tcf_chain_lookup_rcu(ingress_block, ext->chain);
			fchain = tcf_chain_lookup_rcu(block, ext->chain);
			if (!fchain)
				return TC_ACT_SHOT;

@@ -1618,6 +1609,7 @@ int tcf_classify_ingress(struct sk_buff *skb,
			tp = rcu_dereference_bh(fchain->filter_chain);
			last_executed_chain = fchain->index;
		}
	}

	ret = __tcf_classify(skb, tp, orig_tp, res, compat_mode,
			     &last_executed_chain);
@@ -1635,7 +1627,7 @@ int tcf_classify_ingress(struct sk_buff *skb,
	return ret;
#endif
}
EXPORT_SYMBOL(tcf_classify_ingress);
EXPORT_SYMBOL(tcf_classify);

struct tcf_chain_info {
	struct tcf_proto __rcu **pprev;
@@ -3825,7 +3817,7 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru

	fl = rcu_dereference_bh(qe->filter_chain);

	switch (tcf_classify(skb, fl, &cl_res, false)) {
	switch (tcf_classify(skb, NULL, fl, &cl_res, false)) {
	case TC_ACT_SHOT:
		qdisc_qstats_drop(sch);
		__qdisc_drop(skb, to_free);
+1 −1
Original line number Diff line number Diff line
@@ -394,7 +394,7 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
		list_for_each_entry(flow, &p->flows, list) {
			fl = rcu_dereference_bh(flow->filter_list);
			if (fl) {
				result = tcf_classify(skb, fl, &res, true);
				result = tcf_classify(skb, NULL, fl, &res, true);
				if (result < 0)
					continue;
				flow = (struct atm_flow_data *)res.class;
+1 −1
Original line number Diff line number Diff line
@@ -1665,7 +1665,7 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t,
		goto hash;

	*qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
	result = tcf_classify(skb, filter, &res, false);
	result = tcf_classify(skb, NULL, filter, &res, false);

	if (result >= 0) {
#ifdef CONFIG_NET_CLS_ACT
Loading