* [PATCH net v4 0/5] net/sched: u32_change() fixes
@ 2026-12-03 12:40 Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 1/5] net/sched: cls_u32: fix linked hash table refcount leak Jedrzej Jagielski
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Jedrzej Jagielski @ 2026-12-03 12:40 UTC (permalink / raw)
To: netdev; +Cc: anthony.l.nguyen, kuba, jhs, jiri, edumazet, Jedrzej Jagielski
Hi,
This series fixes four bugs in cls_u32's u32_change() function:
Since commit 695176bfe5de ("net_sched: refactor TC action init API")
u32_change() passes TCA_ACT_FLAGS_* instead of the u32 classifier flags
to u32_replace_hw_knode(), so skip_sw is ignored when offloading u32
knodes: tc_setup_cb_add() runs with err_stop == false, driver errors
are swallowed and a skip_sw filter that cannot be offloaded is reported
as successfully installed, while it matches neither in SW nor in HW.
Patch 4 fixes that. Doing so makes the error paths of
u32_replace_hw_knode() in u32_change() reachable again. They have been
dead code since 695176bfe5de and contain bugs, which patches 1-3 fix
first:
Patch 1 drops the n->ht_down reference at errunbind, which leaked the
linked hash table when offloading a new knode with TCA_U32_LINK failed.
Patch 2 removes a refcount_inc() in the replace error path, which
"undid" a decrement already balanced by u32_init_knode() and leaked a
reference on the old linked hash table.
Patch 3 stops the rollback from sending TC_CLSU32_DELETE_KNODE on a
failed replace. The new knode shares its handle with the still
installed old one, so the rollback removed the old HW rule. It also
documents the trade-off for blocks with multiple offload callbacks
and hints userspace via extack that HW rollback was skipped.
Patch 5 adds a tdc test checking that a skip_sw u32 filter is rejected
on a device without offload support.
Note that with patch 4, skip_sw add/replace commands which cannot be
offloaded now fail with -EOPNOTSUPP/-EINVAL instead of silently
succeeding.
v2:
- add fixes for 2 preexisting issues uncovered by the initial fix
v3:
- reorder: fixes first, skip_sw fix after them, so no bisect point
- add 'don't remove old HW rule on failed knode replace' fix
- add selftest
- alter cover letter content
v4:
- rephrase exack msg
Jedrzej Jagielski (5):
net/sched: cls_u32: fix linked hash table refcount leak
net/sched: cls_u32: remove erroneous refcount_inc()
net/sched: cls_u32: don't remove old HW rule on failed knode replace
net/sched: cls_u32: feed u32_replace_hw_knode() with correct set of
flags
selftests: tc-testing: add u32 skip_sw test
net/sched/cls_u32.c | 26 +++++++++----------
.../tc-testing/tc-tests/filters/u32.json | 22 ++++++++++++++++
2 files changed, 35 insertions(+), 13 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v4 1/5] net/sched: cls_u32: fix linked hash table refcount leak
2026-12-03 12:40 [PATCH net v4 0/5] net/sched: u32_change() fixes Jedrzej Jagielski
@ 2026-12-03 12:40 ` Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc() Jedrzej Jagielski
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Jedrzej Jagielski @ 2026-12-03 12:40 UTC (permalink / raw)
To: netdev
Cc: anthony.l.nguyen, kuba, jhs, jiri, edumazet, Jedrzej Jagielski,
stable, Sashiko
When a new filter is created with TCA_U32_LINK, u32_set_parms() resolves
the linked hash table and increments its reference count, storing it in
n->ht_down.
If u32_replace_hw_knode() subsequently fails, execution jumps to the
errunbind label which frees the node with kfree(n) but never drops the
reference on n->ht_down. This leaves the tc_u_hnode refcount permanently
elevated, preventing it from being freed when the hash table is later
deleted.
Drop the ht_down reference at errunbind before freeing the node.
This is a forward fix for currently dead code, which will be uncovered
by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode()
with correct set of flags".
Fixes: d34e3e181395 ("net: cls_u32: Add support for skip-sw flag to tc u32 classifier.")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260807100356.1083774-1-jedrzej.jagielski%40intel.com
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
net/sched/cls_u32.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 91f4e6458785..c544c8e4e876 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -891,7 +891,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
struct netlink_ext_ack *extack)
{
struct tc_u_common *tp_c = tp->data;
- struct tc_u_hnode *ht;
+ struct tc_u_hnode *ht, *ht_down;
struct tc_u_knode *n;
struct tc_u32_sel *s;
struct nlattr *opt = tca[TCA_OPTIONS];
@@ -1221,6 +1221,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
errunbind:
u32_unbind_filter(tp, n, tb);
+ ht_down = rtnl_dereference(n->ht_down);
+ if (ht_down && refcount_dec_and_test(&ht_down->refcnt))
+ kfree(ht_down);
#ifdef CONFIG_CLS_U32_MARK
free_percpu(n->pcpu_success);
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc()
2026-12-03 12:40 [PATCH net v4 0/5] net/sched: u32_change() fixes Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 1/5] net/sched: cls_u32: fix linked hash table refcount leak Jedrzej Jagielski
@ 2026-12-03 12:40 ` Jedrzej Jagielski
2026-12-04 14:02 ` netdev-bot+sashiko
2026-12-03 12:40 ` [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace Jedrzej Jagielski
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Jedrzej Jagielski @ 2026-12-03 12:40 UTC (permalink / raw)
To: netdev
Cc: anthony.l.nguyen, kuba, jhs, jiri, edumazet, Jedrzej Jagielski,
stable, Sashiko
Remove the redundant refcount_inc(&ht_old->refcnt) in the
u32_replace_hw_knode() error path during filter update.
Commit e8d3d78c19be ("net: sched: cls_u32: Undo refcount decrement in case update failed")
added this increment to "undo" a decrement performed by u32_set_parms()
on the original node's linked hash table but apparently this decrement
is already balanced by u32_init_knode(), which increments the same
refcount when cloning the original node:
u32_init_knode(): refcount_inc() on the old ht_down
u32_set_parms(): refcount_dec() on ht_old
__u32_destroy_key(new): drops new->ht_down
These cancel out, leaving the original hash table's refcount unchanged.
The additional refcount_inc in the error path has no matching decrement,
leaving the tc_u_hnode refcount permanently elevated by 1. This
prevents the hash table from ever being freed, leaking memory.
__u32_destroy_key(new) already correctly drops new->ht_down's refcount
(the new linked hash table set by u32_set_parms), so no manual refcount
fixup is needed.
This is a forward fix for currently dead code, which will be uncovered
by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode()
with correct set of flags".
Fixes: e8d3d78c19be ("net: sched: cls_u32: Undo refcount decrement in case update failed")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260807100356.1083774-1-jedrzej.jagielski%40intel.com
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
net/sched/cls_u32.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index c544c8e4e876..ae1b6476f921 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -954,14 +954,6 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
err = u32_replace_hw_knode(tp, new, flags, extack);
if (err) {
u32_unbind_filter(tp, new, tb);
-
- if (tb[TCA_U32_LINK]) {
- struct tc_u_hnode *ht_old;
-
- ht_old = rtnl_dereference(n->ht_down);
- if (ht_old)
- refcount_inc(&ht_old->refcnt);
- }
__u32_destroy_key(new);
return err;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace
2026-12-03 12:40 [PATCH net v4 0/5] net/sched: u32_change() fixes Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 1/5] net/sched: cls_u32: fix linked hash table refcount leak Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc() Jedrzej Jagielski
@ 2026-12-03 12:40 ` Jedrzej Jagielski
2026-12-04 14:02 ` netdev-bot+sashiko
2026-12-03 12:40 ` [PATCH net v4 4/5] net/sched: cls_u32: feed u32_replace_hw_knode() with correct set of flags Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 5/5] selftests: tc-testing: add u32 skip_sw test Jedrzej Jagielski
4 siblings, 1 reply; 8+ messages in thread
From: Jedrzej Jagielski @ 2026-12-03 12:40 UTC (permalink / raw)
To: netdev
Cc: anthony.l.nguyen, kuba, jhs, jiri, edumazet, Jedrzej Jagielski,
stable, Sashiko
On knode replace, u32_init_knode() copies the handle of the existing
knode into the new one. If offloading the new knode fails,
u32_replace_hw_knode() rolls back with u32_remove_hw_knode(), which
issues TC_CLSU32_DELETE_KNODE for that shared handle and so removes
the HW rule of the old knode, which is still installed in software.
For a skip_sw filter, u32_classify() skips it, so the filter matches
neither in SW nor in HW, while userspace is told the replace failed.
Add @new_handle to u32_replace_hw_knode() and roll back only when the
handle is not shared with an installed knode, i.e. when adding a new
one. On replace, leave the old HW rule in place, in line with
tc_setup_cb_add() treating a failed add as non-destructive.
This is a trade-off for blocks with multiple offload callbacks.
tc_setup_cb_add() stops at the first failing callback, so callbacks
which accepted the replace before it keep the new rule, and its
link_handle may refer to an hnode no longer referenced in software
once the new knode is destroyed. The removed rollback deleted the rule
on all callbacks instead, including those which rejected the replace
and still held the old rule. Since commit 695176bfe5de ("net_sched:
refactor TC action init API") skip_sw is ignored, so the same split
HW state is left, but silently and with the new knode installed in
software. Unless a netdev sharing the block is not offload-capable
let userspace know via extack that the hardware rollback was skipped.
Rolling back per callback is not possible, as tc_setup_cb_add() does
not report which callbacks succeeded and drivers identify u32 rules by
handle only. Re-offloading the old knode is not done either, as
drivers which reject an existing handle (e.g. ixgbe) or handle
REPLACE_KNODE as an add (e.g. cxgb4) would not be restored by it.
Drivers which destroy the old rule themselves when REPLACE_KNODE fails
(e.g. stmmac, nfp abm) still lose it, which is not changed by this
patch.
This is a forward fix for currently dead code, which will be uncovered
by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode()
with correct set of flags".
Fixes: 245dc5121a9b ("net: sched: cls_u32: call block callbacks for offload")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260813122242.1690024-1-jedrzej.jagielski%40intel.com
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
net/sched/cls_u32.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index ae1b6476f921..7ec05629e860 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -548,7 +548,8 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
}
static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
- u32 flags, struct netlink_ext_ack *extack)
+ u32 flags, bool new_handle,
+ struct netlink_ext_ack *extack)
{
struct tc_u_hnode *ht = rtnl_dereference(n->ht_down);
struct tcf_block *block = tp->chain->block;
@@ -576,7 +577,11 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
err = tc_setup_cb_add(block, tp, TC_SETUP_CLSU32, &cls_u32, skip_sw,
&n->flags, &n->in_hw_count, true);
if (err) {
- u32_remove_hw_knode(tp, n, NULL);
+ if (new_handle)
+ u32_remove_hw_knode(tp, n, NULL);
+ else if (!block->nooffloaddevcnt)
+ NL_SET_ERR_MSG_WEAK_MOD(extack,
+ "Replace failed, hardware rollback was skipped");
return err;
}
@@ -951,7 +956,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
u32_bind_filter(tp, new, base, tb);
- err = u32_replace_hw_knode(tp, new, flags, extack);
+ err = u32_replace_hw_knode(tp, new, flags, false, extack);
if (err) {
u32_unbind_filter(tp, new, tb);
__u32_destroy_key(new);
@@ -1189,7 +1194,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
struct tc_u_knode __rcu **ins;
struct tc_u_knode *pins;
- err = u32_replace_hw_knode(tp, n, flags, extack);
+ err = u32_replace_hw_knode(tp, n, flags, true, extack);
if (err)
goto errunbind;
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v4 4/5] net/sched: cls_u32: feed u32_replace_hw_knode() with correct set of flags
2026-12-03 12:40 [PATCH net v4 0/5] net/sched: u32_change() fixes Jedrzej Jagielski
` (2 preceding siblings ...)
2026-12-03 12:40 ` [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace Jedrzej Jagielski
@ 2026-12-03 12:40 ` Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 5/5] selftests: tc-testing: add u32 skip_sw test Jedrzej Jagielski
4 siblings, 0 replies; 8+ messages in thread
From: Jedrzej Jagielski @ 2026-12-03 12:40 UTC (permalink / raw)
To: netdev
Cc: anthony.l.nguyen, kuba, jhs, jiri, edumazet, Jedrzej Jagielski,
stable, Marcin Szycik, Przemek Kitszel
When trying to offload u32 cmd by adding skip_sw attributes it gets
ignored and it cannot be correctly processed by HW and tc_cls_u32_offload
struct which is then passed to driver lacks skip_sw var enabled.
Encountered the issue while developing ixgbe.
u32_replace_hw_knode is fed with the TCA_ACT_* flags (bits 16+)
instead of TCA_CLS_* flags (bits 0-4) which actually stores the flags
parsed by tc, so tc_skip_sw() always returns false. This leads to
ignoring some of the attibutes which meant to be configured on filter
setup.
None of the TCA_ACT_FLAGS_* is actually used within
u32_replace_hw_knode(), so theres no point in passing them.
Other classifiers do not put TCA_ACT_FLAGS_* during filter setup.
Looks like commit 695176bfe5de ("net_sched: refactor TC action init API")
shadowed the local flags variable which used to be set with
nla_get_u32(tb[TCA_U32_FLAGS]) with the flags as the new function param
while not replacing for none of the u32_replace_hw_knode() calls.
Because skip_sw is now honored, "tc ... u32 ... skip_sw" add/replace
commands that previously succeeded (and were silently skipped by the
software path) will now return -EOPNOTSUPP/-EINVAL when the block or
driver cannot offload the filter.
Fixes: 695176bfe5de ("net_sched: refactor TC action init API")
Cc: stable@vger.kernel.org
Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
net/sched/cls_u32.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 7ec05629e860..2c1dd926f6c0 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -956,7 +956,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
u32_bind_filter(tp, new, base, tb);
- err = u32_replace_hw_knode(tp, new, flags, false, extack);
+ err = u32_replace_hw_knode(tp, new, userflags, false, extack);
if (err) {
u32_unbind_filter(tp, new, tb);
__u32_destroy_key(new);
@@ -1194,7 +1194,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
struct tc_u_knode __rcu **ins;
struct tc_u_knode *pins;
- err = u32_replace_hw_knode(tp, n, flags, true, extack);
+ err = u32_replace_hw_knode(tp, n, userflags, true, extack);
if (err)
goto errunbind;
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v4 5/5] selftests: tc-testing: add u32 skip_sw test
2026-12-03 12:40 [PATCH net v4 0/5] net/sched: u32_change() fixes Jedrzej Jagielski
` (3 preceding siblings ...)
2026-12-03 12:40 ` [PATCH net v4 4/5] net/sched: cls_u32: feed u32_replace_hw_knode() with correct set of flags Jedrzej Jagielski
@ 2026-12-03 12:40 ` Jedrzej Jagielski
4 siblings, 0 replies; 8+ messages in thread
From: Jedrzej Jagielski @ 2026-12-03 12:40 UTC (permalink / raw)
To: netdev; +Cc: anthony.l.nguyen, kuba, jhs, jiri, edumazet, Jedrzej Jagielski
Add a tdc test case checking that cls_u32 honors skip_sw. The dummy
device has no tc offload, so the block bound to its ingress qdisc
counts a non offload-capable device and a skip_sw filter cannot be
offloaded anywhere.
The filter add is expected to fail with EOPNOTSUPP (exit 2) and leave
no u32 filter behind. Before the fix, skip_sw was ignored for u32
knodes, the add silently succeeded and the filter matched neither in
software nor in hardware.
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
.../tc-testing/tc-tests/filters/u32.json | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json b/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json
index edc5148a8d97..a97caf9ff85d 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json
@@ -424,5 +424,27 @@
"teardown": [
"$TC qdisc del dev $DEV1 ingress"
]
+ },
+ {
+ "id": "a6e9",
+ "name": "Reject u32 with skip_sw on device without offload support",
+ "category": [
+ "filter",
+ "u32"
+ ],
+ "plugins": {
+ "requires": "nsPlugin"
+ },
+ "setup": [
+ "$TC qdisc add dev $DUMMY ingress"
+ ],
+ "cmdUnderTest": "$TC filter add dev $DUMMY ingress u32 match u32 0 0 skip_sw",
+ "expExitCode": "2",
+ "verifyCmd": "$TC filter show dev $DUMMY ingress",
+ "matchPattern": "u32",
+ "matchCount": "0",
+ "teardown": [
+ "$TC qdisc del dev $DUMMY ingress"
+ ]
}
]
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc()
2026-12-03 12:40 ` [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc() Jedrzej Jagielski
@ 2026-12-04 14:02 ` netdev-bot+sashiko
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 14:02 UTC (permalink / raw)
To: jedrzej.jagielski; +Cc: netdev, anthony.l.nguyen, kuba, jhs, jiri, edumazet
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message describes the removed refcount_inc() as "a
forward fix for currently dead code, which will be uncovered by the…
--
net/sched: cls_u32: remove erroneous refcount_inc()
This patch removes the refcount_inc() on the old linked tc_u_hnode in the
u32_replace_hw_knode() error path of u32_change(). The decrement done by
u32_set_parms() is already balanced by the increment in u32_init_knode(),
so the extra refcount_inc() leaks the hash table.
Closes: https://sashiko.dev/#/patchset/20260807100356.1083774-1-jedrzej.jagielski%40intel.com
> This is a forward fix for currently dead code, which will be uncovered
> by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode()
> with correct set of flags".
[Severity: Low]
This patch has Cc: stable and Fixes: e8d3d78c19be. Is "currently dead
code" true for every stable tree it is meant for?
The branch only became unreachable with 695176bfe5de ("net_sched: refactor
TC action init API") in v5.14. That commit renamed the TCA_U32_FLAGS local
in u32_change() from flags to userflags. It then reused flags for the
kernel TCA_ACT_FLAGS_* word but left the knode call unchanged:
err = u32_replace_hw_knode(tp, new, flags, extack);
Since then, skip_sw has been ignored on this call.
Before v5.14, flags still holds the user's TCA_U32_FLAGS value. Take a
pre-5.14 stable tree that picked up e8d3d78c19be. There, a skip_sw replace
with TCA_U32_LINK that fails to offload would reach this error branch.
Each such failure would raise the old linked tc_u_hnode refcnt by one and
never drop it. A later u32_delete() of that table would then return -EBUSY,
and the table would never be freed.
I can't tell from here whether e8d3d78c19be was actually backported to
pre-5.14 trees, so this part depends on that.
The follow-up flags patch carries Fixes: 695176bfe5de and would not apply
to those older trees.
Could the commit message say that the path is live in pre-v5.14 trees that
contain e8d3d78c19be? Otherwise this patch might be skipped there as only
mattering together with the flags patch.
The refcount change itself looks correct:
- u32_init_knode() takes a reference on the old ht_down.
- u32_set_parms() takes one on the new table and drops one on the old.
- __u32_destroy_key(new) drops the one on the new table.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203124056.547555-1-jedrzej.jagielski%40intel.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace
2026-12-03 12:40 ` [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace Jedrzej Jagielski
@ 2026-12-04 14:02 ` netdev-bot+sashiko
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 14:02 UTC (permalink / raw)
To: jedrzej.jagielski; +Cc: netdev, anthony.l.nguyen, kuba, jhs, jiri, edumazet
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In the final state of the series, u32_replace_hw_knode() in
net/sched/cls_u32.c no longer rolls back hardware when a knode replace…
--
net/sched: cls_u32: don't remove old HW rule on failed knode replace
The commit adds a new_handle parameter to u32_replace_hw_knode(). When
offloading a replacement knode fails, it no longer sends
TC_CLSU32_DELETE_KNODE for the handle that the new knode shares with the
old one, which is still installed. In that case it sets a weak extack
message saying the hardware rollback was skipped, unless the block has a
netdev that cannot offload.
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index ae1b6476f921d..7ec05629e8604 100644
> --- a/net/sched/cls_u32.c
> +++ b/net/sched/cls_u32.c
[ ... ]
> @@ -576,7 +577,11 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
> err = tc_setup_cb_add(block, tp, TC_SETUP_CLSU32, &cls_u32, skip_sw,
> &n->flags, &n->in_hw_count, true);
> if (err) {
> - u32_remove_hw_knode(tp, n, NULL);
> + if (new_handle)
> + u32_remove_hw_knode(tp, n, NULL);
> + else if (!block->nooffloaddevcnt)
> + NL_SET_ERR_MSG_WEAK_MOD(extack,
> + "Replace failed, hardware rollback was skipped");
[Severity: Medium]
Will this message reach userspace in the multi-callback case that the
commit message calls a trade-off? NL_SET_ERR_MSG_WEAK_MOD() writes only
when no message has been set yet:
include/linux/netlink.h:
#define NL_SET_ERR_MSG_WEAK_MOD(extack, msg) do { \
if ((extack) && !(extack)->_msg) \
NL_SET_ERR_MSG_MOD((extack), msg); \
} while (0)
tc_cls_common_offload_init() passes extack to drivers only when
tc_skip_sw(flags) is set. Because err_stop is skip_sw, that is also the
only case in which tc_setup_cb_add() can return an error here. So the
driver that rejects the rule always holds this same extack.
u32 offload drivers usually fill it in when they reject a rule, for
example:
iavf_add_cls_u32():
NL_SET_ERR_MSG_MOD(extack, "Linking not supported");
cxgb4_config_knode():
NL_SET_ERR_MSG_MOD(extack,
"No free LETCAM index available");
Take a shared block where an earlier callback accepts REPLACE_KNODE and a
later one rejects it. __tc_setup_cb_call() stops at the failing callback,
so the earlier devices keep the new rule. That rule may carry a
link_handle to an hnode that software stops referencing after
u32_change() calls __u32_destroy_key(new). Software keeps the old knode,
and userspace sees only the driver's reject reason.
The commit message says:
Unless a netdev sharing the block is not offload-capable
let userspace know via extack that the hardware rollback was skipped.
Is that statement reliably true, given that the macro is the weak
variant?
The opposite case happens too. ixgbe_configure_clsu32() never sets
extack. If ixgbe is the first or only callback and rejects the replace,
userspace gets "Replace failed, hardware rollback was skipped" even
though no hardware state changed.
At this commit the path is still dead, because u32_change() passes flags
instead of userflags. It becomes reachable with the follow-up patch
"net/sched: cls_u32: feed u32_replace_hw_knode() with correct set of
flags".
> return err;
> }
>
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203124056.547555-1-jedrzej.jagielski%40intel.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-04 14:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 12:40 [PATCH net v4 0/5] net/sched: u32_change() fixes Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 1/5] net/sched: cls_u32: fix linked hash table refcount leak Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc() Jedrzej Jagielski
2026-12-04 14:02 ` netdev-bot+sashiko
2026-12-03 12:40 ` [PATCH net v4 3/5] net/sched: cls_u32: don't remove old HW rule on failed knode replace Jedrzej Jagielski
2026-12-04 14:02 ` netdev-bot+sashiko
2026-12-03 12:40 ` [PATCH net v4 4/5] net/sched: cls_u32: feed u32_replace_hw_knode() with correct set of flags Jedrzej Jagielski
2026-12-03 12:40 ` [PATCH net v4 5/5] selftests: tc-testing: add u32 skip_sw test Jedrzej Jagielski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox