From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [RFC net-next 0/3] net: fix route flush for routes using nexthop objects
Date: Fri, 20 Nov 2026 12:01:27 -0800 [thread overview]
Message-ID: <20261120200635.95798-1-stephen@networkplumber.org> (raw)
"ip route flush" fails on any route that uses a nexthop object:
# ip nexthop add id 101 via 192.0.2.1 dev dummy0
# ip route add 203.0.113.0/24 nhid 101
# ip route flush to 203.0.113.0/24
Failed to send flush request: Invalid argument
The first attempt at fixing that was to modify iproute but
that is just working around a kernel bug. Flush should be
able to be done as dump-and-echo by flipping to set
RTM_DELROUTE. This always worked until nexthop compat mode
was introduced.
This series fixes thes by changing where fib handling
is done on delete. I don't use next hop id anywhere
so this is just a proposal.
Patch 1 ignores the legacy nexthop attributes on RTM_DELROUTE when
RTA_NH_ID is present, for both families. The id is already
authoritative in the matching code, so nothing downstream looks at the
fields being cleared. RTM_NEWROUTE stays strict.
Patch 2 accepts RTN_BLACKHOLE on delete when the alias uses a blackhole
nexthop object, so a route can be removed using the type the kernel
advertised. Dropping the dump-side rewrite instead would change what
every existing reader sees.
Patch 3 adds the selftest coverage that was missing. fib_nexthops.sh
exercises "ip nexthop flush" thoroughly but never "ip route flush"
against nhid routes, which is how the two paths drifted apart in the
first place.
Testing: the new tests fail 15 assertions against an unpatched kernel
and all 26 pass with the series applied, booted under qemu with
nexthop_compat_mode=1. The existing fib_nexthops cases, including the
legacy delete paths patch 1 must not disturb, still pass: 93
assertions across ipv4_fcnal, ipv6_fcnal, the compat_mode pair and the
fcnal_runtime pair.
Stephen Hemminger (3):
net: accept legacy nexthop attributes when deleting by nexthop id
ipv4: accept the reported route type when deleting a blackhole nexthop
route
selftests: fib_nexthops: test route flush with nexthop objects
net/ipv4/fib_frontend.c | 17 ++-
net/ipv4/fib_lookup.h | 1 +
net/ipv4/fib_semantics.c | 14 +++
net/ipv4/fib_trie.c | 2 +-
net/ipv6/route.c | 14 ++-
tools/testing/selftests/net/fib_nexthops.sh | 126 ++++++++++++++++++++
6 files changed, 169 insertions(+), 5 deletions(-)
--
2.53.0
next reply other threads:[~2026-11-20 20:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 20:01 Stephen Hemminger [this message]
2026-11-20 20:01 ` [RFC next-net 1/3] net: accept legacy nexthop attributes when deleting by nexthop id Stephen Hemminger
2026-11-20 20:01 ` [RFC next-net 2/3] ipv4: accept the reported route type when deleting a blackhole nexthop route Stephen Hemminger
2026-11-20 20:01 ` [RFC next-net 3/3] selftests: fib_nexthops: test route flush with nexthop objects Stephen Hemminger
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=20261120200635.95798-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox