RFC net: fix route flush for routes using nexthop objects
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | net: accept legacy nexthop attributes when deleting by nexthop idnet/ net/ | +27 | 0 replies | |
| 2/3 | ipv4: accept the reported route type when deleting a blackhole nexthop routenet/ net/ net/ | +16 | 0 replies | |
| 3/3 | selftests: fib_nexthops: test route flush with nexthop objectstools/ | +126 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC net-next 0/3] net: fix route flush for routes using nexthop objects
"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(-)
Signature · 1 line
2.53.0