Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net, sched: Add tcf_set_drop_reason for {__,}tcf_classify

Add an initial user for the newly added tcf_set_drop_reason() helper to set the
drop reason for internal errors leading to TC_ACT_SHOT inside {__,}tcf_classify().

Right now this only adds a very basic SKB_DROP_REASON_TC_ERROR as a generic
fallback indicator to mark drop locations. Where needed, such locations can be
converted to more specific codes, for example, when hitting the reclassification
limit, etc.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Victor Nogueira <victor@mojatatu.com>
Link: https://lore.kernel.org/r/20231009092655.22025-2-daniel@iogearbox.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Daniel Borkmann and committed by
Jakub Kicinski
39d08b91 54a59aed

+23 -6
+3
include/net/dropreason-core.h
··· 80 80 FN(IPV6_NDISC_BAD_OPTIONS) \ 81 81 FN(IPV6_NDISC_NS_OTHERHOST) \ 82 82 FN(QUEUE_PURGE) \ 83 + FN(TC_ERROR) \ 83 84 FNe(MAX) 84 85 85 86 /** ··· 346 345 SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST, 347 346 /** @SKB_DROP_REASON_QUEUE_PURGE: bulk free. */ 348 347 SKB_DROP_REASON_QUEUE_PURGE, 348 + /** @SKB_DROP_REASON_TC_ERROR: generic internal tc error. */ 349 + SKB_DROP_REASON_TC_ERROR, 349 350 /** 350 351 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which 351 352 * shouldn't be used as a real 'reason' - only for tracing code gen
+20 -6
net/sched/cls_api.c
··· 1681 1681 * time we got here with a cookie from hardware. 1682 1682 */ 1683 1683 if (unlikely(n->tp != tp || n->tp->chain != n->chain || 1684 - !tp->ops->get_exts)) 1684 + !tp->ops->get_exts)) { 1685 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1685 1686 return TC_ACT_SHOT; 1687 + } 1686 1688 1687 1689 exts = tp->ops->get_exts(tp, n->handle); 1688 - if (unlikely(!exts || n->exts != exts)) 1690 + if (unlikely(!exts || n->exts != exts)) { 1691 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1689 1692 return TC_ACT_SHOT; 1693 + } 1690 1694 1691 1695 n = NULL; 1692 1696 err = tcf_exts_exec_ex(skb, exts, act_index, res); ··· 1716 1712 return err; 1717 1713 } 1718 1714 1719 - if (unlikely(n)) 1715 + if (unlikely(n)) { 1716 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1720 1717 return TC_ACT_SHOT; 1718 + } 1721 1719 1722 1720 return TC_ACT_UNSPEC; /* signal: continue lookup */ 1723 1721 #ifdef CONFIG_NET_CLS_ACT ··· 1729 1723 tp->chain->block->index, 1730 1724 tp->prio & 0xffff, 1731 1725 ntohs(tp->protocol)); 1726 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1732 1727 return TC_ACT_SHOT; 1733 1728 } 1734 1729 ··· 1766 1759 if (ext->act_miss) { 1767 1760 n = tcf_exts_miss_cookie_lookup(ext->act_miss_cookie, 1768 1761 &act_index); 1769 - if (!n) 1762 + if (!n) { 1763 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1770 1764 return TC_ACT_SHOT; 1765 + } 1771 1766 1772 1767 chain = n->chain_index; 1773 1768 } else { ··· 1777 1768 } 1778 1769 1779 1770 fchain = tcf_chain_lookup_rcu(block, chain); 1780 - if (!fchain) 1771 + if (!fchain) { 1772 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1781 1773 return TC_ACT_SHOT; 1774 + } 1782 1775 1783 1776 /* Consume, so cloned/redirect skbs won't inherit ext */ 1784 1777 skb_ext_del(skb, TC_SKB_EXT); ··· 1799 1788 struct tc_skb_cb *cb = tc_skb_cb(skb); 1800 1789 1801 1790 ext = tc_skb_ext_alloc(skb); 1802 - if (WARN_ON_ONCE(!ext)) 1791 + if (WARN_ON_ONCE(!ext)) { 1792 + tcf_set_drop_reason(res, SKB_DROP_REASON_TC_ERROR); 1803 1793 return TC_ACT_SHOT; 1794 + } 1795 + 1804 1796 ext->chain = last_executed_chain; 1805 1797 ext->mru = cb->mru; 1806 1798 ext->post_ct = cb->post_ct;