Return the new filter through *arg, as the other classifiers do. head is always NULL at that point, so the RTM_NEWTFILTER notification for a matchall add has handle 0 and no TCA_OPTIONS: # tc monitor & # tc filter add dev d0 ingress pref 10 protocol ip matchall action pass added filter dev d0 ingress protocol ip pref 10 matchall chain 0 With this patch it carries handle 0x1, the flags and the action. Fixes: fd62d9f5c575 ("net/sched: matchall: Fix configuration race") Signed-off-by: Dave Seddon --- net/sched/cls_matchall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 6ece63b82775..52be7660b682 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -230,7 +230,7 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, tcf_proto_update_usesw(tp, new->flags); - *arg = head; + *arg = new; rcu_assign_pointer(tp->root, new); return 0; -- 2.56.0 Return the new filter through *arg, as the other classifiers do. cls_cgroup_change() never sets it, so the RTM_NEWTFILTER notification for a cgroup add or replace has handle 0 and no TCA_OPTIONS: # tc -echo filter add dev d0 ingress handle 7 pref 1 cgroup action ok added filter dev d0 ingress protocol all pref 1 cgroup chain 0 With this patch it carries handle 0x7 and the action. Fixes: f400923735ec ("pkt_sched: Control group classifier") Signed-off-by: Dave Seddon --- net/sched/cls_cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index 28701d3916b8..521901d8538c 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c @@ -119,6 +119,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, if (err < 0) goto errout; + *arg = new; rcu_assign_pointer(tp->root, new); if (head) { tcf_exts_get_net(&head->exts); -- 2.56.0 Add a matchall and a cgroup filter with "tc -echo" and check that the echoed notification carries the filter handle. Both tests fail without the previous two patches. Signed-off-by: Dave Seddon --- .../tc-testing/tc-tests/filters/cgroup.json | 22 +++++++++++++++++++ .../tc-testing/tc-tests/filters/matchall.json | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/cgroup.json b/tools/testing/selftests/tc-testing/tc-tests/filters/cgroup.json index 35c9a7dbe1c4..9bbbb6b08e2d 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/cgroup.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/cgroup.json @@ -1232,5 +1232,27 @@ "teardown": [ "$TC qdisc del dev $DEV1 ingress" ] + }, + { + "id": "b9d4", + "name": "Add cgroup filter and check the echoed notification", + "category": [ + "filter", + "cgroup" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DUMMY ingress" + ], + "cmdUnderTest": "bash -c '$TC -echo filter add dev $DUMMY parent ffff: handle 0x7 prio 1 protocol ip cgroup action ok | grep \"cgroup.*handle 0x7\"'", + "expExitCode": "0", + "verifyCmd": "$TC filter show dev $DUMMY ingress", + "matchPattern": "cgroup.*handle 0x7", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress" + ] } ] diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json index 6b3eea401fc8..c4689cb62f3e 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json @@ -574,5 +574,27 @@ "teardown": [ "$TC qdisc del dev $DEV1 clsact" ] + }, + { + "id": "e3c7", + "name": "Add ingress matchall filter and check the echoed notification", + "category": [ + "filter", + "matchall" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DUMMY ingress" + ], + "cmdUnderTest": "bash -c '$TC -echo filter add dev $DUMMY parent ffff: handle 0x7 prio 1 protocol ip matchall action ok | grep \"matchall.*handle 0x7\"'", + "expExitCode": "0", + "verifyCmd": "$TC filter show dev $DUMMY ingress", + "matchPattern": "matchall.*handle 0x7", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress" + ] } ] -- 2.56.0