Skip to content

Commit e7bdc31

Browse files
vbnogueiraopsiff
authored andcommitted
net: sched: Add initial TC error skb drop reasons
mainline inclusion from mainline-v6.8-rc1 category: bugfix Continue expanding Daniel's patch by adding new skb drop reasons that are idiosyncratic to TC. More specifically: - SKB_DROP_REASON_TC_COOKIE_ERROR: An error occurred whilst processing a tc ext cookie. - SKB_DROP_REASON_TC_CHAIN_NOTFOUND: tc chain lookup failed. - SKB_DROP_REASON_TC_RECLASSIFY_LOOP: tc exceeded max reclassify loop iterations Signed-off-by: Victor Nogueira <victor@mojatatu.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 4cf24dc) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 7405982 commit e7bdc31

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

include/net/dropreason-core.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@
8080
FN(IPV6_NDISC_BAD_OPTIONS) \
8181
FN(IPV6_NDISC_NS_OTHERHOST) \
8282
FN(QUEUE_PURGE) \
83-
FN(TC_ERROR) \
83+
FN(TC_COOKIE_ERROR) \
8484
FN(PACKET_SOCK_ERROR) \
85+
FN(TC_CHAIN_NOTFOUND) \
86+
FN(TC_RECLASSIFY_LOOP) \
8587
FNe(MAX)
8688

8789
/**
@@ -347,13 +349,23 @@ enum skb_drop_reason {
347349
SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST,
348350
/** @SKB_DROP_REASON_QUEUE_PURGE: bulk free. */
349351
SKB_DROP_REASON_QUEUE_PURGE,
350-
/** @SKB_DROP_REASON_TC_ERROR: generic internal tc error. */
351-
SKB_DROP_REASON_TC_ERROR,
352+
/**
353+
* @SKB_DROP_REASON_TC_COOKIE_ERROR: An error occurred whilst
354+
* processing a tc ext cookie.
355+
*/
356+
SKB_DROP_REASON_TC_COOKIE_ERROR,
352357
/**
353358
* @SKB_DROP_REASON_PACKET_SOCK_ERROR: generic packet socket errors
354359
* after its filter matches an incoming packet.
355360
*/
356361
SKB_DROP_REASON_PACKET_SOCK_ERROR,
362+
/** @SKB_DROP_REASON_TC_CHAIN_NOTFOUND: tc chain lookup failed. */
363+
SKB_DROP_REASON_TC_CHAIN_NOTFOUND,
364+
/**
365+
* @SKB_DROP_REASON_TC_RECLASSIFY_LOOP: tc exceeded max reclassify loop
366+
* iterations.
367+
*/
368+
SKB_DROP_REASON_TC_RECLASSIFY_LOOP,
357369
/**
358370
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
359371
* shouldn't be used as a real 'reason' - only for tracing code gen

net/sched/act_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
11181118
}
11191119
} else if (TC_ACT_EXT_CMP(ret, TC_ACT_GOTO_CHAIN)) {
11201120
if (unlikely(!rcu_access_pointer(a->goto_chain))) {
1121-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1121+
tcf_set_drop_reason(skb,
1122+
SKB_DROP_REASON_TC_CHAIN_NOTFOUND);
11221123
return TC_ACT_SHOT;
11231124
}
11241125
tcf_action_goto_chain_exec(a, res);

net/sched/cls_api.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,13 +1688,15 @@ static inline int __tcf_classify(struct sk_buff *skb,
16881688
*/
16891689
if (unlikely(n->tp != tp || n->tp->chain != n->chain ||
16901690
!tp->ops->get_exts)) {
1691-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1691+
tcf_set_drop_reason(skb,
1692+
SKB_DROP_REASON_TC_COOKIE_ERROR);
16921693
return TC_ACT_SHOT;
16931694
}
16941695

16951696
exts = tp->ops->get_exts(tp, n->handle);
16961697
if (unlikely(!exts || n->exts != exts)) {
1697-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1698+
tcf_set_drop_reason(skb,
1699+
SKB_DROP_REASON_TC_COOKIE_ERROR);
16981700
return TC_ACT_SHOT;
16991701
}
17001702

@@ -1723,7 +1725,8 @@ static inline int __tcf_classify(struct sk_buff *skb,
17231725
}
17241726

17251727
if (unlikely(n)) {
1726-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1728+
tcf_set_drop_reason(skb,
1729+
SKB_DROP_REASON_TC_COOKIE_ERROR);
17271730
return TC_ACT_SHOT;
17281731
}
17291732

@@ -1735,7 +1738,8 @@ static inline int __tcf_classify(struct sk_buff *skb,
17351738
tp->chain->block->index,
17361739
tp->prio & 0xffff,
17371740
ntohs(tp->protocol));
1738-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1741+
tcf_set_drop_reason(skb,
1742+
SKB_DROP_REASON_TC_RECLASSIFY_LOOP);
17391743
return TC_ACT_SHOT;
17401744
}
17411745

@@ -1773,7 +1777,8 @@ int tcf_classify(struct sk_buff *skb,
17731777
n = tcf_exts_miss_cookie_lookup(ext->act_miss_cookie,
17741778
&act_index);
17751779
if (!n) {
1776-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1780+
tcf_set_drop_reason(skb,
1781+
SKB_DROP_REASON_TC_COOKIE_ERROR);
17771782
return TC_ACT_SHOT;
17781783
}
17791784

@@ -1784,7 +1789,9 @@ int tcf_classify(struct sk_buff *skb,
17841789

17851790
fchain = tcf_chain_lookup_rcu(block, chain);
17861791
if (!fchain) {
1787-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1792+
tcf_set_drop_reason(skb,
1793+
SKB_DROP_REASON_TC_CHAIN_NOTFOUND);
1794+
17881795
return TC_ACT_SHOT;
17891796
}
17901797

@@ -1806,10 +1813,9 @@ int tcf_classify(struct sk_buff *skb,
18061813

18071814
ext = tc_skb_ext_alloc(skb);
18081815
if (WARN_ON_ONCE(!ext)) {
1809-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1816+
tcf_set_drop_reason(skb, SKB_DROP_REASON_NOMEM);
18101817
return TC_ACT_SHOT;
18111818
}
1812-
18131819
ext->chain = last_executed_chain;
18141820
ext->mru = cb->mru;
18151821
ext->post_ct = cb->post_ct;

0 commit comments

Comments
 (0)