net: sched: allow qdiscs to share filter block instances
Subsystems (6)
Jiri Pirko
maintainerv4 cover net: sched: allow qdiscs to share filter block instances
From: Jiri Pirko <[email protected]>
Currently the filters added to qdiscs are independent. So for example if you have 2 netdevices and you create ingress qdisc on both and you want to add identical filter rules both, you need to add them twice. This patchset makes this easier and mainly saves resources allowing to share all filters within a qdisc - I call it a "filter block". Also this helps to save resources when we do offload to hw for example to expensive TCAM.
So back to the example. First, we create 2 qdiscs. Both will share block number 22. "22" is just an identification. If we don't pass any block number, a new one will be generated by kernel:
$ tc qdisc add dev ens7 ingress block 22
^^^^^^^^
$ tc qdisc add dev ens8 ingress block 22
^^^^^^^^Now if we list the qdiscs, we will see the block index in the output:
$ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22
To make is more visual, the situation looks like this:
ens7 ingress qdisc ens7 ingress qdisc
| |
| |
+----------> block 22 <----------+Unlimited number of qdiscs may share the same block.
Now we can add filter to any of qdiscs sharing the same block:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop
We will see the same output if we list filters for ens7 and ens8, including stats:
$ tc -s filter show dev ens7 ingress
filter protocol ip pref 25 flower chain 0
filter protocol ip pref 25 flower chain 0 handle 0x1
eth_type ipv4
dst_ip 192.168.0.0/16
not_in_hw
action order 1: gact action drop
random type none pass val 0
index 1 ref 1 bind 1 installed 39 sec used 2 sec
Action statistics:
Sent 3108 bytes 37 pkt (dropped 37, overlimits 0 requeues 0)
backlog 0b 0p requeues 0$ tc -s filter show dev ens8 ingress
filter protocol ip pref 25 flower chain 0
filter protocol ip pref 25 flower chain 0 handle 0x1
eth_type ipv4
dst_ip 192.168.0.0/16
not_in_hw
action order 1: gact action drop
random type none pass val 0
index 1 ref 1 bind 1 installed 40 sec used 3 sec
Action statistics:
Sent 3108 bytes 37 pkt (dropped 37, overlimits 0 requeues 0)
backlog 0b 0p requeues 0---v3->v4:
- patch 1:
- rebased on top of the current net-next
- added some extack strings
- patch 3:
- rebased on top of the current net-next
- patch 5:
- propagate netdev_ops->ndo_setup_tc error up to tcf_block_offload_bind caller
- patch 6:
- rebased on top of the current net-next
v2->v3:
- removed original patch 1, removing tp->q cls_bpf dependency. Fixed by Jakub in the meantime.
- patch 1:
- rebased on top of the current net-next
- patch 5:
- new patch
- patch 6:
- removed "p_" prefix from block index function args
- patch 9:
- add tc offload feature handling
Jiri Pirko (10):
net: sched: introduce support for multiple filter chain pointers
registration
net: sched: avoid usage of tp->q in tcf_classify
net: sched: introduce block mechanism to handle netif_keep_dst calls
net: sched: remove classid and q fields from tcf_proto
net: sched: keep track of offloaded filters and check tc offload
feature
net: sched: allow ingress and clsact qdiscs to share filter blocks
mlxsw: spectrum_acl: Reshuffle code around
mlxsw_sp_acl_ruleset_create/destroy
mlxsw: spectrum_acl: Don't store netdev and ingress for ruleset unbind
mlxsw: spectrum_acl: Implement TC block sharing
mlxsw: spectrum_acl: Pass mlxsw_sp_port down to ruleset bind/unbind
ops
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 182 ++++++++-- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 44 ++- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 302 ++++++++++++---- .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 44 ++- .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 41 +-- include/net/pkt_cls.h | 4 + include/net/sch_generic.h | 26 +- include/uapi/linux/pkt_sched.h | 11 + net/sched/cls_api.c | 380 ++++++++++++++++++--- net/sched/cls_bpf.c | 9 +- net/sched/cls_flow.c | 2 +- net/sched/cls_flower.c | 3 +- net/sched/cls_matchall.c | 3 +- net/sched/cls_route.c | 2 +- net/sched/cls_u32.c | 13 +- net/sched/sch_ingress.c | 89 ++++- 16 files changed, 931 insertions(+), 224 deletions(-)
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 1/10 net: sched: introduce support for multiple filter chain pointers registration
From: Jiri Pirko <[email protected]>
So far, there was possible only to register a single filter chain pointer to block->chain[0]. However, when the blocks will get shareable, we need to allow multiple filter chain pointers registration.
---v3->v4:
- rebased on top of the current net-next
- added some extack stringsv2->v3:
- rebased on top of the current net-next
--- include/net/pkt_cls.h | 3 + include/net/sch_generic.h | 5 +- net/sched/cls_api.c | 236 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 216 insertions(+), 28 deletions(-)
include/net/pkt_cls.h +3 -0
@@ -29,6 +29,8 @@ struct tcf_block_ext_info {enum tcf_block_binder_type binder_type;tcf_chain_head_change_t *chain_head_change;void *chain_head_change_priv; +bool shareable; +u32 block_index; };struct tcf_block_cb ;
@@ -50,6 +52,7 @@ void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,static inline struct Qdisc *tcf_block_q (struct tcf_block *block) { +WARN_ON (block->refcnt !=1 );return block->q; }
include/net/sch_generic.h +3 -2
@@ -275,8 +275,7 @@ typedef void tcf_chain_head_change_t(struct tcf_proto *tp_head, void *priv);struct tcf_chain {struct tcf_proto __rcu *filter_chain; -tcf_chain_head_change_t *chain_head_change; -void *chain_head_change_priv; +struct list_head filter_chain_list;struct list_head list;struct tcf_block *block;u32 index;/* chain index */
@@ -285,6 +284,8 @@ struct tcf_chain {struct tcf_block {struct list_head chain_list; +u32 index;/* block index for shared blocks */ +unsigned int refcnt;struct net *net;struct Qdisc *q;struct list_head cb_list;
net/sched/cls_api.c +210 -26
312 lines not on this page · raw message
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 2/10 net: sched: avoid usage of tp->q in tcf_classify
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Use block index in the messages instead.
--- net/sched/cls_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/sched/cls_api.c +3 -2
@@ -678,8 +678,9 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,#ifdef CONFIG_NET_CLS_ACT reset:if (unlikely (limit++ >= max_reclassify_loop)) { -net_notice_ratelimited ("%s: reclassify loop, rule prio %u, protocol %02x\n" , - tp->q->ops->id, tp->prio &0xffff , +net_notice_ratelimited ("%u: reclassify loop, rule prio %u, protocol %02x\n" , + tp->chain->block->index, + tp->prio &0xffff ,ntohs (tp->protocol));return TC_ACT_SHOT ; }
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 3/10 net: sched: introduce block mechanism to handle netif_keep_dst calls
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Couple of classifiers call netif_keep_dst directly on q->dev. That is not possible to do directly for shared blocke where multiple qdiscs are owning the block. So introduce a infrastructure to keep track of the block owners in list and use this list to implement block variant of netif_keep_dst.
---v3->v4:
- rebased on top of the current net-nextv1->v2:
- fix binder_type to check "egress" as well as pointed out by Daniel
--- include/net/pkt_cls.h | 1 + include/net/sch_generic.h | 2 ++ net/sched/cls_api.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ net/sched/cls_bpf.c | 4 +-- net/sched/cls_flow.c | 2 +- net/sched/cls_route.c | 2 +- 6 files changed, 76 insertions(+), 4 deletions(-)
include/net/pkt_cls.h +1 -0
@@ -40,6 +40,7 @@ bool tcf_queue_work(struct work_struct *work);struct tcf_chain *tcf_chain_get (struct tcf_block *block,u32 chain_index,bool create);void tcf_chain_put (struct tcf_chain *chain); +void tcf_block_netif_keep_dst (struct tcf_block *block);int tcf_block_get (struct tcf_block **p_block,struct tcf_proto __rcu **p_filter_chain,struct Qdisc *q,struct netlink_ext_ack *extack);
include/net/sch_generic.h +2 -0
@@ -289,6 +289,8 @@ struct tcf_block {struct net *net;struct Qdisc *q;struct list_head cb_list; +struct list_head owner_list; +bool keep_dst; };static inline void qdisc_cb_private_validate (const struct sk_buff *skb,int sz)
net/sched/cls_api.c +69 -0
99 lines not on this page · raw message
net/sched/cls_bpf.c +2 -2
@@ -392,8 +392,8 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog, prog->bpf_name = name; prog->filter = fp; -if (fp->dst_needed && !(tp->q->flags &TCQ_F_INGRESS )) -netif_keep_dst (qdisc_dev (tp->q)); +if (fp->dst_needed) +tcf_block_netif_keep_dst (tp->chain->block);return 0 ; }
net/sched/cls_flow.c +1 -1
@@ -526,7 +526,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,timer_setup (&fnew->perturb_timer, flow_perturbation,TIMER_DEFERRABLE ); -netif_keep_dst (qdisc_dev (tp->q)); +tcf_block_netif_keep_dst (tp->chain->block);if (tb[TCA_FLOW_KEYS ]) { fnew->keymask = keymask;
net/sched/cls_route.c +1 -1
@@ -527,7 +527,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,if (f->handle < f1->handle)break ; -netif_keep_dst (qdisc_dev (tp->q)); +tcf_block_netif_keep_dst (tp->chain->block);rcu_assign_pointer (f->next, f1);rcu_assign_pointer (*fp, f);
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 4/10 net: sched: remove classid and q fields from tcf_proto
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Both are no longer used, so remove them.
--- include/net/sch_generic.h | 2 -- net/sched/cls_api.c | 7 ++----- 2 files changed, 2 insertions(+), 7 deletions(-)
include/net/sch_generic.h +0 -2
@@ -255,8 +255,6 @@ struct tcf_proto {/* All the rest */ u32 prio; -u32 classid; -struct Qdisc *q;void *data;const struct tcf_proto_ops *ops;struct tcf_chain *chain;
net/sched/cls_api.c +2 -5
@@ -122,8 +122,7 @@ static inline u32 tcf_auto_prio(struct tcf_proto *tp) }static struct tcf_proto *tcf_proto_create (const char *kind,u32 protocol, -u32 prio,u32 parent,struct Qdisc *q, -struct tcf_chain *chain) +u32 prio,struct tcf_chain *chain) {struct tcf_proto *tp;int err;
@@ -157,8 +156,6 @@ static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol, tp->classify = tp->ops->classify; tp->protocol = protocol; tp->prio = prio; - tp->classid = parent; - tp->q = q; tp->chain = chain; err = tp->ops->init (tp);
@@ -1075,7 +1072,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, prio =tcf_auto_prio (tcf_chain_tp_prev (&chain_info)); tp =tcf_proto_create (nla_data (tca[TCA_KIND ]), - protocol, prio, parent, q, chain); + protocol, prio, chain);if (IS_ERR (tp)) { err =PTR_ERR (tp); goto errout;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 5/10 net: sched: keep track of offloaded filters and check tc offload feature
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
During block bind, we need to check tc offload feature. If it is disabled yet still the block contains offloaded filters, forbid the bind. Also forbid to register callback for a block that already containes offloaded filters, as the play back is not supported now. For keeping track of offloaded filters there is a new counter introduced, alongside with couple of helpers called from cls_* code. These helpers set and clear TCA_CLS_FLAGS_IN_HW flag.
---v3->v4:
- propagate netdev_ops->ndo_setup_tc error up to tcf_block_offload_bind callerv2->v3:
- new patch
--- include/net/sch_generic.h | 17 +++++++++++++ net/sched/cls_api.c | 63 ++++++++++++++++++++++++++++++++++++----------- net/sched/cls_bpf.c | 5 +++- net/sched/cls_flower.c | 3 ++- net/sched/cls_matchall.c | 3 ++- net/sched/cls_u32.c | 13 +++++----- 6 files changed, 81 insertions(+), 23 deletions(-)
include/net/sch_generic.h +17 -0
@@ -289,8 +289,25 @@ struct tcf_block {struct list_head cb_list;struct list_head owner_list;bool keep_dst; +unsigned int offloadcnt; }; +static inline void tcf_block_offload_inc (struct tcf_block *block,u32 *flags) +{ +if (*flags &TCA_CLS_FLAGS_IN_HW ) +return ; + *flags |=TCA_CLS_FLAGS_IN_HW ; + block->offloadcnt++; +} + +static inline void tcf_block_offload_dec (struct tcf_block *block,u32 *flags) +{ +if (!(*flags &TCA_CLS_FLAGS_IN_HW )) +return ; + *flags &= ~TCA_CLS_FLAGS_IN_HW ; + block->offloadcnt--; +} +static inline void qdisc_cb_private_validate (const struct sk_buff *skb,int sz) {struct qdisc_skb_cb *qcb;
net/sched/cls_api.c +49 -14
106 lines not on this page · raw message
net/sched/cls_bpf.c +4 -1
@@ -167,13 +167,16 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, cls_bpf.exts_integrated = obj->exts_integrated; cls_bpf.gen_flags = obj->gen_flags; +if (oldprog) +tcf_block_offload_dec (block, &oldprog->gen_flags); + err =tc_setup_cb_call (block,NULL ,TC_SETUP_CLSBPF , &cls_bpf, skip_sw);if (prog) {if (err <0 ) {cls_bpf_offload_cmd (tp, oldprog, prog);return err; }else if (err >0 ) { - prog->gen_flags |=TCA_CLS_FLAGS_IN_HW ; +tcf_block_offload_inc (block, &prog->gen_flags); } }
net/sched/cls_flower.c +2 -1
@@ -229,6 +229,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f)tc_setup_cb_call (block, &f->exts,TC_SETUP_CLSFLOWER , &cls_flower, false); +tcf_block_offload_dec (block, &f->flags); } static int fl_hw_replace_filter(struct tcf_proto *tp,
@@ -256,7 +257,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,fl_hw_destroy_filter (tp, f);return err; }else if (err >0 ) { - f->flags |=TCA_CLS_FLAGS_IN_HW ; +tcf_block_offload_inc (block, &f->flags); }if (skip_sw && !(f->flags &TCA_CLS_FLAGS_IN_HW ))
net/sched/cls_matchall.c +2 -1
@@ -81,6 +81,7 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp, cls_mall.cookie = cookie;tc_setup_cb_call (block,NULL ,TC_SETUP_CLSMATCHALL , &cls_mall, false); +tcf_block_offload_dec (block, &head->flags); } static int mall_replace_hw_filter(struct tcf_proto *tp,
@@ -103,7 +104,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp,mall_destroy_hw_filter (tp, head, cookie);return err; }else if (err >0 ) { - head->flags |=TCA_CLS_FLAGS_IN_HW ; +tcf_block_offload_inc (block, &head->flags); }if (skip_sw && !(head->flags &TCA_CLS_FLAGS_IN_HW ))
net/sched/cls_u32.c +7 -6
@@ -529,16 +529,17 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h,return 0 ; } -static void u32_remove_hw_knode (struct tcf_proto *tp,u32 handle) +static void u32_remove_hw_knode (struct tcf_proto *tp,struct tc_u_knode *n) {struct tcf_block *block = tp->chain->block;struct tc_cls_u32_offload cls_u32 = {};tc_cls_common_offload_init (&cls_u32.common, tp); cls_u32.command =TC_CLSU32_DELETE_KNODE ; - cls_u32.knode.handle = handle; + cls_u32.knode.handle = n->handle;tc_setup_cb_call (block,NULL ,TC_SETUP_CLSU32 , &cls_u32, false); +tcf_block_offload_dec (block, &n->flags); } static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
@@ -567,10 +568,10 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, err =tc_setup_cb_call (block,NULL ,TC_SETUP_CLSU32 , &cls_u32, skip_sw);if (err <0 ) { -u32_remove_hw_knode (tp, n->handle); +u32_remove_hw_knode (tp, n);return err; }else if (err >0 ) { - n->flags |=TCA_CLS_FLAGS_IN_HW ; +tcf_block_offload_inc (block, &n->flags); }if (skip_sw && !(n->flags &TCA_CLS_FLAGS_IN_HW ))
@@ -589,7 +590,7 @@ static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)RCU_INIT_POINTER (ht->ht[h],rtnl_dereference (n->next));tcf_unbind_filter (tp, &n->res); -u32_remove_hw_knode (tp, n->handle); +u32_remove_hw_knode (tp, n);idr_remove_ext (&ht->handle_idr, n->handle);if (tcf_exts_get_net (&n->exts))call_rcu (&n->rcu, u32_delete_key_freepf_rcu);
@@ -682,7 +683,7 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last) goto out;if (TC_U32_KEY (ht->handle)) { -u32_remove_hw_knode (tp, ht->handle); +u32_remove_hw_knode (tp, (struct tc_u_knode *)ht); ret =u32_delete_key (tp, (struct tc_u_knode *)ht); goto out; }
Signature · 1 line
2.9.5
Re: [patch net-next v4 05/10] net: sched: keep track of offloaded filters and check tc offload feature
Quoted 14 lines · Jiri Pirko
(quoted diff) +10
-3-static void tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, - struct tcf_block_ext_info *ei) +static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, + struct tcf_block_ext_info *ei) { - tcf_block_offload_cmd(block, q, ei, TC_BLOCK_BIND); + struct net_device *dev = q->dev_queue->dev; + int err; + + if (!dev->netdev_ops->ndo_setup_tc) + return 0; + + /* If tc offload feature is disabled and the block we try to bind + * to already has some offloaded filters, forbid to bind.
Review
Quoted 10 lines
(quoted diff) +9
-0+ */ + if (!tc_can_offload(dev) && tcf_block_offload_in_use(block)) + return -EOPNOTSUPP; + + err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_BIND); + if (err == -EOPNOTSUPP) + /* Driver does not support binding. */ + return 0; + return err; }
Would you mind explaining why those return 0s are safe?
Say I have 2 netdevs, one dumb NIC without ndo_setup_tc (dnic) and one NIC that can offload everything (enic). I can share a block between them (before or after adding any filters) and adding filters with skip_sw will succeed, even though dnic will not see them ever. There is only one callback for enic, "all callbacks" != "all devices". It's fine to share the block in such case, but that block can never accept a skip_sw filter. Don't we need something like (reverse) patch 3 for keeping track of netdevs sharing the block which are not OK with offloads?
Am I misunderstanding how this is supposed to work? Or simply too nit picky about providing predictable behaviour?
Quick hack to illustrate the idea (untested):
include/net/sch_generic.h +1 -0
@@ -289,6 +289,7 @@ struct tcf_block {struct list_head cb_list;struct list_head owner_list;bool keep_dst; +bool nonoffload_taint;unsigned int offloadcnt; };
net/sched/cls_api.c +12 -3
@@ -290,7 +290,7 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,int err;if (!dev->netdev_ops->ndo_setup_tc) -return 0 ; + goto mark_no_offload;/* If tc offload feature is disabled and the block we try to bind * to already has some offloaded filters, forbid to bind.
@@ -300,9 +300,14 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, err =tcf_block_offload_cmd (block, dev, ei,TC_BLOCK_BIND );if (err == -EOPNOTSUPP ) -/* Driver does not support binding. */ -return 0 ; + goto mark_no_offload;return err; + +mark_no_offload: +if (tcf_block_offload_in_use (block)) +return -EOPNOTSUPP ; + block->nonoffload_taint = true; +return 0 ; } static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
@@ -1492,6 +1497,10 @@ int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts,int ok_count;int ret; +/* Make sure all netdevs sharing this block are offload-capable */ +if (block->nonoffload_taint && err_stop) +return -EOPNOTSUPP ; + ret =tcf_block_cb_call (block, type, type_data, err_stop);if (ret <0 )return ret;
Here a block once tainted with a bad netdev will never be offloadable again, so tracking a'la patch 3 would be nicer..
Jiri Pirko
maintainerRe: [patch net-next v4 05/10] net: sched: keep track of offloaded filters and check tc offload feature
Quoted 38 lines · Sun, Dec 24, 2017 at 03:20:45AM CET, [email protected] wrote:
Quoted 14 lines · Jiri Pirko
(quoted diff) +10
-3-static void tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, - struct tcf_block_ext_info *ei) +static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, + struct tcf_block_ext_info *ei) { - tcf_block_offload_cmd(block, q, ei, TC_BLOCK_BIND); + struct net_device *dev = q->dev_queue->dev; + int err; + + if (!dev->netdev_ops->ndo_setup_tc) + return 0; + + /* If tc offload feature is disabled and the block we try to bind + * to already has some offloaded filters, forbid to bind.Review
Quoted 10 lines
(quoted diff) +9
-0+ */ + if (!tc_can_offload(dev) && tcf_block_offload_in_use(block)) + return -EOPNOTSUPP; + + err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_BIND); + if (err == -EOPNOTSUPP) + /* Driver does not support binding. */ + return 0; + return err; }Would you mind explaining why those return 0s are safe?
Say I have 2 netdevs, one dumb NIC without
ndo_setup_tc(dnic) and one NIC that can offload everything (enic). I can share a block between them (before or after adding any filters) and adding filters withskip_swwill succeed, even though dnic will not see them ever. There is only one callback for enic, "all callbacks" != "all devices". It's fine to share the block in such case, but that block can never accept askip_swfilter. Don't we need something like (reverse) patch 3 for keeping track of netdevs sharing the block which are not OK with offloads?
Quoted 2 lines
Am I misunderstanding how this is supposed to work? Or simply too nit picky about providing predictable behaviour?
You undestand it correctly. Original plan was to ignore thore devices that does not support offloading. But thinking about it a bit more, you are probably right that they should be taken into consideration when user explicitly says "skip_sw".
Will include the accounting you suggest below. Thanks!
Quoted 60 lines
Quick hack to illustrate the idea (untested):
include/net/sch_generic.h +1
-0@@ -289,6 +289,7 @@ struct tcf_block {struct list_head cb_list;struct list_head owner_list;bool keep_dst; +bool nonoffload_taint;unsigned int offloadcnt; };net/sched/cls_api.c +12
-3@@ -290,7 +290,7 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,int err;if (!dev->netdev_ops->ndo_setup_tc) -return 0 ; + goto mark_no_offload;/* If tc offload feature is disabled and the block we try to bind * to already has some offloaded filters, forbid to bind. @@ -300,9 +300,14 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, err =tcf_block_offload_cmd (block, dev, ei,TC_BLOCK_BIND );if (err == -EOPNOTSUPP ) -/* Driver does not support binding. */ -return 0 ; + goto mark_no_offload;return err; + +mark_no_offload: +if (tcf_block_offload_in_use (block)) +return -EOPNOTSUPP ; + block->nonoffload_taint = true; +return 0 ; } static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,@@ -1492,6 +1497,10 @@ int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts,int ok_count;int ret; +/* Make sure all netdevs sharing this block are offload-capable */ +if (block->nonoffload_taint && err_stop) +return -EOPNOTSUPP ; + ret =tcf_block_cb_call (block, type, type_data, err_stop);if (ret <0 )return ret;Here a block once tainted with a bad netdev will never be offloadable again, so tracking a'la patch 3 would be nicer..
Jiri Pirko
maintainerPATCH v4 6/10 net: sched: allow ingress and clsact qdiscs to share filter blocks
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Benefit from the previously introduced shared filter blocks infrastructure and allow ingress and clsact qdisc instances to share filter blocks. The block index is coming from userspace as qdisc option.
---v3->v4:
- rebased on top of the current net-next v2->v3:
- removed "p_" prefix from block index function args
--- include/uapi/linux/pkt_sched.h | 11 ++++++ net/sched/sch_ingress.c | 89 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-)
include/uapi/linux/pkt_sched.h +11 -0
@@ -934,4 +934,15 @@ enum {#define TCA_CBS_MAX (__TCA_CBS_MAX - 1) +/* Ingress/clsact */ + +enum { +TCA_CLSACT_UNSPEC , +TCA_CLSACT_INGRESS_BLOCK , +TCA_CLSACT_EGRESS_BLOCK , + __TCA_CLSACT_MAX +}; + +#define TCA_CLSACT_MAX (__TCA_CLSACT_MAX - 1) +#endif
net/sched/sch_ingress.c +88 -1
142 lines not on this page · raw message
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 7/10 mlxsw: spectrum_acl: Reshuffle code around mlxsw_sp_acl_ruleset_create/destroy
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
In order to prepare for follow-up changes, make the bind/unbind helpers very simple. That required move of ht insertion/removal and bind/unbind calls into mlxsw_sp_acl_ruleset_create/destroy.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 102 ++++++++++----------- 1 file changed, 46 insertions(+), 56 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +46 -56
@@ -118,8 +118,26 @@ struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp)return mlxsw_sp->acl->dummy_fid; } +static int mlxsw_sp_acl_ruleset_bind (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_ruleset *ruleset, +struct net_device *dev,bool ingress) +{ +const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; + +return ops->ruleset_bind (mlxsw_sp, ruleset->priv, dev, ingress); +} + +static void mlxsw_sp_acl_ruleset_unbind (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_ruleset *ruleset) +{ +const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; + + ops->ruleset_unbind (mlxsw_sp, ruleset->priv); +} +static struct mlxsw_sp_acl_ruleset * -mlxsw_sp_acl_ruleset_create (struct mlxsw_sp *mlxsw_sp, +mlxsw_sp_acl_ruleset_create (struct mlxsw_sp *mlxsw_sp,struct net_device *dev, +bool ingress,u32 chain_index,const struct mlxsw_sp_acl_profile_ops *ops) {struct mlxsw_sp_acl *acl = mlxsw_sp->acl;
@@ -132,6 +150,9 @@ mlxsw_sp_acl_ruleset_create(struct mlxsw_sp *mlxsw_sp,if (!ruleset)return ERR_PTR (-ENOMEM ); ruleset->ref_count =1 ; + ruleset->ht_key.dev = dev; + ruleset->ht_key.ingress = ingress; + ruleset->ht_key.chain_index = chain_index; ruleset->ht_key.ops = ops; err =rhashtable_init (&ruleset->rule_ht, &mlxsw_sp_acl_rule_ht_params);
@@ -142,68 +163,49 @@ mlxsw_sp_acl_ruleset_create(struct mlxsw_sp *mlxsw_sp,if (err) goto err_ops_ruleset_add; -return ruleset; - -err_ops_ruleset_add: -rhashtable_destroy (&ruleset->rule_ht); -err_rhashtable_init: -kfree (ruleset); -return ERR_PTR (err); -} - -static void mlxsw_sp_acl_ruleset_destroy (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_acl_ruleset *ruleset) -{ -const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; - - ops->ruleset_del (mlxsw_sp, ruleset->priv); -rhashtable_destroy (&ruleset->rule_ht); -kfree (ruleset); -} - -static int mlxsw_sp_acl_ruleset_bind (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_acl_ruleset *ruleset, -struct net_device *dev,bool ingress, -u32 chain_index) -{ -const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; -struct mlxsw_sp_acl *acl = mlxsw_sp->acl; -int err; - - ruleset->ht_key.dev = dev; - ruleset->ht_key.ingress = ingress; - ruleset->ht_key.chain_index = chain_index; err =rhashtable_insert_fast (&acl->ruleset_ht, &ruleset->ht_node, mlxsw_sp_acl_ruleset_ht_params);if (err) -return err; -if (!ruleset->ht_key.chain_index) { + goto err_ht_insert; + +if (!chain_index) {/* We only need ruleset with chain index 0, the implicit one, * to be directly bound to device. The rest of the rulesets * are bound by "Goto action set". */ - err = ops->ruleset_bind (mlxsw_sp, ruleset->priv, dev, ingress); + err =mlxsw_sp_acl_ruleset_bind (mlxsw_sp, ruleset, + dev, ingress);if (err) - goto err_ops_ruleset_bind; + goto err_ruleset_bind; } -return 0 ; -err_ops_ruleset_bind: +return ruleset; + +err_ruleset_bind:rhashtable_remove_fast (&acl->ruleset_ht, &ruleset->ht_node, mlxsw_sp_acl_ruleset_ht_params); -return err; +err_ht_insert: + ops->ruleset_del (mlxsw_sp, ruleset->priv); +err_ops_ruleset_add: +rhashtable_destroy (&ruleset->rule_ht); +err_rhashtable_init: +kfree (ruleset); +return ERR_PTR (err); } -static void mlxsw_sp_acl_ruleset_unbind (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_acl_ruleset *ruleset) +static void mlxsw_sp_acl_ruleset_destroy (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_ruleset *ruleset) {const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;struct mlxsw_sp_acl *acl = mlxsw_sp->acl;if (!ruleset->ht_key.chain_index) - ops->ruleset_unbind (mlxsw_sp, ruleset->priv); +mlxsw_sp_acl_ruleset_unbind (mlxsw_sp, ruleset);rhashtable_remove_fast (&acl->ruleset_ht, &ruleset->ht_node, mlxsw_sp_acl_ruleset_ht_params); + ops->ruleset_del (mlxsw_sp, ruleset->priv); +rhashtable_destroy (&ruleset->rule_ht); +kfree (ruleset); }static void mlxsw_sp_acl_ruleset_ref_inc (struct mlxsw_sp_acl_ruleset *ruleset)
@@ -216,7 +218,6 @@ static void mlxsw_sp_acl_ruleset_ref_dec(struct mlxsw_sp *mlxsw_sp, {if (--ruleset->ref_count)return ; -mlxsw_sp_acl_ruleset_unbind (mlxsw_sp, ruleset);mlxsw_sp_acl_ruleset_destroy (mlxsw_sp, ruleset); }
@@ -263,7 +264,6 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,const struct mlxsw_sp_acl_profile_ops *ops;struct mlxsw_sp_acl *acl = mlxsw_sp->acl;struct mlxsw_sp_acl_ruleset *ruleset; -int err; ops = acl->ops->profile_ops (mlxsw_sp, profile);if (!ops)
@@ -275,18 +275,8 @@ mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev,mlxsw_sp_acl_ruleset_ref_inc (ruleset);return ruleset; } - ruleset =mlxsw_sp_acl_ruleset_create (mlxsw_sp, ops); -if (IS_ERR (ruleset)) -return ruleset; - err =mlxsw_sp_acl_ruleset_bind (mlxsw_sp, ruleset, dev, - ingress, chain_index); -if (err) - goto err_ruleset_bind; -return ruleset; - -err_ruleset_bind: -mlxsw_sp_acl_ruleset_destroy (mlxsw_sp, ruleset); -return ERR_PTR (err); +return mlxsw_sp_acl_ruleset_create (mlxsw_sp, dev, ingress, + chain_index, ops); } void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp,
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 8/10 mlxsw: spectrum_acl: Don't store netdev and ingress for ruleset unbind
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Instead, pass netdev and ingress flag to ruleset unbind op.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 3 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 9 ++++-- .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 33 +++++++++++----------- 3 files changed, 24 insertions(+), 21 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +2 -1
@@ -477,7 +477,8 @@ struct mlxsw_sp_acl_profile_ops {void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv);int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv,struct net_device *dev,bool ingress); -void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv); +void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv, +struct net_device *dev,bool ingress);u16 (*ruleset_group_id)(void *ruleset_priv);size_t rule_priv_size; int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +6 -3
@@ -128,11 +128,12 @@ static int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, }static void mlxsw_sp_acl_ruleset_unbind (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_acl_ruleset *ruleset) +struct mlxsw_sp_acl_ruleset *ruleset, +struct net_device *dev,bool ingress) {const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; - ops->ruleset_unbind (mlxsw_sp, ruleset->priv); + ops->ruleset_unbind (mlxsw_sp, ruleset->priv, dev, ingress); } static struct mlxsw_sp_acl_ruleset *
@@ -200,7 +201,9 @@ static void mlxsw_sp_acl_ruleset_destroy(struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl *acl = mlxsw_sp->acl;if (!ruleset->ht_key.chain_index) -mlxsw_sp_acl_ruleset_unbind (mlxsw_sp, ruleset); +mlxsw_sp_acl_ruleset_unbind (mlxsw_sp, ruleset, + ruleset->ht_key.dev, + ruleset->ht_key.ingress);rhashtable_remove_fast (&acl->ruleset_ht, &ruleset->ht_node, mlxsw_sp_acl_ruleset_ht_params); ops->ruleset_del (mlxsw_sp, ruleset->priv);
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +16 -17
@@ -154,10 +154,6 @@ struct mlxsw_sp_acl_tcam_group {struct list_head region_list;unsigned int region_count;struct rhashtable chunk_ht; -struct { -u16 local_port; -bool ingress; - } bound;struct mlxsw_sp_acl_tcam_group_ops *ops;const struct mlxsw_sp_acl_tcam_pattern *patterns;unsigned int patterns_count;
@@ -271,26 +267,28 @@ mlxsw_sp_acl_tcam_group_bind(struct mlxsw_sp *mlxsw_sp,return -EINVAL ; mlxsw_sp_port =netdev_priv (dev); - group->bound.local_port = mlxsw_sp_port->local_port; - group->bound.ingress = ingress; -mlxsw_reg_ppbt_pack (ppbt_pl, - group->bound.ingress ?MLXSW_REG_PXBT_E_IACL : -MLXSW_REG_PXBT_E_EACL , -MLXSW_REG_PXBT_OP_BIND , group->bound.local_port, +mlxsw_reg_ppbt_pack (ppbt_pl, ingress ?MLXSW_REG_PXBT_E_IACL : +MLXSW_REG_PXBT_E_EACL , +MLXSW_REG_PXBT_OP_BIND , mlxsw_sp_port->local_port, group->id);return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (ppbt), ppbt_pl); }static void mlxsw_sp_acl_tcam_group_unbind (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_acl_tcam_group *group) +struct mlxsw_sp_acl_tcam_group *group, +struct net_device *dev,bool ingress) { +struct mlxsw_sp_port *mlxsw_sp_port;char ppbt_pl[MLXSW_REG_PPBT_LEN ]; -mlxsw_reg_ppbt_pack (ppbt_pl, - group->bound.ingress ?MLXSW_REG_PXBT_E_IACL : -MLXSW_REG_PXBT_E_EACL , -MLXSW_REG_PXBT_OP_UNBIND , group->bound.local_port, +if (WARN_ON (!mlxsw_sp_port_dev_check (dev))) +return ; + + mlxsw_sp_port =netdev_priv (dev); +mlxsw_reg_ppbt_pack (ppbt_pl, ingress ?MLXSW_REG_PXBT_E_IACL : +MLXSW_REG_PXBT_E_EACL , +MLXSW_REG_PXBT_OP_UNBIND , mlxsw_sp_port->local_port, group->id);mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (ppbt), ppbt_pl); }
@@ -1066,11 +1064,12 @@ mlxsw_sp_acl_tcam_flower_ruleset_bind(struct mlxsw_sp *mlxsw_sp,static void mlxsw_sp_acl_tcam_flower_ruleset_unbind (struct mlxsw_sp *mlxsw_sp, -void *ruleset_priv) +void *ruleset_priv, +struct net_device *dev,bool ingress) {struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset = ruleset_priv; -mlxsw_sp_acl_tcam_group_unbind (mlxsw_sp, &ruleset->group); +mlxsw_sp_acl_tcam_group_unbind (mlxsw_sp, &ruleset->group, dev, ingress); } static u16
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 9/10 mlxsw: spectrum_acl: Implement TC block sharing
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Benefit from the prepared TC and in-driver ACL infrastructure and introduce block sharing offload. For that, a new struct "block" is introduced in spectrum_acl in order to hold a list of specific block-port bindings.
---v2->v3:
- add tc offload feature handlingv1->v2:
- new patch
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 182 +++++++++++++--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 37 +++- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 237 ++++++++++++++++++--- .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 41 ++-- 4 files changed, 401 insertions(+), 96 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +152 -30
@@ -1747,72 +1747,186 @@ static int mlxsw_sp_setup_tc_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, }static int -mlxsw_sp_setup_tc_cls_flower (struct mlxsw_sp_port *mlxsw_sp_port, -struct tc_cls_flower_offload *f, -bool ingress) +mlxsw_sp_setup_tc_cls_flower (struct mlxsw_sp_acl_block *acl_block, +struct tc_cls_flower_offload *f) { +struct mlxsw_sp *mlxsw_sp =mlxsw_sp_acl_block_mlxsw_sp (acl_block); +switch (f->command) {case TC_CLSFLOWER_REPLACE : -return mlxsw_sp_flower_replace (mlxsw_sp_port, ingress, f); +return mlxsw_sp_flower_replace (mlxsw_sp, acl_block, f);case TC_CLSFLOWER_DESTROY : -mlxsw_sp_flower_destroy (mlxsw_sp_port, ingress, f); +mlxsw_sp_flower_destroy (mlxsw_sp, acl_block, f);return 0 ;case TC_CLSFLOWER_STATS : -return mlxsw_sp_flower_stats (mlxsw_sp_port, ingress, f); +return mlxsw_sp_flower_stats (mlxsw_sp, acl_block, f);default :return -EOPNOTSUPP ; } } -static int mlxsw_sp_setup_tc_block_cb (enum tc_setup_type type,void *type_data, -void *cb_priv,bool ingress) +static int mlxsw_sp_setup_tc_block_cb_matchall (enum tc_setup_type type, +void *type_data, +void *cb_priv,bool ingress) {struct mlxsw_sp_port *mlxsw_sp_port = cb_priv; -if (!tc_can_offload (mlxsw_sp_port->dev)) -return -EOPNOTSUPP ; -switch (type) {case TC_SETUP_CLSMATCHALL : +if (!tc_can_offload (mlxsw_sp_port->dev)) +return -EOPNOTSUPP ; +return mlxsw_sp_setup_tc_cls_matchall (mlxsw_sp_port, type_data, ingress);case TC_SETUP_CLSFLOWER : -return mlxsw_sp_setup_tc_cls_flower (mlxsw_sp_port, type_data, - ingress); +return 0 ;default :return -EOPNOTSUPP ; } } -static int mlxsw_sp_setup_tc_block_cb_ig (enum tc_setup_type type, -void *type_data,void *cb_priv) +static int mlxsw_sp_setup_tc_block_cb_matchall_ig (enum tc_setup_type type, +void *type_data, +void *cb_priv) { -return mlxsw_sp_setup_tc_block_cb (type, type_data, cb_priv, true); +return mlxsw_sp_setup_tc_block_cb_matchall (type, type_data, + cb_priv, true); } -static int mlxsw_sp_setup_tc_block_cb_eg (enum tc_setup_type type, -void *type_data,void *cb_priv) +static int mlxsw_sp_setup_tc_block_cb_matchall_eg (enum tc_setup_type type, +void *type_data, +void *cb_priv) { -return mlxsw_sp_setup_tc_block_cb (type, type_data, cb_priv, false); +return mlxsw_sp_setup_tc_block_cb_matchall (type, type_data, + cb_priv, false); +} + +static int mlxsw_sp_setup_tc_block_cb_flower (enum tc_setup_type type, +void *type_data,void *cb_priv) +{ +struct mlxsw_sp_acl_block *acl_block = cb_priv; + +switch (type) { +case TC_SETUP_CLSMATCHALL : +return 0 ; +case TC_SETUP_CLSFLOWER : +if (mlxsw_sp_acl_block_disabled (acl_block)) +return -EOPNOTSUPP ; + +return mlxsw_sp_setup_tc_cls_flower (acl_block, type_data); +default : +return -EOPNOTSUPP ; + } +} + +static int +mlxsw_sp_setup_tc_block_flower_bind (struct mlxsw_sp_port *mlxsw_sp_port, +struct tcf_block *block,bool ingress) +{ +struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; +struct mlxsw_sp_acl_block *acl_block; +struct tcf_block_cb *block_cb; +int err; + + block_cb =tcf_block_cb_lookup (block, mlxsw_sp_setup_tc_block_cb_flower, + mlxsw_sp); +if (!block_cb) { + acl_block =mlxsw_sp_acl_block_create (mlxsw_sp, block->net); +if (!acl_block) +return -ENOMEM ; + block_cb =__tcf_block_cb_register (block, + mlxsw_sp_setup_tc_block_cb_flower, + mlxsw_sp, acl_block); +if (IS_ERR (block_cb)) { + err =PTR_ERR (block_cb); + goto err_cb_register; + } + }else { + acl_block =tcf_block_cb_priv (block_cb); + } +tcf_block_cb_incref (block_cb); + err =mlxsw_sp_acl_block_bind (mlxsw_sp, acl_block, + mlxsw_sp_port, ingress); +if (err) + goto err_block_bind; + +if (ingress) + mlxsw_sp_port->ing_acl_block = acl_block; +else + mlxsw_sp_port->eg_acl_block = acl_block; + +return 0 ; + +err_block_bind: +if (!tcf_block_cb_decref (block_cb)) { +__tcf_block_cb_unregister (block_cb); +err_cb_register: +mlxsw_sp_acl_block_destroy (acl_block); + } +return err; +} + +static void +mlxsw_sp_setup_tc_block_flower_unbind (struct mlxsw_sp_port *mlxsw_sp_port, +struct tcf_block *block,bool ingress) +{ +struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; +struct mlxsw_sp_acl_block *acl_block; +struct tcf_block_cb *block_cb; +int err; + + block_cb =tcf_block_cb_lookup (block, mlxsw_sp_setup_tc_block_cb_flower, + mlxsw_sp); +if (!block_cb) +return ; + +if (ingress) + mlxsw_sp_port->ing_acl_block =NULL ; +else + mlxsw_sp_port->eg_acl_block =NULL ; + + acl_block =tcf_block_cb_priv (block_cb); + err =mlxsw_sp_acl_block_unbind (mlxsw_sp, acl_block, + mlxsw_sp_port, ingress); +if (!err && !tcf_block_cb_decref (block_cb)) { +__tcf_block_cb_unregister (block_cb); +mlxsw_sp_acl_block_destroy (acl_block); + } }static int mlxsw_sp_setup_tc_block (struct mlxsw_sp_port *mlxsw_sp_port,struct tc_block_offload *f) {tc_setup_cb_t *cb; +bool ingress; +int err; -if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) - cb = mlxsw_sp_setup_tc_block_cb_ig; -else if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) - cb = mlxsw_sp_setup_tc_block_cb_eg; -else +if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) { + cb = mlxsw_sp_setup_tc_block_cb_matchall_ig; + ingress = true; + }else if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) { + cb = mlxsw_sp_setup_tc_block_cb_matchall_eg; + ingress = false; + }else {return -EOPNOTSUPP ; + }switch (f->command) {case TC_BLOCK_BIND : -return tcf_block_cb_register (f->block, cb, mlxsw_sp_port, - mlxsw_sp_port); + err =tcf_block_cb_register (f->block, cb, mlxsw_sp_port, + mlxsw_sp_port); +if (err) +return err; + err =mlxsw_sp_setup_tc_block_flower_bind (mlxsw_sp_port, + f->block, ingress); +if (err) { +tcf_block_cb_unregister (f->block, cb, mlxsw_sp_port); +return err; + } +return 0 ;case TC_BLOCK_UNBIND : +mlxsw_sp_setup_tc_block_flower_unbind (mlxsw_sp_port, + f->block, ingress);tcf_block_cb_unregister (f->block, cb, mlxsw_sp_port);return 0 ;default :
@@ -1840,10 +1954,18 @@ static int mlxsw_sp_feature_hw_tc(struct net_device *dev, bool enable) {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev); -if (!enable && (mlxsw_sp_port->acl_rule_count || - !list_empty (&mlxsw_sp_port->mall_tc_list))) { -netdev_err (dev,"Active offloaded tc filters, can't turn hw_tc_offload off\n" ); -return -EINVAL ; +if (!enable) { +if (mlxsw_sp_acl_block_rule_count (mlxsw_sp_port->ing_acl_block) || +mlxsw_sp_acl_block_rule_count (mlxsw_sp_port->eg_acl_block) || + !list_empty (&mlxsw_sp_port->mall_tc_list)) { +netdev_err (dev,"Active offloaded tc filters, can't turn hw_tc_offload off\n" ); +return -EINVAL ; + } +mlxsw_sp_acl_block_disable_inc (mlxsw_sp_port->ing_acl_block); +mlxsw_sp_acl_block_disable_inc (mlxsw_sp_port->eg_acl_block); + }else { +mlxsw_sp_acl_block_disable_dec (mlxsw_sp_port->ing_acl_block); +mlxsw_sp_acl_block_disable_dec (mlxsw_sp_port->eg_acl_block); }return 0 ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +29 -8
@@ -270,7 +270,8 @@ struct mlxsw_sp_port {struct mlxsw_sp_port_sample *sample;struct list_head vlans_list;struct mlxsw_sp_qdisc root_qdisc; -unsigned acl_rule_count; +struct mlxsw_sp_acl_block *ing_acl_block; +struct mlxsw_sp_acl_block *eg_acl_block; }; static inline bool
@@ -498,17 +499,34 @@ struct mlxsw_sp_acl_ops { enum mlxsw_sp_acl_profile profile); }; +struct mlxsw_sp_acl_block ;struct mlxsw_sp_acl_ruleset ;/* spectrum_acl.c */ struct mlxsw_afk *mlxsw_sp_acl_afk (struct mlxsw_sp_acl *acl); +struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp (struct mlxsw_sp_acl_block *block); +unsigned int mlxsw_sp_acl_block_rule_count (struct mlxsw_sp_acl_block *block); +void mlxsw_sp_acl_block_disable_inc (struct mlxsw_sp_acl_block *block); +void mlxsw_sp_acl_block_disable_dec (struct mlxsw_sp_acl_block *block); +bool mlxsw_sp_acl_block_disabled (struct mlxsw_sp_acl_block *block); +struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create (struct mlxsw_sp *mlxsw_sp, +struct net *net); +void mlxsw_sp_acl_block_destroy (struct mlxsw_sp_acl_block *block); +int mlxsw_sp_acl_block_bind (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block, +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress); +int mlxsw_sp_acl_block_unbind (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block, +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress);struct mlxsw_sp_acl_ruleset * -mlxsw_sp_acl_ruleset_lookup (struct mlxsw_sp *mlxsw_sp,struct net_device *dev, -bool ingress,u32 chain_index, +mlxsw_sp_acl_ruleset_lookup (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block,u32 chain_index,enum mlxsw_sp_acl_profile profile);struct mlxsw_sp_acl_ruleset * -mlxsw_sp_acl_ruleset_get (struct mlxsw_sp *mlxsw_sp,struct net_device *dev, -bool ingress,u32 chain_index, +mlxsw_sp_acl_ruleset_get (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block,u32 chain_index,enum mlxsw_sp_acl_profile profile);void mlxsw_sp_acl_ruleset_put (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_ruleset *ruleset);
@@ -575,11 +593,14 @@ void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;/* spectrum_flower.c */ -int mlxsw_sp_flower_replace (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress, +int mlxsw_sp_flower_replace (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block,struct tc_cls_flower_offload *f); -void mlxsw_sp_flower_destroy (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress, +void mlxsw_sp_flower_destroy (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block,struct tc_cls_flower_offload *f); -int mlxsw_sp_flower_stats (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress, +int mlxsw_sp_flower_stats (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_acl_block *block,struct tc_cls_flower_offload *f);/* spectrum_qdisc.c */
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +203 -34
338 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +17 -24
125 lines not on this page · raw message
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH v4 10/10 mlxsw: spectrum_acl: Pass mlxsw_sp_port down to ruleset bind/unbind ops
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
No need to convert from mlxsw_sp_port to net_device and back again.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 6 +++-- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 4 ++-- .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 27 +++++++++------------- 3 files changed, 17 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +4 -2
@@ -477,9 +477,11 @@ struct mlxsw_sp_acl_profile_ops { void *priv, void *ruleset_priv);void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv);int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv, -struct net_device *dev,bool ingress); +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress);void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp,void *ruleset_priv, -struct net_device *dev,bool ingress); +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress);u16 (*ruleset_group_id)(void *ruleset_priv);size_t rule_priv_size; int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +2 -2
@@ -169,7 +169,7 @@ mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;return ops->ruleset_bind (mlxsw_sp, ruleset->priv, - binding->mlxsw_sp_port->dev, binding->ingress); + binding->mlxsw_sp_port, binding->ingress); } static void
@@ -181,7 +181,7 @@ mlxsw_sp_acl_ruleset_unbind(struct mlxsw_sp *mlxsw_sp,const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; ops->ruleset_unbind (mlxsw_sp, ruleset->priv, - binding->mlxsw_sp_port->dev, binding->ingress); + binding->mlxsw_sp_port, binding->ingress); }static bool mlxsw_sp_acl_ruleset_block_bound (struct mlxsw_sp_acl_block *block)
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +11 -16
@@ -258,15 +258,11 @@ static void mlxsw_sp_acl_tcam_group_del(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_acl_tcam_group_bind (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_tcam_group *group, -struct net_device *dev,bool ingress) +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress) { -struct mlxsw_sp_port *mlxsw_sp_port;char ppbt_pl[MLXSW_REG_PPBT_LEN ]; -if (!mlxsw_sp_port_dev_check (dev)) -return -EINVAL ; - - mlxsw_sp_port =netdev_priv (dev); mlxsw_reg_ppbt_pack(ppbt_pl, ingress ? MLXSW_REG_PXBT_E_IACL : MLXSW_REG_PXBT_E_EACL, MLXSW_REG_PXBT_OP_BIND, mlxsw_sp_port->local_port,
@@ -277,15 +273,11 @@ mlxsw_sp_acl_tcam_group_bind(struct mlxsw_sp *mlxsw_sp,static void mlxsw_sp_acl_tcam_group_unbind (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_tcam_group *group, -struct net_device *dev,bool ingress) +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress) { -struct mlxsw_sp_port *mlxsw_sp_port;char ppbt_pl[MLXSW_REG_PPBT_LEN ]; -if (WARN_ON (!mlxsw_sp_port_dev_check (dev))) -return ; - - mlxsw_sp_port =netdev_priv (dev); mlxsw_reg_ppbt_pack(ppbt_pl, ingress ? MLXSW_REG_PXBT_E_IACL : MLXSW_REG_PXBT_E_EACL, MLXSW_REG_PXBT_OP_UNBIND, mlxsw_sp_port->local_port,
@@ -1054,22 +1046,25 @@ mlxsw_sp_acl_tcam_flower_ruleset_del(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_acl_tcam_flower_ruleset_bind (struct mlxsw_sp *mlxsw_sp,void *ruleset_priv, -struct net_device *dev,bool ingress) +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress) {struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset = ruleset_priv;return mlxsw_sp_acl_tcam_group_bind (mlxsw_sp, &ruleset->group, - dev, ingress); + mlxsw_sp_port, ingress); }static void mlxsw_sp_acl_tcam_flower_ruleset_unbind (struct mlxsw_sp *mlxsw_sp,void *ruleset_priv, -struct net_device *dev,bool ingress) +struct mlxsw_sp_port *mlxsw_sp_port, +bool ingress) {struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset = ruleset_priv; -mlxsw_sp_acl_tcam_group_unbind (mlxsw_sp, &ruleset->group, dev, ingress); +mlxsw_sp_acl_tcam_group_unbind (mlxsw_sp, &ruleset->group, + mlxsw_sp_port, ingress); } static u16
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 1/1 tc: implement filter block sharing to ingress and clsact qdiscs
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
--- include/uapi/linux/pkt_sched.h | 11 +++++++++ tc/q_clsact.c | 56 ++++++++++++++++++++++++++++++++++++++---- tc/q_ingress.c | 32 +++++++++++++++++++++--- 3 files changed, 91 insertions(+), 8 deletions(-)
include/uapi/linux/pkt_sched.h +11 -0
@@ -934,4 +934,15 @@ enum {#define TCA_CBS_MAX (__TCA_CBS_MAX - 1) +/* Ingress/clsact */ + +enum { +TCA_CLSACT_UNSPEC , +TCA_CLSACT_INGRESS_BLOCK , +TCA_CLSACT_EGRESS_BLOCK , + __TCA_CLSACT_MAX +}; + +#define TCA_CLSACT_MAX (__TCA_CLSACT_MAX - 1) +#endif
tc/q_clsact.c +51 -5
74 lines not on this page · raw message
tc/q_ingress.c +29 -3
@@ -17,30 +17,56 @@static void explain (void ) { -fprintf (stderr,"Usage: ... ingress\n" ); +fprintf (stderr,"Usage: ... ingress [block BLOCK_INDEX]\n" ); }static int ingress_parse_opt (struct qdisc_util *qu,int argc,char **argv,struct nlmsghdr *n,const char *dev) { +struct rtattr *tail; +unsigned int block; +while (argc >0 ) {if (strcmp (*argv,"handle" ) ==0 ) {NEXT_ARG (); - argc--; argv++; + }else if (strcmp (*argv,"block" ) ==0 ) { +NEXT_ARG (); +if (get_unsigned (&block, *argv,0 )) { +fprintf (stderr,"Illegal \"block\"\n" ); +return -1 ; + } }else {fprintf (stderr,"What is \"%s\"?\n" , *argv);explain ();return -1 ; } +NEXT_ARG_FWD (); } + tail =NLMSG_TAIL (n); +addattr_l (n,1024 ,TCA_OPTIONS ,NULL ,0 ); +if (block) +addattr32 (n,1024 ,TCA_CLSACT_INGRESS_BLOCK , block); + tail->rta_len = (void *)NLMSG_TAIL (n) - (void *) tail;return 0 ; }static int ingress_print_opt (struct qdisc_util *qu,FILE *f,struct rtattr *opt) { -fprintf (f,"---------------- " ); +struct rtattr *tb[TCA_CLSACT_MAX +1 ]; +unsigned int block; + +if (!opt) +return 0 ; + +parse_rtattr_nested (tb,TCA_CLSACT_MAX , opt); + +if (tb[TCA_CLSACT_INGRESS_BLOCK ] && +RTA_PAYLOAD (tb[TCA_CLSACT_INGRESS_BLOCK ]) >=sizeof (__u32)) { + block =rta_getattr_u32 (tb[TCA_CLSACT_INGRESS_BLOCK ]); +print_uint (PRINT_ANY ,"block" ,"block %u " , block); + }return 0 ; }
Signature · 1 line
2.9.5
Quoted 22 lines · Jiri Pirko
So back to the example. First, we create 2 qdiscs. Both will share block number 22. "22" is just an identification. If we don't pass any block number, a new one will be generated by kernel:
$ tc qdisc add dev ens7 ingress block 22 ^^^^^^^^ $ tc qdisc add dev ens8 ingress block 22 ^^^^^^^^Now if we list the qdiscs, we will see the block index in the output:
$ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22To make is more visual, the situation looks like this:
ens7 ingress qdisc ens7 ingress qdisc
| | | | +----------> block 22 <----------+
Quoted 5 lines
Unlimited number of qdiscs may share the same block.
Now we can add filter to any of qdiscs sharing the same block:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop
Allowing config of a shared block through any qdisc that references it is akin to me allowing nexthop objects to be manipulated by any route that references it -- sure, it could be done but causes a lot surprises to the user.
You are adding a new tc object -- a shared block. Why the resistance to creating a proper API for managing it?
Jiri Pirko
maintainerQuoted 30 lines · Sun, Dec 24, 2017 at 02:54:47AM CET, [email protected] wrote:
Quoted 22 lines · Jiri Pirko
So back to the example. First, we create 2 qdiscs. Both will share block number 22. "22" is just an identification. If we don't pass any block number, a new one will be generated by kernel:
$ tc qdisc add dev ens7 ingress block 22 ^^^^^^^^ $ tc qdisc add dev ens8 ingress block 22 ^^^^^^^^Now if we list the qdiscs, we will see the block index in the output:
$ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22To make is more visual, the situation looks like this:
ens7 ingress qdisc ens7 ingress qdisc
| | | | +----------> block 22 <----------+Quoted 5 lines
Unlimited number of qdiscs may share the same block.
Now we can add filter to any of qdiscs sharing the same block:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop
Quoted 7 lines
Allowing config of a shared block through any qdisc that references it is akin to me allowing nexthop objects to be manipulated by any route that references it -- sure, it could be done but causes a lot surprises to the user.
You are adding a new tc object -- a shared block. Why the resistance to creating a proper API for managing it?
Again, no resistance, I said many times it would be done as a follow-up. But as an api already exists, it has to continue to work. Or do you suggest it should stop working? That, I don't agree with.
Quoted 36 lines · Jiri Pirko
Quoted 35 lines · Sun, Dec 24, 2017 at 02:54:47AM CET, [email protected] wrote:
Quoted 22 lines · Jiri Pirko
So back to the example. First, we create 2 qdiscs. Both will share block number 22. "22" is just an identification. If we don't pass any block number, a new one will be generated by kernel:
$ tc qdisc add dev ens7 ingress block 22 ^^^^^^^^ $ tc qdisc add dev ens8 ingress block 22 ^^^^^^^^Now if we list the qdiscs, we will see the block index in the output:
$ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22To make is more visual, the situation looks like this:
ens7 ingress qdisc ens7 ingress qdisc
| | | | +----------> block 22 <----------+Quoted 5 lines
Unlimited number of qdiscs may share the same block.
Now we can add filter to any of qdiscs sharing the same block:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropAllowing config of a shared block through any qdisc that references it is akin to me allowing nexthop objects to be manipulated by any route that references it -- sure, it could be done but causes a lot surprises to the user.
Quoted 7 lines
Quoted 2 lines
You are adding a new tc object -- a shared block. Why the resistance to creating a proper API for managing it?
Again, no resistance, I said many times it would be done as a follow-up. But as an api already exists, it has to continue to work. Or do you suggest it should stop working? That, I don't agree with.
That is exactly what I am saying - principle of least surprise. The new object brings its own API and can only be modified using the new API. The scheme above can and will surprise users. You are thinking like a tc developer, someone intimately familiar with the code, and not like an ordinary user of this new feature.
Jiri Pirko
maintainerQuoted 45 lines · Sun, Dec 24, 2017 at 05:25:41PM CET, [email protected] wrote:
Quoted 36 lines · Jiri Pirko
Quoted 35 lines · Sun, Dec 24, 2017 at 02:54:47AM CET, [email protected] wrote:
Quoted 22 lines · Jiri Pirko
So back to the example. First, we create 2 qdiscs. Both will share block number 22. "22" is just an identification. If we don't pass any block number, a new one will be generated by kernel:
$ tc qdisc add dev ens7 ingress block 22 ^^^^^^^^ $ tc qdisc add dev ens8 ingress block 22 ^^^^^^^^Now if we list the qdiscs, we will see the block index in the output:
$ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22To make is more visual, the situation looks like this:
ens7 ingress qdisc ens7 ingress qdisc
| | | | +----------> block 22 <----------+Quoted 5 lines
Unlimited number of qdiscs may share the same block.
Now we can add filter to any of qdiscs sharing the same block:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropAllowing config of a shared block through any qdisc that references it is akin to me allowing nexthop objects to be manipulated by any route that references it -- sure, it could be done but causes a lot surprises to the user.
Quoted 7 lines
Quoted 2 lines
You are adding a new tc object -- a shared block. Why the resistance to creating a proper API for managing it?
Again, no resistance, I said many times it would be done as a follow-up. But as an api already exists, it has to continue to work. Or do you suggest it should stop working? That, I don't agree with.
Quoted 5 lines
That is exactly what I am saying - principle of least surprise. The new object brings its own API and can only be modified using the new API. The scheme above can and will surprise users. You are thinking like a tc developer, someone intimately familiar with the code, and not like an ordinary user of this new feature.
Breaking exising tools is newer good. Note that not only about filter add/del iface but also dump and notifications. I agree to extend the api for the "block handle", sure, but the existing api should continue to work.
Jiri Pirko
maintainerQuoted 52 lines · Mon, Dec 25, 2017 at 11:23:46AM CET, [email protected] wrote:
Quoted 45 lines · Sun, Dec 24, 2017 at 05:25:41PM CET, [email protected] wrote:
Quoted 36 lines · Jiri Pirko
Quoted 35 lines · Sun, Dec 24, 2017 at 02:54:47AM CET, [email protected] wrote:
Quoted 22 lines · Jiri Pirko
So back to the example. First, we create 2 qdiscs. Both will share block number 22. "22" is just an identification. If we don't pass any block number, a new one will be generated by kernel:
$ tc qdisc add dev ens7 ingress block 22 ^^^^^^^^ $ tc qdisc add dev ens8 ingress block 22 ^^^^^^^^Now if we list the qdiscs, we will see the block index in the output:
$ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22To make is more visual, the situation looks like this:
ens7 ingress qdisc ens7 ingress qdisc
| | | | +----------> block 22 <----------+Quoted 5 lines
Unlimited number of qdiscs may share the same block.
Now we can add filter to any of qdiscs sharing the same block:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropAllowing config of a shared block through any qdisc that references it is akin to me allowing nexthop objects to be manipulated by any route that references it -- sure, it could be done but causes a lot surprises to the user.
Quoted 7 lines
Quoted 2 lines
You are adding a new tc object -- a shared block. Why the resistance to creating a proper API for managing it?
Again, no resistance, I said many times it would be done as a follow-up. But as an api already exists, it has to continue to work. Or do you suggest it should stop working? That, I don't agree with.
Quoted 5 lines
That is exactly what I am saying - principle of least surprise. The new object brings its own API and can only be modified using the new API. The scheme above can and will surprise users. You are thinking like a tc developer, someone intimately familiar with the code, and not like an ordinary user of this new feature.
Quoted 4 lines
Breaking exising tools is newer good. Note that not only about filter add/del iface but also dump and notifications. I agree to extend the api for the "block handle", sure, but the existing api should continue to work.
DaveA, please consider following example:
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1
Now I have one device with one qdisc attached.
I will add some filters, for example:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop
No sharing is happening. The user is doing what he is used to do.
Now user decides to share this filters with another device. As you can see above, the block created for ens7 qdisc instance has id "1". User can simply do:
tc qdisc add dev ens8 ingress block 1
And the block gets shared among ens7 ingress qdisc instance and ens8 ingress qdisc instance.
What is wrong with this? The approach you suggest would disallow this forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
Thanks!
Quoted 17 lines · Jiri Pirko
DaveA, please consider following example:
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1Now I have one device with one qdisc attached.
I will add some filters, for example:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropNo sharing is happening. The user is doing what he is used to do.
Now user decides to share this filters with another device. As you can see above, the block created for ens7 qdisc instance has id "1". User can simply do:
Quoted 6 lines
tc qdisc add dev ens8 ingress block 1
And the block gets shared among ens7 ingress qdisc instance and ens8 ingress qdisc instance.
What is wrong with this? The approach you suggest would disallow this
Conceptually, absolutely nothing. We all agree that a shared block feature is needed. So no argument on sharing the filters across devices.
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop
Then traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
Consider the commands being run by different people, and a time span between. Allowing the shared block to be configured by any device using the block is just setting up users for errors and confusion.
Quoted 3 lines
forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
It forces the user to acknowledge it is changing a resource that may be shared by more than one device.
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.
$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1
$ tc filter add block 1 protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop
Now there are no surprises. I have to know that ens8 is using block 1, and I have to specify that block when adding a filter.
BTW, is there an option to list all devices using the same shared block
- short of listing all and grepping?
Jiri Pirko
maintainerQuoted 34 lines · Wed, Jan 03, 2018 at 03:07:36AM CET, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
DaveA, please consider following example:
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1Now I have one device with one qdisc attached.
I will add some filters, for example:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropNo sharing is happening. The user is doing what he is used to do.
Now user decides to share this filters with another device. As you can see above, the block created for ens7 qdisc instance has id "1". User can simply do:
Quoted 6 lines
tc qdisc add dev ens8 ingress block 1
And the block gets shared among ens7 ingress qdisc instance and ens8 ingress qdisc instance.
What is wrong with this? The approach you suggest would disallow this
Conceptually, absolutely nothing. We all agree that a shared block feature is needed. So no argument on sharing the filters across devices.
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
Quoted 7 lines
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropThen traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
Given the fact that user configured sharing between ens7 and ens8 and he can easily see that by "$ tc qdisc show" I don't see anything wrong about it, no surprise. Either the user knows what is he doing or not.
Quoted 4 lines
Consider the commands being run by different people, and a time span between. Allowing the shared block to be configured by any device using the block is just setting up users for errors and confusion.
No confusion. Everything is visible, all info is in the manpage. The same story as always.
Quoted 12 lines
Quoted 4 lines
forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
It forces the user to acknowledge it is changing a resource that may be shared by more than one device.
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.
Quoted 8 lines
$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1$ tc filter add block 1 protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropNow there are no surprises. I have to know that ens8 is using block 1, and I have to specify that block when adding a filter.
On contrary. This is surprising! Consider my original example extended by your approach and limitations:
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1 $ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop
So far, everything is good. Now I add qdisc with block 1 to ens8:
$ tc qdisc add dev ens8 ingress block 1
And I do:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop Should it Error out or pass by your limitations?
Assume it should pass.
I do:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.
This will error out as you wrote. Now I do show:
$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1
As you wrote, there is "ens7" in output of ens8 qdisc. That is surprising.
What would following commands show with your limitations:
$ tc filter show dev ens7 ingress $ tc filter show dev ens8 ingress
All filters should be listed under ens7 and ens8 should be blank? I cannot add filters to ens8 with your limitations so I guess the show for it should be blank. But there are actually rules there! That is another surprise and breakage!
Now I continue and remove the qdisc from ens7:
$ tc qdisc add dev ens7 ingress
The block 1 is still there for ens8. So what happens now? What is the output of "filter show dev ens8 ingress" and "qdisc show dev ens8"? Will "add dev ens8 ingress" magically start to work now? This is another set of surprises and breakages.
So as I see it with your limitations, there is a lot of surprises introduced.
Note that I gave a lot of thoughts to all this. The approach I suggest is the cleanest and does not break anything. Also, it is easily extendable by adding the block handle to add/del/list the filters. But the current commands should not be broken. Please.
If you want, I can implement the block handle extension as a part of this patchset. I wanted to do it as a follow-up to limit the number of patches in the set so DaveM would not have reason to hate me :)
Quoted 4 lines
BTW, is there an option to list all devices using the same shared block
- short of listing all and grepping?
$ tc qdisc show
Quoted 38 lines · Jiri Pirko
Quoted 37 lines · Wed, Jan 03, 2018 at 03:07:36AM CET, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
DaveA, please consider following example:
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1Now I have one device with one qdisc attached.
I will add some filters, for example:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropNo sharing is happening. The user is doing what he is used to do.
Now user decides to share this filters with another device. As you can see above, the block created for ens7 qdisc instance has id "1". User can simply do:
Quoted 6 lines
tc qdisc add dev ens8 ingress block 1
And the block gets shared among ens7 ingress qdisc instance and ens8 ingress qdisc instance.
What is wrong with this? The approach you suggest would disallow this
Conceptually, absolutely nothing. We all agree that a shared block feature is needed. So no argument on sharing the filters across devices.
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop
Quoted 8 lines
Quoted 4 lines
Then traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
Given the fact that user configured sharing between ens7 and ens8 and he can easily see that by "$ tc qdisc show" I don't see anything wrong about it, no surprise. Either the user knows what is he doing or not.
tc is one of the most difficult commands for users to understand and get right. The API behind the command even more so. There seems to be a general agreement on this.
To someone like you who is well versed in tc semantics this may seem obvious, but I contend that even you would slip up here at some point. There is too much distance between the filter management and the qdisc listing a part of which shows a block id - not that it is shared or anything else, just of the many words in the output there is 'block N'.
Quoted 24 lines
Quoted 4 lines
Consider the commands being run by different people, and a time span between. Allowing the shared block to be configured by any device using the block is just setting up users for errors and confusion.
No confusion. Everything is visible, all info is in the manpage. The same story as always.
Quoted 15 lines
Quoted 4 lines
forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
It forces the user to acknowledge it is changing a resource that may be shared by more than one device.
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1
Quoted 8 lines
Quoted 5 lines
$ tc filter add block 1 protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropNow there are no surprises. I have to know that ens8 is using block 1, and I have to specify that block when adding a filter.
On contrary. This is surprising! Consider my original example extended by your approach and limitations:
Nope, I was not extending your approach; I was using your examples to show why I disagree with the approach. As I mentioned in past responses, I believe the block lifecycle should be independent of any device.
$ tc qdisc add block 1 $ tc filter add block 1 ....
$ tc qdisc add dev ens7 ingress block 1 $ tc qdisc add dev ens8 ingress block 1
$ tc filter show block 1 (filters listed)
$ tc filter show dev ens7 ingress Info: This qdisc is shared. Use the block api to list filters.
(This is very similar to how I am handling nexthop objects for routes. I can show some examples if desired, but don't want this tangent to go too far.)
Quoted 18 lines
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1 $ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropSo far, everything is good. Now I add qdisc with block 1 to ens8:
$ tc qdisc add dev ens8 ingress block 1And I do:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop Should it Error out or pass by your limitations?Assume it should pass.
I do:$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.
Quoted 7 lines
This will error out as you wrote. Now I do show:
$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1As you wrote, there is "ens7" in output of ens8 qdisc. That is surprising.
that's a typo on my part with copy-paste-modify of commands while writing an email; that was not intentional to show ens7 on an ens8 device.
Quoted 4 lines
What would following commands show with your limitations:
$ tc filter show dev ens7 ingress $ tc filter show dev ens8 ingress
see above
Quoted 35 lines
All filters should be listed under ens7 and ens8 should be blank? I cannot add filters to ens8 with your limitations so I guess the show for it should be blank. But there are actually rules there! That is another surprise and breakage!
Now I continue and remove the qdisc from ens7:
$ tc qdisc add dev ens7 ingressThe block 1 is still there for ens8. So what happens now? What is the output of "filter show dev ens8 ingress" and "qdisc show dev ens8"? Will "add dev ens8 ingress" magically start to work now? This is another set of surprises and breakages.
So as I see it with your limitations, there is a lot of surprises introduced.
Note that I gave a lot of thoughts to all this. The approach I suggest is the cleanest and does not break anything. Also, it is easily extendable by adding the block handle to add/del/list the filters. But the current commands should not be broken. Please.
If you want, I can implement the block handle extension as a part of this patchset. I wanted to do it as a follow-up to limit the number of patches in the set so DaveM would not have reason to hate me :)
Quoted 4 lines
BTW, is there an option to list all devices using the same shared block
- short of listing all and grepping?$ tc qdisc show
Jiri Pirko
maintainerQuoted 88 lines · Wed, Jan 03, 2018 at 04:57:23PM CET, [email protected] wrote:
Quoted 38 lines · Jiri Pirko
Quoted 37 lines · Wed, Jan 03, 2018 at 03:07:36AM CET, [email protected] wrote:
Quoted 17 lines · Jiri Pirko
DaveA, please consider following example:
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1Now I have one device with one qdisc attached.
I will add some filters, for example:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropNo sharing is happening. The user is doing what he is used to do.
Now user decides to share this filters with another device. As you can see above, the block created for ens7 qdisc instance has id "1". User can simply do:
Quoted 6 lines
tc qdisc add dev ens8 ingress block 1
And the block gets shared among ens7 ingress qdisc instance and ens8 ingress qdisc instance.
What is wrong with this? The approach you suggest would disallow this
Conceptually, absolutely nothing. We all agree that a shared block feature is needed. So no argument on sharing the filters across devices.
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropQuoted 8 lines
Quoted 4 lines
Then traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
Given the fact that user configured sharing between ens7 and ens8 and he can easily see that by "$ tc qdisc show" I don't see anything wrong about it, no surprise. Either the user knows what is he doing or not.
tc is one of the most difficult commands for users to understand and get right. The API behind the command even more so. There seems to be a general agreement on this.
To someone like you who is well versed in tc semantics this may seem obvious, but I contend that even you would slip up here at some point. There is too much distance between the filter management and the qdisc listing a part of which shows a block id - not that it is shared or anything else, just of the many words in the output there is 'block N'.
Quoted 30 lines
Quoted 4 lines
Consider the commands being run by different people, and a time span between. Allowing the shared block to be configured by any device using the block is just setting up users for errors and confusion.
No confusion. Everything is visible, all info is in the manpage. The same story as always.
Quoted 20 lines
Quoted 4 lines
forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
It forces the user to acknowledge it is changing a resource that may be shared by more than one device.
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1$ tc filter add block 1 protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropNow there are no surprises. I have to know that ens8 is using block 1, and I have to specify that block when adding a filter.
Quoted 8 lines
Quoted 2 lines
On contrary. This is surprising! Consider my original example extended by your approach and limitations:
Nope, I was not extending your approach; I was using your examples to show why I disagree with the approach. As I mentioned in past responses, I believe the block lifecycle should be independent of any device.
$ tc qdisc add block 1
qdisc add block seems odd as in this point, block 1 has nothing to do with any qdisc
Quoted 4 lines
$ tc filter add block 1 ....$ tc qdisc add dev ens7 ingress block 1 $ tc qdisc add dev ens8 ingress block 1
So when I do just:
tc qdisc add dev ens7 ingress
there won't be a block id created. I would like to be able to have it done on one device and share on the second when I please to. With your limitation, I have remove all, add block, add all back again.
Quoted 5 lines
$ tc filter show block 1 (filters listed)$ tc filter show dev ens7 ingress
So the command will return 0 as everything is ok. List is empty, yet there are still filters being processed on this qdisc. That is surprise from where I stand. I as a user would expect a list of all filters being used here. This what you propose is clearly a breakage.
I think that both of us have different expectations about how this should work. I said already that "tc filter add block 1 ...." and "tc filter show block 1" from your approach is fine with me. I even think that the explicit creation and destruction of block ("tc qdisc add block 1" and "tc qdisc del block 1") is fine.
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
Now, I suggest I will implement the block api extensions you suggest without the limitations and send it as a part of this patchset. Would you be ok with that?
Thanks!
Quoted 26 lines
Info: This qdisc is shared. Use the block api to list filters.
(This is very similar to how I am handling nexthop objects for routes. I can show some examples if desired, but don't want this tangent to go too far.)
Quoted 20 lines
$ tc qdisc add dev ens7 ingress $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1 $ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action dropSo far, everything is good. Now I add qdisc with block 1 to ens8:
$ tc qdisc add dev ens8 ingress block 1And I do:
$ tc filter add dev ens7 ingress protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop Should it Error out or pass by your limitations?Assume it should pass.
I do:$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.This will error out as you wrote. Now I do show:
Quoted 8 lines
Quoted 5 lines
$ tc qdisc show dev ens8 qdisc ingress ffff: dev ens7 parent ffff:fff1 block 1As you wrote, there is "ens7" in output of ens8 qdisc. That is surprising.
that's a typo on my part with copy-paste-modify of commands while writing an email; that was not intentional to show ens7 on an ens8 device.
ok.
Quoted 45 lines
Quoted 6 lines
What would following commands show with your limitations:
$ tc filter show dev ens7 ingress $ tc filter show dev ens8 ingresssee above
Quoted 35 lines
All filters should be listed under ens7 and ens8 should be blank? I cannot add filters to ens8 with your limitations so I guess the show for it should be blank. But there are actually rules there! That is another surprise and breakage!
Now I continue and remove the qdisc from ens7:
$ tc qdisc add dev ens7 ingressThe block 1 is still there for ens8. So what happens now? What is the output of "filter show dev ens8 ingress" and "qdisc show dev ens8"? Will "add dev ens8 ingress" magically start to work now? This is another set of surprises and breakages.
So as I see it with your limitations, there is a lot of surprises introduced.
Note that I gave a lot of thoughts to all this. The approach I suggest is the cleanest and does not break anything. Also, it is easily extendable by adding the block handle to add/del/list the filters. But the current commands should not be broken. Please.
If you want, I can implement the block handle extension as a part of this patchset. I wanted to do it as a follow-up to limit the number of patches in the set so DaveM would not have reason to hate me :)
Quoted 4 lines
BTW, is there an option to list all devices using the same shared block
- short of listing all and grepping?$ tc qdisc show
Quoted 3 lines · Jiri Pirko
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
FWIW I would agree with David that allowing add on a shared block modify filters on another interface can break existing users. (No opinion on dump and lifetime).
Jiri Pirko
maintainerQuoted 8 lines · Thu, Jan 04, 2018 at 12:51:52AM CET, [email protected] wrote:
Quoted 3 lines · Jiri Pirko
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
FWIW I would agree with David that allowing add on a shared block modify filters on another interface can break existing users. (No opinion on dump and lifetime).
I don't think that David is saying that, but why do you think it would break existing users?
Quoted 6 lines · Jiri Pirko
Quoted 5 lines · Thu, Jan 04, 2018 at 12:51:52AM CET, [email protected] wrote:
Quoted 3 lines · Jiri Pirko
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
Quoted 6 lines
Quoted 3 lines
FWIW I would agree with David that allowing add on a shared block modify filters on another interface can break existing users. (No opinion on dump and lifetime).
I don't think that David is saying that, but why do you think it would break existing users?
Perhaps I worded is too strongly as "breaking existing users", but it certainly introduces surprising side effects. David put it into words very well:
Quoted 28 lines · David Ahern
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropThen traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
Consider the commands being run by different people, and a time span between. Allowing the shared block to be configured by any device using the block is just setting up users for errors and confusion.
Quoted 3 lines
forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
It forces the user to acknowledge it is changing a resource that may be shared by more than one device.
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.
Jiri Pirko
maintainerQuoted 11 lines · Thu, Jan 04, 2018 at 08:06:58AM CET, [email protected] wrote:
Quoted 10 lines · Jiri Pirko
Quoted 8 lines · Thu, Jan 04, 2018 at 12:51:52AM CET, [email protected] wrote:
Quoted 3 lines · Jiri Pirko
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
FWIW I would agree with David that allowing add on a shared block modify filters on another interface can break existing users. (No opinion on dump and lifetime).
Quoted 21 lines
Quoted 2 lines
I don't think that David is saying that, but why do you think it would break existing users?
Perhaps I worded is too strongly as "breaking existing users", but it certainly introduces surprising side effects. David put it into words very well:
Quoted 13 lines · David Ahern
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropThen traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
It is not that the new filter magically appears on ens7. No magic. ens8 and ens7 share the same block. User set the sharing up originally, he can see it in "tc qdisc show". So if he does this, he cannot be surprised. Also, he can list the filters if he does "tc filter show" to see what is there per-qdisc.
If the user expects something else, he should go back and read the docs and learn to understand how tc works.
Quoted 15 lines
Quoted 15 lines
Consider the commands being run by different people, and a time span between. Allowing the shared block to be configured by any device using the block is just setting up users for errors and confusion.
Quoted 3 lines
forcing user to explicitly create some block entity and then to attach it to qdisc instances. I don't really see good reason for it. Could you please clear this up for me?
It forces the user to acknowledge it is changing a resource that may be shared by more than one device.
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action drop Error: This qdisc is a shared block. Use the block API to configure.
Jamal Hadi Salim
maintainerMy comments below - I do have a more _basic_ issue on the egress side that IMO noone has brought up that needs to be addressed. All examples so far have been focusing on ingress.
Since I am late in this discussion, let me state my understanding of the thread and assumptions so there is no cross-talk.
we are going to need to be able to say:
tc qdisc add block 1
tc filter add block 1 protocol ip priority 10 flower ...
From my scanning of the thread, I dont think I see disagreement. Jiri, did i misread what you are saying?
New approach syntax should still be legit for backward compat, so this should work:
"tc filter add dev ens7 parent ffff: protocol ip priority 10 flower .."
Blocks or not we still need to have old scripts work. Which also means one should also be able to say:
"tc filter ls dev ens7 ..." with no suprises.
From my reading of the thread - there is no disagreement that "tc qdisc add dev ens7 ingress block 1"
should be able to "bind" to block1 if it exists
or create it if it doesnt and then "bind" to it ("autobind").
And that a simple "tc qdisc add dev ens7 ingress" should either not be able to create a block (or we can say creates block id 0 - owned by the netdev - for consistency).
To David A: If someone created the qdisc using new approach and then later tried to add/list rules using the old syntax, surely that should work, no? I have seen setups which separate creation of qdiscs using one script and addition of filters via another script (very common actually).
Having said that:
I see the value of less is more and being able to use one(block) interface to add/del/list filters if we add the blocks feature; but backward compat(meaning crazy scripting) needs to be respected. I dont see how we get away from that.
Maybe what we need is another knob to control this new functionality? Either a kernel config option or an extra parameter when creating the qdisc or a system wide boolean per netdev (which of course contradicts the "less is more" principle). If this knob was set then you reject addition of filters via a port/qdisc which is sharing.
I agree with Jiri - if you consciously choose to share there should be no suprises with what filters get applied.
I think this email is too long and my egress concern will be lost if i typed it here; so i will send another email.
cheers,
jamal
Quoted 43 lines · Jiri Pirko
Quoted 11 lines · Thu, Jan 04, 2018 at 08:06:58AM CET, [email protected] wrote:
Quoted 10 lines · Jiri Pirko
Quoted 8 lines · Thu, Jan 04, 2018 at 12:51:52AM CET, [email protected] wrote:
Quoted 3 lines · Jiri Pirko
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
FWIW I would agree with David that allowing add on a shared block modify filters on another interface can break existing users. (No opinion on dump and lifetime).
Quoted 21 lines
Quoted 2 lines
I don't think that David is saying that, but why do you think it would break existing users?
Perhaps I worded is too strongly as "breaking existing users", but it certainly introduces surprising side effects. David put it into words very well:
Quoted 13 lines · David Ahern
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropThen traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
It is not that the new filter magically appears on ens7. No magic. ens8 and ens7 share the same block. User set the sharing up originally, he can see it in "tc qdisc show". So if he does this, he cannot be surprised. Also, he can list the filters if he does "tc filter show" to see what is there per-qdisc.
If the user expects something else, he should go back and read the docs and learn to understand how tc works.
Jiri Pirko
maintainerQuoted 5 lines · Thu, Jan 04, 2018 at 01:41:54PM CET, [email protected] wrote:
My comments below - I do have a more _basic_ issue on the egress side that IMO noone has brought up that needs to be addressed. All examples so far have been focusing on ingress.
Which one? I guess you will send it as a separate email.
Quoted 10 lines
Since I am late in this discussion, let me state my understanding of the thread and assumptions so there is no cross-talk.
we are going to need to be able to say:
tc qdisc add block 1
tc filter add block 1 protocol ip priority 10 flower ...From my scanning of the thread, I dont think I see disagreement. Jiri, did i misread what you are saying?
Agreed. The plan is to do this in the follow-up, but if you guys need it now, I can do that now.
Quoted 5 lines
New approach syntax should still be legit for backward compat, so this should work:
"tc filter add dev ens7 parent ffff: protocol ip priority 10 flower .."
Agreed. Works like that with the current patchset.
Quoted 4 lines
Blocks or not we still need to have old scripts work. Which also means one should also be able to say:
"tc filter ls dev ens7 ..." with no suprises.
Agreed. Works like that with the current patchset.
Quoted 5 lines
From my reading of the thread - there is no disagreement that "tc qdisc add dev ens7 ingress block 1"
should be able to "bind" to block1 if it exists
or create it if it doesnt and then "bind" to it ("autobind").
Agreed. Works exactly as you described in the current patchset.
Quoted 4 lines
And that a simple "tc qdisc add dev ens7 ingress" should either not be able to create a block (or we can say creates block id 0 - owned by the netdev - for consistency).
This allocates a new block - as it needs it internally anyway - and tc core will assign unused block id. You can see this id in the list then. Later you can use this block id for other created qdiscs.
Block ids are per-ns.
Quoted 6 lines
To David A: If someone created the qdisc using new approach and then later tried to add/list rules using the old syntax, surely that should work, no? I have seen setups which separate creation of qdiscs using one script and addition of filters via another script (very common actually).
Agreed, that is exactly what I want from day 1.
Quoted 7 lines
Having said that:
I see the value of less is more and being able to use one(block) interface to add/del/list filters if we add the blocks feature; but backward compat(meaning crazy scripting) needs to be respected. I dont see how we get away from that.
Quoted 5 lines
Maybe what we need is another knob to control this new functionality? Either a kernel config option or an extra parameter when creating the qdisc or a system wide boolean per netdev (which of course contradicts the "less is more" principle). If this knob was set then you reject addition of filters via a port/qdisc which is sharing.
I don't like this knob idea. It just adds confusion for no good reason what so ever.
Quoted 58 lines
I agree with Jiri - if you consciously choose to share there should be no suprises with what filters get applied.
I think this email is too long and my egress concern will be lost if i typed it here; so i will send another email.
cheers,
jamalQuoted 43 lines · Jiri Pirko
Quoted 11 lines · Thu, Jan 04, 2018 at 08:06:58AM CET, [email protected] wrote:
Quoted 10 lines · Jiri Pirko
Quoted 8 lines · Thu, Jan 04, 2018 at 12:51:52AM CET, [email protected] wrote:
Quoted 3 lines · Jiri Pirko
However I don't agree about breaking the existing filter add and show and also imposibility to make not-shared block shared in the runtime before defining it first.
FWIW I would agree with David that allowing add on a shared block modify filters on another interface can break existing users. (No opinion on dump and lifetime).
Quoted 21 lines
Quoted 2 lines
I don't think that David is saying that, but why do you think it would break existing users?
Perhaps I worded is too strongly as "breaking existing users", but it certainly introduces surprising side effects. David put it into words very well:
Quoted 13 lines · David Ahern
The disagreement is in how they should be managed. I think my last response concisely captures my concerns -- the principle of least surprise.
So with the initial commands above, all is fine. Then someone is debugging a problem or wants to add another filter to ens8, so they run:
$ tc filter add dev ens8 ingress protocol ip pref 25 flower dst_ip 192.168.1.0/16 action dropThen traffic flows through ens7 break and some other user is struggling to understand what just happened. That the new filter magically appears on ens7 when the user operated on ens8 is a surprise. Nothing about that last command acknowledges that it is changing a shared resource.
It is not that the new filter magically appears on ens7. No magic. ens8 and ens7 share the same block. User set the sharing up originally, he can see it in "tc qdisc show". So if he does this, he cannot be surprised. Also, he can list the filters if he does "tc filter show" to see what is there per-qdisc.
If the user expects something else, he should go back and read the docs and learn to understand how tc works.
Jamal Hadi Salim
maintainerQuoted 8 lines · Jiri Pirko
Quoted 4 lines · Thu, Jan 04, 2018 at 01:41:54PM CET, [email protected] wrote:
And that a simple "tc qdisc add dev ens7 ingress" should either not be able to create a block (or we can say creates block id 0 - owned by the netdev - for consistency).
Quoted 6 lines
This allocates a new block - as it needs it internally anyway - and tc core will assign unused block id. You can see this id in the list then. Later you can use this block id for other created qdiscs.
Block ids are per-ns.
Hrm. I was thinking more that there is a block that cannot be shared and is only owned by the netdev i.e current behavior. But what you describe should work
(and let the user decide if they want to share).
Quoted 9 lines
Quoted 6 lines
Maybe what we need is another knob to control this new functionality? Either a kernel config option or an extra parameter when creating the qdisc or a system wide boolean per netdev (which of course contradicts the "less is more" principle). If this knob was set then you reject addition of filters via a port/qdisc which is sharing.
I don't like this knob idea. It just adds confusion for no good reason what so ever.
I dont like it either but i see it as a knob to choose between improved usability/manageability (which new interface provides) vs least suprise - which is to keep the old syntax around. If i was an admin and turned on this knob - I am prepared to deal with fallout of some user script which tries to add filters via the device instead of the block.
cheers,
jamal
Jiri Pirko
maintainerQuoted 13 lines · Thu, Jan 04, 2018 at 02:30:54PM CET, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 4 lines · Thu, Jan 04, 2018 at 01:41:54PM CET, [email protected] wrote:
And that a simple "tc qdisc add dev ens7 ingress" should either not be able to create a block (or we can say creates block id 0 - owned by the netdev - for consistency).
This allocates a new block - as it needs it internally anyway - and tc core will assign unused block id. You can see this id in the list then. Later you can use this block id for other created qdiscs.
Quoted 7 lines
Quoted 2 lines
Block ids are per-ns.
Hrm. I was thinking more that there is a block that cannot be shared and is only owned by the netdev i.e current behavior. But what you describe should work
(and let the user decide if they want to share).
Yeah. This is how it is implemented right now. Works fine. And provides user possibility to set the share with other qdisc while the filters are already there. It is actually quite nice.
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Maybe what we need is another knob to control this new functionality? Either a kernel config option or an extra parameter when creating the qdisc or a system wide boolean per netdev (which of course contradicts the "less is more" principle). If this knob was set then you reject addition of filters via a port/qdisc which is sharing.
I don't like this knob idea. It just adds confusion for no good reason what so ever.
Quoted 6 lines
I dont like it either but i see it as a knob to choose between improved usability/manageability (which new interface provides) vs least suprise - which is to keep the old syntax around. If i was an admin and turned on this knob - I am prepared to deal with fallout of some user script which tries to add filters via the device instead of the block.
This smells awfully like "break_my_system" knob described by DaveM during our route offloading discussions :)
I would just go without this knob for now in a way I suggested earlier in my reply to DavidA. I would leave the functionality there as it is in the current patchset, leaving all original interfaces to work and on top of that, I will add "filter add block" and "filter list block" handles. Sounds fine?
Quoted 3 lines
cheers,
jamal
David Miller
maintainerFrom: Jamal Hadi Salim <[email protected]>
Date: Thu, 4 Jan 2018 07:41:54 -0500
Quoted 2 lines
I agree with Jiri - if you consciously choose to share there should be no suprises with what filters get applied.
Wrong. It is not always the case that the two entities making changes are coordinated explicitly.
Block operations shared across devices must therefore be _explicit_.
Any other behavior will result in surprised and unintended consequences.
Jamal Hadi Salim
maintainerOn the egress issue and sharing.
Let me provide a simple example to illustrate.
tc qdisc add dev enps7 root handle 1: prio block 1
Creates 3 classes
$ tc class ls dev enps7 class prio 1:1 parent 1: class prio 1:2 parent 1: class prio 1:3 parent 1:
tc qdisc add dev enps8 root handle 10: prio block 1
Creates 3 classes
$ tc class ls dev enps8 class prio 10:1 parent 10: class prio 10:2 parent 10: class prio 10:3 parent 10:
So now i add filters, today I can do:
tc filter add dev enps7 parent 1:0 protocol ip priority 10 flower ... classid 1:2
I could also have added this via the new block interface i.e
$ tc filter add block 1 protocol ip priority 10 flower ... classid 1:2
Looks good - things will work fine for packets showing up on egress of enps7 which match the flower rule and classid 1:2 is selected to queue the packet on.
Things will not _work fine_ for packets showing up on egress of ensp8. There is no classid 1:2 on egress of enps8. The prio qdisc is a bad example because it has a default queue (i think 10:2) in this case. Other qdiscs(off top of my head DRR) will just drop the packet.
I think this is resolvable - but it will take more to the patches than the current set you posted Jiri.
A simple solution is to say sharing only works for ingress (but that sounds very lame).
cheers,
jamal
Jiri Pirko
maintainerQuoted 37 lines · Thu, Jan 04, 2018 at 01:55:05PM CET, [email protected] wrote:
On the egress issue and sharing.
Let me provide a simple example to illustrate.
tc qdisc add dev enps7 root handle 1: prio block 1
Creates 3 classes
$ tc class ls dev enps7 class prio 1:1 parent 1: class prio 1:2 parent 1: class prio 1:3 parent 1:tc qdisc add dev enps8 root handle 10: prio block 1
Creates 3 classes
$ tc class ls dev enps8 class prio 10:1 parent 10: class prio 10:2 parent 10: class prio 10:3 parent 10:So now i add filters, today I can do:
tc filter add dev enps7 parent 1:0 protocol ip priority 10 flower ... classid 1:2
I could also have added this via the new block interface i.e
$ tc filter add block 1 protocol ip priority 10 flower ... classid 1:2Looks good - things will work fine for packets showing up on egress of enps7 which match the flower rule and classid 1:2 is selected to queue the packet on.
Quoted 5 lines
Things will not
_workfine_for packets showing up on egress of ensp8. There is no classid 1:2 on egress of enps8. The prio qdisc is a bad example because it has a default queue (i think 10:2) in this case. Other qdiscs(off top of my head DRR) will just drop the packet.
I'm very well aware of this. The plan is to support this and resolve the lack of classid withing the qdisc according to the qdisc type. However, currently the classfull qdiscs are not supported for block sharing - only ingress and clsact qdiscs are supported.
Quoted 5 lines
I think this is resolvable - but it will take more to the patches than the current set you posted Jiri.
A simple solution is to say sharing only works for ingress (but that sounds very lame).
That is the current limitation of the patchset as you can see. The sharing works only for ingress and clsact qdisc. So works for both ingress and egress (clsact).
Quoted 3 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 10 lines · Jiri Pirko
Quoted 8 lines · Thu, Jan 04, 2018 at 01:55:05PM CET, [email protected] wrote:
$ tc filter add block 1 protocol ip priority 10 flower ... classid 1:2Looks good - things will work fine for packets showing up on egress of enps7 which match the flower rule and classid 1:2 is selected to queue the packet on.
Quoted 8 lines
Quoted 5 lines
Things will not
_workfine_for packets showing up on egress of ensp8. There is no classid 1:2 on egress of enps8. The prio qdisc is a bad example because it has a default queue (i think 10:2) in this case. Other qdiscs(off top of my head DRR) will just drop the packet.I'm very well aware of this. The plan is to support this and resolve the lack of classid withing the qdisc according to the qdisc type.
If i understood you correctly, that is still iffy.
An admin will see packets for the same filter on one device going to an agreed-to queue but on another going to a default queue.
Quoted 3 lines
However, currently the classfull qdiscs are not supported for block sharing - only ingress and clsact qdiscs are supported.
Essentially anything that doesnt have queues associated with it.. (and ignore the tcf_result).
Quoted 10 lines
Quoted 5 lines
I think this is resolvable - but it will take more to the patches than the current set you posted Jiri.
A simple solution is to say sharing only works for ingress (but that sounds very lame).That is the current limitation of the patchset as you can see. The sharing works only for ingress and clsact qdisc. So works for both ingress and egress (clsact).
One option is to name all egress queues the same way on all devices f.e in the two examples i provided call root qdiscs 1:0.
I am not sure how cleanly you get this to work with egress My current thinking involves some brain somersault... I will think some more about it...
cheers,
jamal
Jiri Pirko
maintainerQuoted 17 lines · Thu, Jan 04, 2018 at 02:43:08PM CET, [email protected] wrote:
Quoted 16 lines · Jiri Pirko
Quoted 13 lines · Thu, Jan 04, 2018 at 01:55:05PM CET, [email protected] wrote:
$ tc filter add block 1 protocol ip priority 10 flower ... classid 1:2Looks good - things will work fine for packets showing up on egress of enps7 which match the flower rule and classid 1:2 is selected to queue the packet on.
Things will not
_workfine_for packets showing up on egress of ensp8. There is no classid 1:2 on egress of enps8. The prio qdisc is a bad example because it has a default queue (i think 10:2) in this case. Other qdiscs(off top of my head DRR) will just drop the packet.
Quoted 6 lines
Quoted 2 lines
I'm very well aware of this. The plan is to support this and resolve the lack of classid withing the qdisc according to the qdisc type.
If i understood you correctly, that is still iffy.
An admin will see packets for the same filter on one device going to an agreed-to queue but on another going to a default queue.
Yeah, it is. That needs a bit more thoughts and discussion. That was the main purpose I did not address it in this patchset and allowed only ingress and clsact qidsc.
Quoted 19 lines
Quoted 4 lines
However, currently the classfull qdiscs are not supported for block sharing - only ingress and clsact qdiscs are supported.
Essentially anything that doesnt have queues associated with it.. (and ignore the
tcf_result).Quoted 10 lines
Quoted 5 lines
I think this is resolvable - but it will take more to the patches than the current set you posted Jiri.
A simple solution is to say sharing only works for ingress (but that sounds very lame).That is the current limitation of the patchset as you can see. The sharing works only for ingress and clsact qdisc. So works for both ingress and egress (clsact).
Quoted 6 lines
One option is to name all egress queues the same way on all devices f.e in the two examples i provided call root qdiscs 1:0.
I am not sure how cleanly you get this to work with egress My current thinking involves some brain somersault... I will think some more about it...
clsact egress works the same as ingress qdisc - please check the code.
Quoted 3 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 10 lines · Jiri Pirko
Quoted 3 lines · Thu, Jan 04, 2018 at 02:43:08PM CET, [email protected] wrote:
If i understood you correctly, that is still iffy.
An admin will see packets for the same filter on one device going to an agreed-to queue but on another going to a default queue.Yeah, it is. That needs a bit more thoughts and discussion. That was the main purpose I did not address it in this patchset and allowed only ingress and clsact qidsc.
Like i said - this requires the admin to be aware of this issue. It is nasty otherwise.
Quoted 9 lines
Quoted 6 lines
One option is to name all egress queues the same way on all devices f.e in the two examples i provided call root qdiscs 1:0.
I am not sure how cleanly you get this to work with egress My current thinking involves some brain somersault... I will think some more about it...
clsact egress works the same as ingress qdisc - please check the code.
clsact egress does not deal with tcf_result - what code do you want me to check?
cheers,
jamal
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Thu, 4 Jan 2018 11:12:57 +0100
Quoted 1 line
No magic. ens8 and ens7 share the same block.
No Jiri, the fact that they share the same block _IS MAGIC_.
It is unexpected behavior to modify a rule and have it propagate to devices not mentioned in the command line.
This is totally going to break things and upset people.
Saying it shows up in some tc dump command is not an argument for this behavior being "expected". NO way.
I completely agree with David and others, you _MUST_ make an explicit API and set of operations to make changes to rules contained in shared blocks.
Period.
Jiri Pirko
maintainerQuoted 10 lines · Thu, Jan 04, 2018 at 04:33:48PM CET, [email protected] wrote:
From: Jiri Pirko <[email protected]>
Date: Thu, 4 Jan 2018 11:12:57 +0100Quoted 1 line
No magic. ens8 and ens7 share the same block.
No Jiri, the fact that they share the same block
_ISMAGIC_.It is unexpected behavior to modify a rule and have it propagate to devices not mentioned in the command line.
Quoted 8 lines
This is totally going to break things and upset people.
Saying it shows up in some tc dump command is not an argument for this behavior being "expected". NO way.
I completely agree with David and others, you _MUST_ make an explicit API and set of operations to make changes to rules contained in shared blocks.
Okay. So you say that when I create a qdisc and its block is created, I can never share it.
I have to always explicitly create block to share and only then to bind it to some qdisc/s?
Jiri Pirko
maintainerQuoted 20 lines · Thu, Jan 04, 2018 at 04:51:15PM CET, [email protected] wrote:
Quoted 10 lines · Thu, Jan 04, 2018 at 04:33:48PM CET, [email protected] wrote:
From: Jiri Pirko <[email protected]>
Date: Thu, 4 Jan 2018 11:12:57 +0100Quoted 1 line
No magic. ens8 and ens7 share the same block.
No Jiri, the fact that they share the same block
_ISMAGIC_.It is unexpected behavior to modify a rule and have it propagate to devices not mentioned in the command line.
Quoted 8 lines
This is totally going to break things and upset people.
Saying it shows up in some tc dump command is not an argument for this behavior being "expected". NO way.
I completely agree with David and others, you _MUST_ make an explicit API and set of operations to make changes to rules contained in shared blocks.
Quoted 5 lines
Okay. So you say that when I create a qdisc and its block is created, I can never share it.
I have to always explicitly create block to share and only then to bind it to some qdisc/s?
I think I have the idea. It can work as usual until the block gets to be shared, then only the block-specific things would work. The exisint filter add and filter should would error out (with extack message why). Ok, I'm on it. Thanks.