Skip to content

Commit 4cf24dc

Browse files
vbnogueiradavem330
authored andcommitted
net: sched: Add initial TC error skb drop reasons
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 <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b6a3c60 commit 4cf24dc

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

include/net/dropreason-core.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@
8585
FN(IPV6_NDISC_BAD_OPTIONS) \
8686
FN(IPV6_NDISC_NS_OTHERHOST) \
8787
FN(QUEUE_PURGE) \
88-
FN(TC_ERROR) \
88+
FN(TC_COOKIE_ERROR) \
8989
FN(PACKET_SOCK_ERROR) \
90+
FN(TC_CHAIN_NOTFOUND) \
91+
FN(TC_RECLASSIFY_LOOP) \
9092
FNe(MAX)
9193

9294
/**
@@ -377,13 +379,23 @@ enum skb_drop_reason {
377379
SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST,
378380
/** @SKB_DROP_REASON_QUEUE_PURGE: bulk free. */
379381
SKB_DROP_REASON_QUEUE_PURGE,
380-
/** @SKB_DROP_REASON_TC_ERROR: generic internal tc error. */
381-
SKB_DROP_REASON_TC_ERROR,
382+
/**
383+
* @SKB_DROP_REASON_TC_COOKIE_ERROR: An error occurred whilst
384+
* processing a tc ext cookie.
385+
*/
386+
SKB_DROP_REASON_TC_COOKIE_ERROR,
382387
/**
383388
* @SKB_DROP_REASON_PACKET_SOCK_ERROR: generic packet socket errors
384389
* after its filter matches an incoming packet.
385390
*/
386391
SKB_DROP_REASON_PACKET_SOCK_ERROR,
392+
/** @SKB_DROP_REASON_TC_CHAIN_NOTFOUND: tc chain lookup failed. */
393+
SKB_DROP_REASON_TC_CHAIN_NOTFOUND,
394+
/**
395+
* @SKB_DROP_REASON_TC_RECLASSIFY_LOOP: tc exceeded max reclassify loop
396+
* iterations.
397+
*/
398+
SKB_DROP_REASON_TC_RECLASSIFY_LOOP,
387399
/**
388400
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
389401
* 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
@@ -1119,7 +1119,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
11191119
}
11201120
} else if (TC_ACT_EXT_CMP(ret, TC_ACT_GOTO_CHAIN)) {
11211121
if (unlikely(!rcu_access_pointer(a->goto_chain))) {
1122-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1122+
tcf_set_drop_reason(skb,
1123+
SKB_DROP_REASON_TC_CHAIN_NOTFOUND);
11231124
return TC_ACT_SHOT;
11241125
}
11251126
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
@@ -1681,13 +1681,15 @@ static inline int __tcf_classify(struct sk_buff *skb,
16811681
*/
16821682
if (unlikely(n->tp != tp || n->tp->chain != n->chain ||
16831683
!tp->ops->get_exts)) {
1684-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1684+
tcf_set_drop_reason(skb,
1685+
SKB_DROP_REASON_TC_COOKIE_ERROR);
16851686
return TC_ACT_SHOT;
16861687
}
16871688

16881689
exts = tp->ops->get_exts(tp, n->handle);
16891690
if (unlikely(!exts || n->exts != exts)) {
1690-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1691+
tcf_set_drop_reason(skb,
1692+
SKB_DROP_REASON_TC_COOKIE_ERROR);
16911693
return TC_ACT_SHOT;
16921694
}
16931695

@@ -1716,7 +1718,8 @@ static inline int __tcf_classify(struct sk_buff *skb,
17161718
}
17171719

17181720
if (unlikely(n)) {
1719-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1721+
tcf_set_drop_reason(skb,
1722+
SKB_DROP_REASON_TC_COOKIE_ERROR);
17201723
return TC_ACT_SHOT;
17211724
}
17221725

@@ -1728,7 +1731,8 @@ static inline int __tcf_classify(struct sk_buff *skb,
17281731
tp->chain->block->index,
17291732
tp->prio & 0xffff,
17301733
ntohs(tp->protocol));
1731-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1734+
tcf_set_drop_reason(skb,
1735+
SKB_DROP_REASON_TC_RECLASSIFY_LOOP);
17321736
return TC_ACT_SHOT;
17331737
}
17341738

@@ -1766,7 +1770,8 @@ int tcf_classify(struct sk_buff *skb,
17661770
n = tcf_exts_miss_cookie_lookup(ext->act_miss_cookie,
17671771
&act_index);
17681772
if (!n) {
1769-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1773+
tcf_set_drop_reason(skb,
1774+
SKB_DROP_REASON_TC_COOKIE_ERROR);
17701775
return TC_ACT_SHOT;
17711776
}
17721777

@@ -1777,7 +1782,9 @@ int tcf_classify(struct sk_buff *skb,
17771782

17781783
fchain = tcf_chain_lookup_rcu(block, chain);
17791784
if (!fchain) {
1780-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1785+
tcf_set_drop_reason(skb,
1786+
SKB_DROP_REASON_TC_CHAIN_NOTFOUND);
1787+
17811788
return TC_ACT_SHOT;
17821789
}
17831790

@@ -1799,10 +1806,9 @@ int tcf_classify(struct sk_buff *skb,
17991806

18001807
ext = tc_skb_ext_alloc(skb);
18011808
if (WARN_ON_ONCE(!ext)) {
1802-
tcf_set_drop_reason(skb, SKB_DROP_REASON_TC_ERROR);
1809+
tcf_set_drop_reason(skb, SKB_DROP_REASON_NOMEM);
18031810
return TC_ACT_SHOT;
18041811
}
1805-
18061812
ext->chain = last_executed_chain;
18071813
ext->mru = cb->mru;
18081814
ext->post_ct = cb->post_ct;

0 commit comments

Comments
 (0)