Netdev List
 help / color / mirror / Atom feed
* [RFC net-next 0/3] net: fix route flush for routes using nexthop objects
@ 2026-11-20 20:01 Stephen Hemminger
  2026-11-20 20:01 ` [RFC next-net 1/3] net: accept legacy nexthop attributes when deleting by nexthop id Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Hemminger @ 2026-11-20 20:01 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, Stephen Hemminger

"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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-20 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 20:01 [RFC net-next 0/3] net: fix route flush for routes using nexthop objects Stephen Hemminger
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox