Introduce tc block ports tracking and use
Subsystems (3)
Jamal Hadi Salim
maintainercover Introduce tc block ports tracking and use
In this patchset we introduce tc block netdev tracking infra. Patch 1 introduces the infra. Patch 2 exposes it to the datapath and patch 3 shows its usage via a new tc action "blockcast".
Jamal Hadi Salim (3):
Introduce tc block netdev tracking infra
Expose tc block ports to the datapath
Introduce blockcast tc action
include/net/sch_generic.h | 8 + include/net/tc_wrapper.h | 5 + net/sched/Kconfig | 13 ++ net/sched/Makefile | 1 + net/sched/act_blockcast.c | 315 ++++++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 7 +- net/sched/sch_api.c | 83 +++++++++- net/sched/sch_generic.c | 37 ++++- 8 files changed, 463 insertions(+), 6 deletions(-) create mode 100644 net/sched/act_blockcast.c
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH 1/3 Introduce tc block netdev tracking infra
The tc block is a collection of netdevs/ports which allow qdiscs to share filter block instances (as opposed to the traditional tc filter per port). Example:
$ tc qdisc add dev ens7 ingress block 22 $ tc qdisc add dev ens8 ingress block 22
Now we can add a filter using the block index:
$ tc filter add block 22 protocol ip pref 25 \ flower dst_ip 192.168.0.0/16 action drop
Upto this point, the block is unaware of its ports. This patch fixes that and makes the tc block ports available to the datapath as well as control path on offloading.
--- include/net/sch_generic.h | 4 ++ net/sched/cls_api.c | 1 + net/sched/sch_api.c | 82 +++++++++++++++++++++++++++++++++++++-- net/sched/sch_generic.c | 40 ++++++++++++++++++- 4 files changed, 121 insertions(+), 6 deletions(-)
include/net/sch_generic.h +4 -0
@@ -19,6 +19,7 @@#include <net/gen_stats.h> #include <net/rtnetlink.h> #include <net/flow_offload.h> +#include <linux/xarray.h> struct Qdisc_ops ;struct qdisc_walker ;
@@ -126,6 +127,8 @@ struct Qdisc {struct rcu_head rcu;netdevice_tracker dev_tracker; +netdevice_tracker in_block_tracker; +netdevice_tracker eg_block_tracker;/* private data */ long privdata[]____cacheline_aligned ; };
@@ -458,6 +461,7 @@ struct tcf_chain { };struct tcf_block { +struct xarray ports;/* datapath accessible */ /* Lock protects tcf_block and lifetime-management data of chains * attached to the block (refcnt, action_refcnt, explicitly_created). */
net/sched/cls_api.c +1 -0
@@ -1003,6 +1003,7 @@ static struct tcf_block *tcf_block_create(struct net *net, struct Qdisc *q,refcount_set (&block->refcnt,1 ); block->net = net; block->index = block_index; +xa_init (&block->ports);/* Don't store q pointer for blocks which are shared */ if (!tcf_block_shared (block))
net/sched/sch_api.c +78 -4
120 lines not on this page · raw message
net/sched/sch_generic.c +38 -2
@@ -1048,7 +1048,12 @@ static void qdisc_free_cb(struct rcu_head *head)static void __qdisc_destroy (struct Qdisc *qdisc) { -const struct Qdisc_ops *ops = qdisc->ops; +struct net_device *dev =qdisc_dev (qdisc); +const struct Qdisc_ops *ops = qdisc->ops; +const struct Qdisc_class_ops *cops; +struct tcf_block *block; +unsigned long cl; +u32 block_index;#ifdef CONFIG_NET_SCHED qdisc_hash_del (qdisc);
@@ -1059,11 +1064,42 @@ static void __qdisc_destroy(struct Qdisc *qdisc)qdisc_reset (qdisc); + cops = ops->cl_ops; +if (ops->ingress_block_get) { + block_index = ops->ingress_block_get (qdisc); +if (block_index) { +/* XXX: will only work for clsact and ingress, we need +* a flag for qdiscs instead of depending on this hack +*/ + cl =TC_H_MIN_INGRESS ; + block = cops->tcf_block (qdisc, cl,NULL ); +if (block) { +if (xa_erase (&block->ports, dev->ifindex)) +netdev_put (dev, &qdisc->in_block_tracker); + } + } + } + +if (ops->egress_block_get) { + block_index = ops->egress_block_get (qdisc); +if (block_index) { +/* XXX: will only work for clsact, we need a flag for +* qdiscs instead of depending on this hack +*/ + cl =TC_H_MIN_EGRESS ; + block = cops->tcf_block (qdisc, cl,NULL ); +if (block) { +if (xa_erase (&block->ports, dev->ifindex)) +netdev_put (dev, &qdisc->eg_block_tracker); + } + } + } +if (ops->destroy) ops->destroy (qdisc);module_put (ops->owner); -netdev_put (qdisc_dev (qdisc), &qdisc->dev_tracker); +netdev_put (dev, &qdisc->dev_tracker);trace_qdisc_destroy (qdisc);
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH 2/3 Expose tc block ports to the datapath
In reply to Jamal Hadi SalimThe datapath can now find the block of the port in which the packet arrived at. It can then use it for various activities.
In the next patch we show a simple action that multicast to all ports except for the port in which the packet arrived on.
--- include/net/sch_generic.h | 4 ++++ net/sched/cls_api.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-)
include/net/sch_generic.h +4 -0
@@ -440,6 +440,8 @@ struct qdisc_skb_cb { };#define QDISC_CB_PRIV_LEN 20unsigned char data[QDISC_CB_PRIV_LEN ]; +/* This should allow eBPF to continue to align */ +u32 block_index; };typedef void tcf_chain_head_change_t (struct tcf_proto *tp_head,void *priv);
@@ -488,6 +490,8 @@ struct tcf_block {struct mutex proto_destroy_lock;/* Lock for proto_destroy hashtable. */ }; +struct tcf_block *tcf_block_lookup (struct net *net,u32 block_index); +static inline bool lockdep_tcf_chain_is_locked (struct tcf_chain *chain) {return lockdep_is_held (&chain->filter_chain_lock);
net/sched/cls_api.c +5 -1
@@ -1011,12 +1011,13 @@ static struct tcf_block *tcf_block_create(struct net *net, struct Qdisc *q,return block; } -static struct tcf_block *tcf_block_lookup (struct net *net,u32 block_index) +struct tcf_block *tcf_block_lookup (struct net *net,u32 block_index) {struct tcf_net *tn =net_generic (net, tcf_net_id);return idr_find (&tn->idr, block_index); } +EXPORT_SYMBOL (tcf_block_lookup);static struct tcf_block *tcf_block_refcnt_get (struct net *net,u32 block_index) {
@@ -1737,9 +1738,12 @@ int tcf_classify(struct sk_buff *skb,const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { + struct qdisc_skb_cb *qdisc_cb = qdisc_skb_cb(skb);#if !IS_ENABLED (CONFIG_NET_TC_SKB_EXT )u32 last_executed_chain =0 ; + qdisc_cb->block_index = block->index; +return __tcf_classify (skb, tp, tp, res, compat_mode,NULL ,0 , &last_executed_chain);#else
Signature · 1 line
2.34.1
Re: [PATCH RFC net-next 2/3] Expose tc block ports to the datapath
net/sched/cls_api.c static struct tcf_block *tcf_block_create(struct net *net, struct Qdisc *q,
Quoted 7 lines · On Tue, 15 Aug 2023 12:25:29 -0400 Jamal Hadi Salim <[email protected]> wrote:
net/sched/cls_api.c +2
-0+struct tcf_block *tcf_block_lookup (struct net *net,u32 block_index) {struct tcf_net *tn =net_generic (net, tcf_net_id);return idr_find (&tn->idr, block_index); } +EXPORT_SYMBOL (tcf_block_lookup)
Use EXPORT_SYMBOL_GPL?
Jamal Hadi Salim
maintainerRe: [PATCH RFC net-next 2/3] Expose tc block ports to the datapath
Quoted 8 lines · Stephen Hemminger
Quoted 4 lines · On Tue, 15 Aug 2023 12:25:29 -0400 Jamal Hadi Salim <[email protected]> wrote:
+struct
tcf_block*tcf_block_lookup(struct net *net, u32block_index){ struct tcf_net *tn = net_generic(net, tcf_net_id);
Quoted 5 lines
Quoted 3 lines
return idr_find(&tn->idr, block_index);}
+EXPORT_SYMBOL(tcf_block_lookup)Use
EXPORT_SYMBOL_GPL?
Sure.
Quoted 1 line · Simon Horman
Quoted 31 lines · Simon Horman
Quoted 11 lines · Jamal Hadi Salim
The datapath can now find the block of the port in which the packet arrived at. It can then use it for various activities.
In the next patch we show a simple action that multicast to all ports except for the port in which the packet arrived on.
Co-developed-by Victor Nogueira <[email protected]>Signed-off-by Victor Nogueira <[email protected]>Co-developed-by Pedro Tammela <[email protected]>Signed-off-by Pedro Tammela <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>...
Quoted 4 lines
net/sched/cls_api.c +0
-0...
net/sched/cls_api.c int tcf_classify(struct sk_buff *skb, · line 1741
Quoted 5 lines
net/sched/cls_api.c +1
-0@@ -1737,9 +1738,12 @@ int tcf_classify(struct sk_buff *skb,const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { + struct qdisc_skb_cb *qdisc_cb = qdisc_skb_cb(skb);Hi Jamal,
Quoted 2 lines
Does the line above belong inside the condition immediately below? It seems potentially unused otherwise.
Indeed.
The Intel bot also complained about this. I guess we'll need an additional patch and move up "last_executed_chain" variable which is repeated twice. Then i can add the assignment on top of this. Something like:
net/sched/cls_api.c +2 -3
@@ -1736,13 +1736,12 @@ int tcf_classify(struct sk_buff *skb,const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { -#if !IS_ENABLED(CONFIG_NET_TC_SKB_EXT) u32 last_executed_chain = 0; - +#if !IS_ENABLED (CONFIG_NET_TC_SKB_EXT )return __tcf_classify (skb, tp, tp, res, compat_mode,NULL ,0 , &last_executed_chain);#else -u32 last_executed_chain = tp ? tp->chain->index :0 ; + last_executed_chain = tp ? tp->chain->index :0 ;struct tcf_exts_miss_cookie_node *n =NULL ;const struct tcf_proto *orig_tp = tp;struct tc_skb_ext *ext;
cheers,
jamal
Jamal Hadi Salim
maintainerRe: [PATCH RFC net-next 2/3] Expose tc block ports to the datapath
In reply to Stephen HemmingerQuoted 8 lines · Stephen Hemminger
Quoted 4 lines · On Tue, 15 Aug 2023 12:25:29 -0400 Jamal Hadi Salim <[email protected]> wrote:
+struct
tcf_block*tcf_block_lookup(struct net *net, u32block_index){ struct tcf_net *tn = net_generic(net, tcf_net_id);
Quoted 5 lines
Quoted 3 lines
return idr_find(&tn->idr, block_index);}
+EXPORT_SYMBOL(tcf_block_lookup)Use
EXPORT_SYMBOL_GPL?
Actually... all the other symbols exported in that area use EXPORT_SYMBOL() - i just cutnpasted. For consistency shouldnt i keep it?
cheers,
jamal
kernel test robot
build botRe: [PATCH RFC net-next 2/3] Expose tc block ports to the datapath
In reply to Jamal Hadi Salimkernel test robot noticed the following build warnings:
Hi Jamal,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jamal-Hadi-Salim/Introduce-tc-block-netdev-tracking-infra/20230816-002903 base: net-next/main patch link: https://lore.kernel.org/r/20230815162530.150994-3-jhs%40mojatatu.com patch subject: [PATCH RFC net-next 2/3] Expose tc block ports to the datapath config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230816/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230816/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
net/sched/cls_api.c: In function 'tcf_classify':
>> net/sched/cls_api.c:1741:30: warning: unused variable 'qdisc_cb' [-Wunused-variable]
1741 | struct qdisc_skb_cb *qdisc_cb = qdisc_skb_cb(skb);
| ^~~~~~~~vim +/qdisc_cb +1741 net/sched/cls_api.c
1735
1736 int tcf_classify(struct sk_buff *skb,
1737 const struct tcf_block *block,
1738 const struct tcf_proto *tp,
1739 struct tcf_result *res, bool compat_mode)
1740 {
> 1741 struct qdisc_skb_cb *qdisc_cb = qdisc_skb_cb(skb);
1742 #if !IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
1743 u32 last_executed_chain = 0;
1744
1745 qdisc_cb->block_index = block->index;
1746
1747 return __tcf_classify(skb, tp, tp, res, compat_mode, NULL, 0,
1748 &last_executed_chain);
1749 #else
1750 u32 last_executed_chain = tp ? tp->chain->index : 0;
1751 struct tcf_exts_miss_cookie_node *n = NULL;
1752 const struct tcf_proto *orig_tp = tp;
1753 struct tc_skb_ext *ext;
1754 int act_index = 0;
1755 int ret;
1756
1757 if (block) {
1758 ext = skb_ext_find(skb, TC_SKB_EXT);
1759
1760 if (ext && (ext->chain || ext->act_miss)) {
1761 struct tcf_chain *fchain;
1762 u32 chain;
1763
1764 if (ext->act_miss) {
1765 n = tcf_exts_miss_cookie_lookup(ext->act_miss_cookie,
1766 &act_index);
1767 if (!n)
1768 return TC_ACT_SHOT;
1769
1770 chain = n->chain_index;
1771 } else {
1772 chain = ext->chain;
1773 }
1774
1775 fchain = tcf_chain_lookup_rcu(block, chain);
1776 if (!fchain)
1777 return TC_ACT_SHOT;
1778
1779 /* Consume, so cloned/redirect skbs won't inherit ext */
1780 skb_ext_del(skb, TC_SKB_EXT);
1781
1782 tp = rcu_dereference_bh(fchain->filter_chain);
1783 last_executed_chain = fchain->index;
1784 }
1785 }
1786
1787 ret = __tcf_classify(skb, tp, orig_tp, res, compat_mode, n, act_index,
1788 &last_executed_chain);
1789
1790 if (tc_skb_ext_tc_enabled()) {
1791 /* If we missed on some chain */
1792 if (ret == TC_ACT_UNSPEC && last_executed_chain) {
1793 struct tc_skb_cb *cb = tc_skb_cb(skb);
1794
1795 ext = tc_skb_ext_alloc(skb);
1796 if (WARN_ON_ONCE(!ext))
1797 return TC_ACT_SHOT;
1798 ext->chain = last_executed_chain;
1799 ext->mru = cb->mru;
1800 ext->post_ct = cb->post_ct;
1801 ext->post_ct_snat = cb->post_ct_snat;
1802 ext->post_ct_dnat = cb->post_ct_dnat;
1803 ext->zone = cb->zone;
1804 }
1805 }
1806
1807 return ret;
1808 #endif
1809 }
1810 EXPORT_SYMBOL(tcf_classify);
1811
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Simon Horman
reviewerRe: [PATCH RFC net-next 2/3] Expose tc block ports to the datapath
In reply to Jamal Hadi SalimQuoted 11 lines · Jamal Hadi Salim
The datapath can now find the block of the port in which the packet arrived at. It can then use it for various activities.
In the next patch we show a simple action that multicast to all ports except for the port in which the packet arrived on.
Co-developed-by Victor Nogueira <[email protected]>Signed-off-by Victor Nogueira <[email protected]>Co-developed-by Pedro Tammela <[email protected]>Signed-off-by Pedro Tammela <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>
...
Quoted 4 lines
net/sched/cls_api.c +0
-0
...
net/sched/cls_api.c int tcf_classify(struct sk_buff *skb, · line 1741
Quoted 5 lines
net/sched/cls_api.c +1
-0@@ -1737,9 +1738,12 @@ int tcf_classify(struct sk_buff *skb,const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { + struct qdisc_skb_cb *qdisc_cb = qdisc_skb_cb(skb);
Hi Jamal,
Does the line above belong inside the condition immediately below? It seems potentially unused otherwise.
Quoted 12 lines
net/sched/cls_api.c +2
-0#if !IS_ENABLED (CONFIG_NET_TC_SKB_EXT )u32 last_executed_chain =0 ; + qdisc_cb->block_index = block->index; +return __tcf_classify (skb, tp, tp, res, compat_mode,NULL ,0 , &last_executed_chain);#else Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerRFC PATCH 3/3 Introduce blockcast tc action
In reply to Jamal Hadi SalimThis action takes advantage of the presence of tc block ports set in the datapath and broadcast a packet to all ports on that set with exception of the port in which it arrived on..
Example usage:
$ tc qdisc add dev ens7 ingress block 22
$ tc qdisc add dev ens8 ingress block 22Now we can add a filter using the block index:
$ tc filter add block 22 protocol ip pref 25 \ flower dst_ip 192.168.0.0/16 action blockcast
--- include/net/tc_wrapper.h | 5 + net/sched/Kconfig | 13 ++ net/sched/Makefile | 1 + net/sched/act_blockcast.c | 302 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 net/sched/act_blockcast.c
include/net/tc_wrapper.h +5 -0
@@ -28,6 +28,7 @@ TC_INDIRECT_ACTION_DECLARE(tcf_csum_act);TC_INDIRECT_ACTION_DECLARE (tcf_ct_act);TC_INDIRECT_ACTION_DECLARE (tcf_ctinfo_act);TC_INDIRECT_ACTION_DECLARE (tcf_gact_act); +TC_INDIRECT_ACTION_DECLARE (tcf_blockcast_run);TC_INDIRECT_ACTION_DECLARE (tcf_gate_act);TC_INDIRECT_ACTION_DECLARE (tcf_ife_act);TC_INDIRECT_ACTION_DECLARE (tcf_ipt_act);
@@ -57,6 +58,10 @@ static inline int tc_act(struct sk_buff *skb, const struct tc_action *a,if (a->ops->act == tcf_mirred_act)return tcf_mirred_act (skb, a, res);#endif +#if IS_BUILTIN (CONFIG_NET_ACT_BLOCKCAST ) +if (a->ops->act == tcf_blockcast_run) +return tcf_blockcast_run (skb, a, res); +#endif #if IS_BUILTIN (CONFIG_NET_ACT_PEDIT )if (a->ops->act == tcf_pedit_act)return tcf_pedit_act (skb, a, res);
net/sched/Kconfig +13 -0
@@ -780,6 +780,19 @@ config NET_ACT_SIMP To compile this code as a module, choose M here: the module will be called act_simple. +config NET_ACT_BLOCKCAST + tristate "TC block Multicast" + depends on NET_CLS_ACT + help + Say Y here to add an action that will multicast an skb to egress of + all netdevs that belong to a tc block except for the netdev on which + the skb arrived on + + If unsure, say N. + + To compile this code as a module, choose M here: the + module will be called act_blockcast. + config NET_ACT_SKBEDIT tristate "SKB Editing" depends on NET_CLS_ACT
net/sched/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o obj-$(CONFIG_NET_ACT_NAT) += act_nat.o obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o +obj-$(CONFIG_NET_ACT_BLOCKCAST) += act_blockcast.o obj-$(CONFIG_NET_ACT_SKBEDIT) += act_skbedit.o obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o obj-$(CONFIG_NET_ACT_MPLS) += act_mpls.o
net/sched/act_blockcast.c new file +302 -0
302 lines not on this page · raw message
Signature · 1 line
2.34.1
Simon Horman
reviewerRe: [PATCH RFC net-next 3/3] Introduce blockcast tc action
Quoted 17 lines · Jamal Hadi Salim
This action takes advantage of the presence of tc block ports set in the datapath and broadcast a packet to all ports on that set with exception of the port in which it arrived on..
Example usage:
$ tc qdisc add dev ens7 ingress block 22 $ tc qdisc add dev ens8 ingress block 22Now we can add a filter using the block index:
$ tc filter add block 22 protocol ip pref 25 \ flower dst_ip 192.168.0.0/16 action blockcastCo-developed-by Victor Nogueira <[email protected]>Signed-off-by Victor Nogueira <[email protected]>Co-developed-by Pedro Tammela <[email protected]>Signed-off-by Pedro Tammela <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>
...
Quoted 14 lines
net/sched/act_blockcast.c new file +14
-0+//XXX: Refactor mirred code and reuse here before final version +static int cast_one (struct sk_buff *skb,const u32 ifindex) +{ +struct sk_buff *skb2 = skb; +int retval =TC_ACT_PIPE ; +struct net_device *dev; +unsigned int rec_level; +bool expects_nh; +int mac_len; +bool at_nh; +int err; + + rec_level =__this_cpu_inc_return (redirect_rec_level); +if (unlikely (rec_level >CAST_RECURSION_LIMIT )) {
net/sched/act_blockcast.c line 60
Quoted 10 lines
net/sched/act_blockcast.c new file +10
-0+net_warn_ratelimited ("blockcast: exceeded redirect recursion limit on dev %s\n" , +netdev_name (skb->dev)); +__this_cpu_dec (redirect_rec_level); +return TC_ACT_SHOT ; + } + + dev =dev_get_by_index_rcu (dev_net (skb->dev), ifindex); +if (unlikely (!dev)) { +pr_notice_once ("blockcast: target device %s is gone\n" , + dev->name);
Hi Jamal,
This code is only executed if dev is NULL, but dev is dereferenced.
Quoted 3 lines
net/sched/act_blockcast.c new file +3
-0+__this_cpu_dec (redirect_rec_level); +return TC_ACT_SHOT ; + }
...
Jamal Hadi Salim
maintainerRe: [PATCH RFC net-next 3/3] Introduce blockcast tc action
Quoted 49 lines · Simon Horman
Quoted 17 lines · Jamal Hadi Salim
This action takes advantage of the presence of tc block ports set in the datapath and broadcast a packet to all ports on that set with exception of the port in which it arrived on..
Example usage:
$ tc qdisc add dev ens7 ingress block 22 $ tc qdisc add dev ens8 ingress block 22Now we can add a filter using the block index:
$ tc filter add block 22 protocol ip pref 25 \ flower dst_ip 192.168.0.0/16 action blockcastCo-developed-by Victor Nogueira <[email protected]>Signed-off-by Victor Nogueira <[email protected]>Co-developed-by Pedro Tammela <[email protected]>Signed-off-by Pedro Tammela <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>...
Quoted 14 lines
net/sched/act_blockcast.c new file +14
-0+//XXX: Refactor mirred code and reuse here before final version +static int cast_one (struct sk_buff *skb,const u32 ifindex) +{ +struct sk_buff *skb2 = skb; +int retval =TC_ACT_PIPE ; +struct net_device *dev; +unsigned int rec_level; +bool expects_nh; +int mac_len; +bool at_nh; +int err; + + rec_level =__this_cpu_inc_return (redirect_rec_level); +if (unlikely (rec_level >CAST_RECURSION_LIMIT )) {net/sched/act_blockcast.c line 60
Quoted 10 lines
net/sched/act_blockcast.c new file +10
-0+net_warn_ratelimited ("blockcast: exceeded redirect recursion limit on dev %s\n" , +netdev_name (skb->dev)); +__this_cpu_dec (redirect_rec_level); +return TC_ACT_SHOT ; + } + + dev =dev_get_by_index_rcu (dev_net (skb->dev), ifindex); +if (unlikely (!dev)) { +pr_notice_once ("blockcast: target device %s is gone\n" , + dev->name);Hi Jamal,
Quoted 2 lines
This code is only executed if dev is NULL, but dev is dereferenced.
good catch;-> Cutnpaste thing..
cheers,
jamal
Quoted 5 lines
Quoted 3 lines
net/sched/act_blockcast.c new file +3
-0+__this_cpu_dec (redirect_rec_level); +return TC_ACT_SHOT ; + }...
Jiri Pirko
maintainerQuoted 3 lines · Tue, Aug 15, 2023 at 06:25:27PM CEST, [email protected] wrote:
In this patchset we introduce tc block netdev tracking infra. Patch 1 introduces the infra. Patch 2 exposes it to the datapath and patch 3 shows its usage via a new tc action "blockcast".
This is very brief. Please describe motivation, how you solve the problem, provide examples, etc. From the cover letter, the reader should know what is going on without looking at the patches.
Quoted 21 lines
Jamal Hadi Salim (3):
Introduce tc block netdev tracking infra
Expose tc block ports to the datapath
Introduce blockcast tc actioninclude/net/sch_generic.h | 8 + include/net/tc_wrapper.h | 5 + net/sched/Kconfig | 13 ++ net/sched/Makefile | 1 + net/sched/act_blockcast.c | 315 ++++++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 7 +- net/sched/sch_api.c | 83 +++++++++- net/sched/sch_generic.c | 37 ++++- 8 files changed, 463 insertions(+), 6 deletions(-)create mode 100644
net/sched/act_blockcast.cSignature · 1 line
2.34.1