Commit fb278072 authored by Victor Nogueira's avatar Victor Nogueira Committed by David S. Miller
Browse files

net: sched: Move drop_reason to struct tc_skb_cb



Move drop_reason from struct tcf_result to skb cb - more specifically to
struct tc_skb_cb. With that, we'll be able to also set the drop reason for
the remaining qdiscs (aside from clsact) that do not have access to
tcf_result when time comes to set the skb drop reason.

Signed-off-by: default avatarVictor Nogueira <victor@mojatatu.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 18764b88
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -154,10 +154,20 @@ __cls_set_class(unsigned long *clp, unsigned long cl)
	return xchg(clp, cl);
}

static inline void tcf_set_drop_reason(struct tcf_result *res,
struct tc_skb_cb;

static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb);

static inline enum skb_drop_reason
tcf_get_drop_reason(const struct sk_buff *skb)
{
	return tc_skb_cb(skb)->drop_reason;
}

static inline void tcf_set_drop_reason(const struct sk_buff *skb,
				       enum skb_drop_reason reason)
{
	res->drop_reason = reason;
	tc_skb_cb(skb)->drop_reason = reason;
}

static inline void
+2 −1
Original line number Diff line number Diff line
@@ -277,12 +277,13 @@ static inline void skb_txtime_consumed(struct sk_buff *skb)

struct tc_skb_cb {
	struct qdisc_skb_cb qdisc_cb;
	u32 drop_reason;

	u16 zone; /* Only valid if post_ct = true */
	u16 mru;
	u8 post_ct:1;
	u8 post_ct_snat:1;
	u8 post_ct_dnat:1;
	u16 zone; /* Only valid if post_ct = true */
};

static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb)
+0 −1
Original line number Diff line number Diff line
@@ -332,7 +332,6 @@ struct tcf_result {
		};
		const struct tcf_proto *goto_tp;
	};
	enum skb_drop_reason		drop_reason;
};

struct tcf_chain;
+2 −2
Original line number Diff line number Diff line
@@ -3923,14 +3923,14 @@ static int tc_run(struct tcx_entry *entry, struct sk_buff *skb,

	tc_skb_cb(skb)->mru = 0;
	tc_skb_cb(skb)->post_ct = false;
	res.drop_reason = *drop_reason;
	tcf_set_drop_reason(skb, *drop_reason);

	mini_qdisc_bstats_cpu_update(miniq, skb);
	ret = tcf_classify(skb, miniq->block, miniq->filter_list, &res, false);
	/* Only tcf related quirks below. */
	switch (ret) {
	case TC_ACT_SHOT:
		*drop_reason = res.drop_reason;
		*drop_reason = tcf_get_drop_reason(skb);
		mini_qdisc_qstats_cpu_drop(miniq);
		break;
	case TC_ACT_OK:
+1 −1
Original line number Diff line number Diff line
@@ -1119,7 +1119,7 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
			}
		} else if (TC_ACT_EXT_CMP(ret, TC_ACT_GOTO_CHAIN)) {
			if (unlikely(!rcu_access_pointer(a->goto_chain))) {
				tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR);
				tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
				return TC_ACT_SHOT;
			}
			tcf_action_goto_chain_exec(a, res);
Loading