Skip to contentSkip to conversation

net: sched: allow qdiscs to share filter block instances

RFC PATCH In review Jiri Pirko 3 participants 11 messages Jul 10, 2017 – Jul 14, 2017

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

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:
qdisc fq_codel 0: dev ens7 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 9014 bytes 99 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22

                                              ^^^^^^^^

Sent 4592 bytes 58 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
qdisc fq_codel 0: dev ens8 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 17022 bytes 307 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22

                                              ^^^^^^^^

Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0

Now we can add filter to any of qdiscs sharing the same block:

$ tc filter add dev ens7 parent ffff: 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 root
filter parent ffff: protocol ip pref 25 flower 
filter parent ffff: protocol ip pref 25 flower handle 0x1 
  eth_type ipv4
  dst_ip 192.168.1.0/24
        action order 1: gact action drop
         random type none pass val 0
         index 3 ref 1 bind 1 installed 10201 sec used 10150 sec
        Action statistics:
        Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0) 
        backlog 0b 0p requeues 0 
$ tc -s filter show dev ens8 root
filter dev ens7 parent ffff: protocol ip pref 25 flower 
filter dev ens7 parent ffff: protocol ip pref 25 flower handle 0x1 
  eth_type ipv4
  dst_ip 192.168.1.0/24
        action order 1: gact action drop
         random type none pass val 0
         index 3 ref 1 bind 1 installed 10202 sec used 10152 sec
        Action statistics:
        Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0) 
        backlog 0b 0p requeues 0 

Issues:
- tp->q is set by the device used to add the filter. That has to be resolved. Impacts the dump (as you can see above)

Jiri Pirko (4):
net: sched: introduce support for multiple filter chain pointers
registration
net: sched: intruduce qdisc_net helper
net: sched: introduce shared filter blocks infrastructure
net: sched: allow ingress and clsact qdiscs to share filter blocks

 include/net/pkt_cls.h          |  22 +++-
 include/net/pkt_sched.h        |   7 ++
 include/net/sch_generic.h      |   4 +-
 include/uapi/linux/pkt_sched.h |  12 +++
 net/sched/cls_api.c            | 240 +++++++++++++++++++++++++++++++++++++----
 net/sched/sch_ingress.c        | 107 ++++++++++++++++--
 6 files changed, 362 insertions(+), 30 deletions(-)
Signature · 1 line
2.9.3
author maintainer
#1 lore raw

RFC PATCH 1/4 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 a block->chain[0]. However, when the blocks will get shareable, we need to allow multiple filter chain pointers registration.

---
 include/net/sch_generic.h |  2 +-
 net/sched/cls_api.c       | 66 ++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 57 insertions(+), 11 deletions(-)
include/net/sch_generic.h +1 -1
index 1c123e2..7396de8 100644
@@ -257,7 +257,7 @@ struct qdisc_skb_cb {
 
 struct tcf_chain {
 	struct tcf_proto __rcu *filter_chain;
-	struct tcf_proto __rcu **p_filter_chain;
+	struct list_head filter_chain_list;
 	struct list_head list;
 	struct tcf_block *block;
 	u32 index; /* chain index */
net/sched/cls_api.c +56 -10

119 lines not on this page · raw message

Signature · 1 line
2.9.3
author maintainer
#2 lore raw

RFC PATCH 2/4 net: sched: intruduce qdisc_net helper

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

There is going to be need to be able to obtain net structure for a qdisc. So introduce helper to do it.

---
 include/net/pkt_sched.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/net/pkt_sched.h +7 -0
index 2579c20..da85ad0 100644
@@ -4,7 +4,9 @@
 #include <linux/jiffies.h>
 #include <linux/ktime.h>
 #include <linux/if_vlan.h>
+#include <linux/netdevice.h>
 #include <net/sch_generic.h>
+#include <net/net_namespace.h>
 
 #define DEFAULT_TX_QUEUE_LEN	1000
 
@@ -132,4 +134,9 @@ static inline unsigned int psched_mtu(const struct net_device *dev)
 	return dev->mtu + dev->hard_header_len;
 }
 
+static inline struct net *qdisc_net(struct Qdisc *q)
+{
+	return dev_net(q->dev_queue->dev);
+}
+
 #endif
Signature · 1 line
2.9.3
author maintainer
#3 lore raw

RFC PATCH 3/4 net: sched: introduce shared filter blocks infrastructure

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Allow qdiscs to share filter blocks among them. Each qdisc type has to use block get/put modifications that enable sharing. Shared blocks are tracked within each net namespace and identified by u32 value. This value is auto-generated in case user did not pass it from userspace. If user passes value that is not used, new block is created. If user passes value that is already used, the existing block will be re-used.

---
 include/net/pkt_cls.h     |  22 +++++-
 include/net/sch_generic.h |   2 +
 net/sched/cls_api.c       | 180 ++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 189 insertions(+), 15 deletions(-)
include/net/pkt_cls.h +21 -1
index 537d0a0..4381cbc 100644
@@ -23,7 +23,12 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
 void tcf_chain_put(struct tcf_chain *chain);
 int tcf_block_get(struct tcf_block **p_block,
 		  struct tcf_proto __rcu **p_filter_chain);
+int tcf_block_get_shared(struct tcf_block **p_block,
+			 struct net *net, u32 block_index,
+			 struct tcf_proto __rcu **p_filter_chain);
 void tcf_block_put(struct tcf_block *block);
+void tcf_block_put_shared(struct tcf_block *block, struct net *net,
+			  struct tcf_proto __rcu **p_filter_chain);
 int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
 		 struct tcf_result *res, bool compat_mode);
 
@@ -35,7 +40,22 @@ int tcf_block_get(struct tcf_block **p_block,
 	return 0;
 }
 
-static inline void tcf_block_put(struct tcf_block *block)
+static inline
+int tcf_block_get_shared(struct tcf_block **p_block,
+			 struct net *net, u32 block_index,
+			 struct tcf_proto __rcu **p_filter_chain)
+{
+	return 0;
+}
+
+static inline
+void tcf_block_put(struct tcf_block *block)
+{
+}
+
+static inline
+void tcf_block_put_shared(struct tcf_block *block, struct net *net,
+			  struct tcf_proto __rcu **p_filter_chain)
 {
 }
 
include/net/sch_generic.h +2 -0
index 7396de8..cbc7313 100644
@@ -266,6 +266,8 @@ struct tcf_chain {
 
 struct tcf_block {
 	struct list_head chain_list;
+	u32 index; /* block index for shared blocks */
+	unsigned int refcnt;
 };
 
 static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
net/sched/cls_api.c +166 -14

232 lines not on this page · raw message

Signature · 1 line
2.9.3
author maintainer
#4 lore raw

RFC PATCH 4/4 net: sched: allow ingress and clsact qdiscs to share filter blocks

In reply to Jiri Pirko

From: 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.

---
 include/uapi/linux/pkt_sched.h |  12 +++++
 net/sched/sch_ingress.c        | 107 ++++++++++++++++++++++++++++++++++++++---
 2 files changed, 112 insertions(+), 7 deletions(-)
include/uapi/linux/pkt_sched.h +12 -0
index 099bf55..a684087 100644
@@ -871,4 +871,16 @@ struct tc_pie_xstats {
 	__u32 maxq;             /* maximum queue size */
 	__u32 ecn_mark;         /* packets marked with ecn*/
 };
+
+/* 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 +100 -7

169 lines not on this page · raw message

Signature · 1 line
2.9.3
author maintainer
#5 lore raw

RFC PATCH 1/1 tc: Implement filter block sharing to ingress and clsact qdiscs

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

---
 include/linux/pkt_sched.h | 12 +++++++++++
 tc/q_clsact.c             | 54 ++++++++++++++++++++++++++++++++++++++++++-----
 tc/q_ingress.c            | 32 +++++++++++++++++++++++++---
 3 files changed, 90 insertions(+), 8 deletions(-)
include/linux/pkt_sched.h +12 -0
index 099bf55..a684087 100644
@@ -871,4 +871,16 @@ struct tc_pie_xstats {
 	__u32 maxq;             /* maximum queue size */
 	__u32 ecn_mark;         /* packets marked with ecn*/
 };
+
+/* 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 +49 -5

72 lines not on this page · raw message

tc/q_ingress.c +29 -3
index 31699a8..b973e1b 100644
@@ -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)
 {
+	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]);
+		fprintf(f, "block %u ", block);
+	}
 	return 0;
 }
 
Signature · 1 line
2.9.3
#6 lore raw
In reply to Jiri Pirko
Quoted 8 lines · Jiri Pirko

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.

[...]

Quoted 4 lines

Now we can add filter to any of qdiscs sharing the same block:

$ tc filter add dev ens7 parent ffff: 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:

yeah, but the stats belong to the action, not the filter, right? so you create here actually a shared action? or you also introduced in that series stats for filters, I am confused...

Or.

author maintainer
#7 lore raw
Quoted 13 lines · Tue, Jul 11, 2017 at 08:57:30AM CEST, [email protected] wrote:
Quoted 8 lines · Jiri Pirko

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.

[...]

Quoted 8 lines
Quoted 4 lines

Now we can add filter to any of qdiscs sharing the same block:

$ tc filter add dev ens7 parent ffff: 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:

yeah, but the stats belong to the action, not the filter, right? so you create here actually a shared action? or you also introduced in that series stats for filters, I am confused...

Filters are shared along with all that belongs to them, so including actions.

maintainer
#8 lore raw
In reply to Jiri Pirko

Hi Jiri,

Commenting on generalities - will comment on code later:

Quoted 9 lines · Jiri Pirko

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.

Quoted 8 lines

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

Above makes intuitive sense.

                                  ^^^^^^^^
Quoted 17 lines

Now if we list the qdiscs, we will see the block index in the output:
qdisc fq_codel 0: dev ens7 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 9014 bytes 99 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22

                                               ^^^^^^^^

Sent 4592 bytes 58 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
qdisc fq_codel 0: dev ens8 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 17022 bytes 307 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22

Quoted 4 lines
                                               ^^^^^^^^

Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0

So does this.

Quoted 5 lines

Now we can add filter to any of qdiscs sharing the same block:

$ tc filter add dev ens7 parent ffff: protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop

So for backward compat - this also makes sense. But:
it does make sense to create new syntax for adding filters and actions:

tc filter add block 22 protocol ip pref 25 flower \
dst_ip 192.168.0.0/16 action drop

Coordinates of the filter block before were:

<ifindex>, <parent>, [handle]

You should be able to abuse struct tcmsg ifindex to represent block # as long as you set parent to be something meaningful that is identified "block coordinate" via TC_H_XXX (pick something safe not in use by ingress or egress; look at: uapi/linux/pkt_sched.h)

Quoted 28 lines

We will see the same output if we list filters for ens7 and ens8, including stats:

$ tc -s filter show dev ens7 root
filter parent ffff: protocol ip pref 25 flower
filter parent ffff: protocol ip pref 25 flower handle 0x1
   eth_type ipv4
   dst_ip 192.168.1.0/24
         action order 1: gact action drop
          random type none pass val 0
          index 3 ref 1 bind 1 installed 10201 sec used 10150 sec
         Action statistics:
         Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
$ tc -s filter show dev ens8 root
filter dev ens7 parent ffff: protocol ip pref 25 flower
filter dev ens7 parent ffff: protocol ip pref 25 flower handle 0x1
   eth_type ipv4
   dst_ip 192.168.1.0/24
         action order 1: gact action drop
          random type none pass val 0
          index 3 ref 1 bind 1 installed 10202 sec used 10152 sec
         Action statistics:
         Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
Quoted 4 lines

Issues:
- tp->q is set by the device used to add the filter. That has to be resolved. Impacts the dump (as you can see above)

I think you have more problems if the dump above is reality;-> You added to ingress and this is showing egress.

To complete the thought, dump is:

tc -s filter show block 22

cheers,
jamal

author maintainer
#9 lore raw
Quoted 57 lines · Tue, Jul 11, 2017 at 02:15:27PM CEST, [email protected] wrote:

Hi Jiri,

Commenting on generalities - will comment on code later:

Quoted 9 lines · Jiri Pirko

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.

Quoted 8 lines

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

Above makes intuitive sense.

                                 ^^^^^^^^
Quoted 17 lines

Now if we list the qdiscs, we will see the block index in the output:
qdisc fq_codel 0: dev ens7 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 9014 bytes 99 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
qdisc ingress ffff: dev ens7 parent ffff:fff1 block 22

                                               ^^^^^^^^

Sent 4592 bytes 58 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
qdisc fq_codel 0: dev ens8 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 17022 bytes 307 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
qdisc ingress ffff: dev ens8 parent ffff:fff1 block 22

Quoted 4 lines
                                               ^^^^^^^^

Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0

So does this.

Quoted 5 lines

Now we can add filter to any of qdiscs sharing the same block:

$ tc filter add dev ens7 parent ffff: protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop
Quoted 6 lines

So for backward compat - this also makes sense. But:
it does make sense to create new syntax for adding filters and actions:

tc filter add block 22 protocol ip pref 25 flower \
dst_ip 192.168.0.0/16 action drop

Was thinking about that. Decided to pass on this now. This should be addressed by follow-up anyway.

Quoted 9 lines

Coordinates of the filter block before were:

<ifindex>, <parent>, [handle]

You should be able to abuse struct tcmsg ifindex to represent block # as long as you set parent to be something meaningful that is identified "block coordinate" via TC_H_XXX (pick something safe not in use by ingress or egress; look at: uapi/linux/pkt_sched.h)

Not sure about this. I have take closer look. In general, I don't like to abuse anything :)

Quoted 29 lines
Quoted 29 lines

We will see the same output if we list filters for ens7 and ens8, including stats:

$ tc -s filter show dev ens7 root
filter parent ffff: protocol ip pref 25 flower
filter parent ffff: protocol ip pref 25 flower handle 0x1
   eth_type ipv4
   dst_ip 192.168.1.0/24
         action order 1: gact action drop
          random type none pass val 0
          index 3 ref 1 bind 1 installed 10201 sec used 10150 sec
         Action statistics:
         Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
$ tc -s filter show dev ens8 root
filter dev ens7 parent ffff: protocol ip pref 25 flower
filter dev ens7 parent ffff: protocol ip pref 25 flower handle 0x1
   eth_type ipv4
   dst_ip 192.168.1.0/24
         action order 1: gact action drop
          random type none pass val 0
          index 3 ref 1 bind 1 installed 10202 sec used 10152 sec
         Action statistics:
         Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
Quoted 7 lines
Quoted 4 lines

Issues:
- tp->q is set by the device used to add the filter. That has to be resolved. Impacts the dump (as you can see above)

I think you have more problems if the dump above is reality;-> You added to ingress and this is showing egress.

Howcome? I only don't see "dev x" on ens7. That is the only difference,

Quoted 4 lines

To complete the thought, dump is:

tc -s filter show block 22

Understood. Again, this should be addressed in follow-up.

Quoted 4 lines

cheers,
jamal

maintainer
#10 lore raw
Quoted 3 lines · Jiri Pirko
Quoted 2 lines · Tue, Jul 11, 2017 at 02:15:27PM CEST, [email protected] wrote:

Hi Jiri,

[..]

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

Now we can add filter to any of qdiscs sharing the same block:

$ tc filter add dev ens7 parent ffff: protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop

So for backward compat - this also makes sense. But:
it does make sense to create new syntax for adding filters and actions:

Quoted 6 lines
Quoted 2 lines

tc filter add block 22 protocol ip pref 25 flower \
dst_ip 192.168.0.0/16 action drop

Was thinking about that. Decided to pass on this now. This should be addressed by follow-up anyway.

Ok, thanks. I feel it is very important.

Quoted 6 lines
Quoted 6 lines

Coordinates of the filter block before were:

<ifindex>, <parent>, [handle]

Quoted 8 lines
Quoted 4 lines

You should be able to abuse struct tcmsg ifindex to represent block # as long as you set parent to be something meaningful that is identified "block coordinate" via TC_H_XXX (pick something safe not in use by ingress or egress; look at: uapi/linux/pkt_sched.h)

Not sure about this. I have take closer look. In general, I don't like to abuse anything :)

I should have said it without "ab" i.e "use" ;->
The purpose of those coordinates is to describe the "location" of what you call the "block" now.
We used to have egress, then ingress "blocks" tied to a port. then Daniel added clsact above but still ingress + egress And it used to be tied to a port and you just changed it to be port independent etc.
It is a natural evolution.

Quoted 1 line
Quoted 1 line
Quoted 1 line

We will see the same output if we list filters for ens7 and ens8, including stats:

[..]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
$ tc -s filter show dev ens8 root
filter dev ens7 parent ffff: protocol ip pref 25 flower
filter dev ens7 parent ffff: protocol ip pref 25 flower handle 0x1
    eth_type ipv4
    dst_ip 192.168.1.0/24
          action order 1: gact action drop
           random type none pass val 0
           index 3 ref 1 bind 1 installed 10202 sec used 10152 sec
          Action statistics:
          Sent 4200 bytes 50 pkt (dropped 50, overlimits 0 requeues 0)
          backlog 0b 0p requeues 0

Issues:
- tp->q is set by the device used to add the filter. That has to be resolved. Impacts the dump (as you can see above)

Quoted 5 lines
Quoted 2 lines

I think you have more problems if the dump above is reality;-> You added to ingress and this is showing egress.

Howcome? I only don't see "dev x" on ens7. That is the only difference,

I meant you are displaying egress qdisc filters(root) but you added them to ingress (ffff:). I would have expected the output you showed had you said:
tc -s filter show dev ens8 parent ffff:

cheers,
jamal