From: Victor Nogueira <victor@mojatatu.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, jhs@mojatatu.com, jiri@resnulli.us
Cc: horms@kernel.org, vega@nebusec.ai, netdev@vger.kernel.org
Subject: [PATCH net v2 0/4] net/sched: cls_route: fix bucket retention and handle recomputation
Date: Mon, 7 Sep 2026 16:21:29 -0300 [thread overview]
Message-ID: <20260907192133.2639067-1-victor@mojatatu.com> (raw)
Patch 1 is the v1 patch, unchanged. route4_change() can move an existing
filter to a different top-level bucket, since route4_set_parms()
recomputes the handle from TCA_ROUTE4_TO/FROM/IIF. The filter is
unlinked from the old bucket, but the bucket itself is never freed once
it goes empty, so route4_delete() keeps reporting *last=false after the
last live filter is gone. That pins the empty tcf_proto and leaks it.
The filters linked to a bucket are refcounted now, and the bucket is
dropped from head->table[] as soon as the count reaches zero.
Reviewing v1, Sashiko pointed out that the duplicate scan in
route4_set_parms() compares against the wrong handle [1]. Patches 2 and
3 fix the two symptoms of that.
Patch 2 makes the scan compare against nhandle. f->handle is the handle
the filter has before the update, not the one it is about to be linked
under, so a change that moves a filter into a chain already holding
nhandle misses the collision and links a second filter under the same
handle. The newcomer is then unreachable: route4_get() returns the
incumbent, and route4_classify() stops at the first filter whose f->id
matches.
Patch 3 handles the mirror case. An in-place replace computes an nhandle
that the filter being replaced already carries, so the scan finds that
filter and rejects the request with -EEXIST. The older filter is passed
to route4_set_parms() and skipped in the scan. Skipping it alone would
rename the filter it replaces: the 0x7F00 order bits are carried in no
attribute and were folded into nhandle on the create path alone, so an
order 1 filter came back as order 0, and a sibling sharing its key could
then no longer be replaced at all. They are carried over now whenever
the request builds the key the filter already has, which leaves a
request that does change the key renaming the filter as before.
Patch 4 adds tdc coverage for all three, including the cross-bucket move
case Sashiko noted route.json had no test for.
[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260829205422.854785-1-victor%40mojatatu.com
v1 -> v2:
- Added patches 2, 3 and 4. Patch 1 is unchanged.
Victor Nogueira (4):
net/sched: cls_route: free emptied bucket on filter move
net/sched: cls_route: Reject handle aliasing
net/sched: cls_route: Fix in-place replace
selftests/tc-testing: Add cls_route bucket move and change tests
net/sched/cls_route.c | 76 ++++---
.../tc-testing/tc-tests/filters/route.json | 210 ++++++++++++++++++
2 files changed, 249 insertions(+), 37 deletions(-)
--
2.55.0
next reply other threads:[~2026-09-07 19:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 19:21 Victor Nogueira [this message]
2026-09-07 19:21 ` [PATCH net v2 1/4] net/sched: cls_route: free emptied bucket on filter move Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 2/4] net/sched: cls_route: Reject handle aliasing Victor Nogueira
2026-09-09 10:22 ` netdev-bot+sashiko
2026-09-10 9:27 ` Paolo Abeni
2026-09-10 12:59 ` Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 3/4] net/sched: cls_route: Fix in-place replace Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 4/4] selftests/tc-testing: Add cls_route bucket move and change tests Victor Nogueira
2026-09-10 9:30 ` [PATCH net v2 0/4] net/sched: cls_route: fix bucket retention and handle recomputation patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907192133.2639067-1-victor@mojatatu.com \
--to=victor@mojatatu.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vega@nebusec.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.