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 may be partially updated.
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
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