* [PATCH net 0/2] ipv4: allow route dump replay with nexthop IDs
@ 2026-11-18 8:45 Yuen Su
2026-11-18 8:45 ` [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes Yuen Su
2026-11-18 8:45 ` [PATCH net 2/2] selftests: net: test flushing IPv4 nexthop routes in compat mode Yuen Su
0 siblings, 2 replies; 4+ messages in thread
From: Yuen Su @ 2026-11-18 8:45 UTC (permalink / raw)
To: netdev
Cc: David Ahern, Ido Schimmel, Stephen Hemminger, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan, linux-kselftest, linux-kernel, linux-api
IPv4 route flush fails when a route dump includes both a nexthop ID
and its expanded compatibility attributes. This series fixes the
IPv4 kernel delete path so that existing iproute2 can reuse the dump.
If a delete supplies RTA_NH_ID, the ID determines the nexthop match.
The first patch limits the mutual exclusion check to operations other
than deletion. The second adds a regression case to the existing IPv4
compatibility test. The route type and IPv6 changes discussed in the
earlier iproute2 thread are outside this series.
In QEMU/KVM, with the same unmodified iproute2, the new flush and
route removal checks failed on the base kernel and passed with the
fix. The three selected kselftests passed all 36 checks with the fix.
Codex helped extract the IPv4 kernel fix from the earlier iproute2
investigation, add the test and run the baseline and patched guests.
Earlier iproute2 discussion
https://lists.openwall.net/netdev/2026/10/26/186
Yuen
Yuen Su (2):
ipv4: accept nexthop dump attributes in route deletes
selftests: net: test flushing IPv4 nexthop routes in compat mode
net/ipv4/fib_frontend.c | 5 ++++-
tools/testing/selftests/net/fib_nexthops.sh | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
base-commit: 2a324a58a084c5cfd7e5a2f55e0786bee170a4a5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes
2026-11-18 8:45 [PATCH net 0/2] ipv4: allow route dump replay with nexthop IDs Yuen Su
@ 2026-11-18 8:45 ` Yuen Su
2026-11-18 12:21 ` Ido Schimmel
2026-11-18 8:45 ` [PATCH net 2/2] selftests: net: test flushing IPv4 nexthop routes in compat mode Yuen Su
1 sibling, 1 reply; 4+ messages in thread
From: Yuen Su @ 2026-11-18 8:45 UTC (permalink / raw)
To: netdev
Cc: David Ahern, Ido Schimmel, Stephen Hemminger, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan, linux-kselftest, linux-kernel, linux-api
ip route flush reuses route dump messages as RTM_DELROUTE requests.
With nexthop compatibility mode enabled, the dump includes RTA_NH_ID
alongside expanded nexthop attributes. rtm_to_fib_config() rejects the
combination with -EINVAL, leaving the routes installed.
Skip the mutual exclusion check for RTM_DELROUTE. fib_nh_match()
already uses the ID to match the nexthop when an ID is supplied, so
the expanded fields do not constrain that match. Keep the validation
for RTM_NEWROUTE and leave the other delete selectors intact.
The failure was reproduced while investigating the iproute2 flush
report below. An unmodified kernel and iproute2 reproduced it without
fault injection in a fresh network namespace with compatibility mode
enabled.
ip link add d0 type dummy
ip link set d0 up
ip -4 nexthop add id 101 via 192.0.2.1 dev d0 onlink
ip -4 route add 198.51.100.0/24 table 1111 nhid 101 metric 10
ip -4 route flush table 1111 metric 10
Verified the flush and the existing new-route validation in QEMU/KVM.
The IPv4 compatibility selftest reproduced the failure on the base
kernel and passed with the fix. The IPv4 group and IPv6 compatibility
selftests also passed with the fix.
Codex assisted with isolating the IPv4 delete change, writing the
regression test and running the QEMU comparisons.
Fixes: 493ced1ac47c ("ipv4: Allow routes to use nexthop objects")
Link: https://lists.openwall.net/netdev/2026/10/26/186
Signed-off-by: Yuen Su <zypulsecore@gmail.com>
---
net/ipv4/fib_frontend.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 8c123b1..6b012c8 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -868,7 +868,10 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
goto errout;
}
- if (cfg->fc_nh_id) {
+ /* Dumps can include both a nexthop ID and compatibility attributes.
+ * On deletion, fib_nh_match() uses the ID to match the nexthop.
+ */
+ if (cfg->fc_nh_id && nlh->nlmsg_type != RTM_DELROUTE) {
if (cfg->fc_oif || cfg->fc_gw_family ||
cfg->fc_encap || cfg->fc_mp) {
NL_SET_ERR_MSG(extack,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net 2/2] selftests: net: test flushing IPv4 nexthop routes in compat mode
2026-11-18 8:45 [PATCH net 0/2] ipv4: allow route dump replay with nexthop IDs Yuen Su
2026-11-18 8:45 ` [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes Yuen Su
@ 2026-11-18 8:45 ` Yuen Su
1 sibling, 0 replies; 4+ messages in thread
From: Yuen Su @ 2026-11-18 8:45 UTC (permalink / raw)
To: netdev
Cc: David Ahern, Ido Schimmel, Stephen Hemminger, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan, linux-kselftest, linux-kernel, linux-api
Exercise ip route flush on a route with a nexthop group while the dump
includes both the group's ID and the expanded paths. Check that the
flush succeeds and that the route is gone.
Both checks fail before the IPv4 delete fix and pass after it in a
QEMU/KVM guest with unmodified iproute2. Codex assisted with adding
the case to the existing compatibility selftest and running it.
Signed-off-by: Yuen Su <zypulsecore@gmail.com>
---
tools/testing/selftests/net/fib_nexthops.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
index adbec51..d3c8cf8 100755
--- a/tools/testing/selftests/net/fib_nexthops.sh
+++ b/tools/testing/selftests/net/fib_nexthops.sh
@@ -2183,6 +2183,13 @@ ipv4_compat_mode()
stop_ip_monitor $ipmout 3
log_test $? 0 "IPv4 compat mode on - nexthop change"
+ run_cmd "$IP route add 192.0.2.1/32 nhid 122"
+ log_test $? 0 "IPv4 compat mode on - add route for flush"
+ run_cmd "$IP route flush to exact 192.0.2.1/32"
+ log_test $? 0 "IPv4 compat mode on - route flush"
+ check_route "192.0.2.1" ""
+ log_test $? 0 "IPv4 compat mode on - route removed by flush"
+
sysctl_nexthop_compat_mode_set 0 "IPv4"
# cleanup
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes
2026-11-18 8:45 ` [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes Yuen Su
@ 2026-11-18 12:21 ` Ido Schimmel
0 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2026-11-18 12:21 UTC (permalink / raw)
To: Yuen Su
Cc: netdev, David Ahern, Stephen Hemminger, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan, linux-kselftest, linux-kernel, linux-api
On Wed, Nov 18, 2026 at 04:45:09PM +0800, Yuen Su wrote:
> ip route flush reuses route dump messages as RTM_DELROUTE requests.
That's an iproute2 design choice. Where does it say that the kernel has
to accept netlink messages that it dumped when they are delivered as
requests (potentially with a different type, as in this case:
RTM_NEWROUTE -> RTM_DELROUTE)?
I assume it was implemented this way because it was easy / convenient,
but you can tell that it doesn't make sense by how fragile it is.
Another example (that wasn't accepted):
https://lore.kernel.org/netdev/20260923-lwt-encap-noflag-v1-0-8de7ab6c86e9@gmail.com/
> With nexthop compatibility mode enabled, the dump includes RTA_NH_ID
> alongside expanded nexthop attributes. rtm_to_fib_config() rejects the
> combination with -EINVAL, leaving the routes installed.
OK, but why do you need this compatibility mode in the first place and
you're not simply disabling it like most production systems that are
using nexthop objects?
Note that iproute2 can include the necessary information in route dumps
even when the compatibility mode is disabled (with -d):
# sysctl -wq net.ipv4.nexthop_compat_mode=0
# ip route show
192.0.2.0/24 nhid 1
# ip -d route show
unicast 192.0.2.0/24 nhid 1 proto boot scope global
nh_info id 1 dev dummy1 scope host proto unspec
# ip nexthop
id 1 dev dummy1 scope host
Is this patch motivated by an actual use case or an LLM report?
>
> Skip the mutual exclusion check for RTM_DELROUTE. fib_nh_match()
> already uses the ID to match the nexthop when an ID is supplied, so
> the expanded fields do not constrain that match. Keep the validation
> for RTM_NEWROUTE and leave the other delete selectors intact.
This leaves save / restore broken.
>
> The failure was reproduced while investigating the iproute2 flush
> report below. An unmodified kernel and iproute2 reproduced it without
> fault injection in a fresh network namespace with compatibility mode
> enabled.
>
> ip link add d0 type dummy
> ip link set d0 up
> ip -4 nexthop add id 101 via 192.0.2.1 dev d0 onlink
> ip -4 route add 198.51.100.0/24 table 1111 nhid 101 metric 10
> ip -4 route flush table 1111 metric 10
>
> Verified the flush and the existing new-route validation in QEMU/KVM.
> The IPv4 compatibility selftest reproduced the failure on the base
> kernel and passed with the fix. The IPv4 group and IPv6 compatibility
> selftests also passed with the fix.
>
> Codex assisted with isolating the IPv4 delete change, writing the
> regression test and running the QEMU comparisons.
>
> Fixes: 493ced1ac47c ("ipv4: Allow routes to use nexthop objects")
Not a regression, never worked. If anything it should be targeted at
net-next, but I don't think that such patches should be accepted. The
fix belongs in iproute2.
> Link: https://lists.openwall.net/netdev/2026/10/26/186
> Signed-off-by: Yuen Su <zypulsecore@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-18 12:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 8:45 [PATCH net 0/2] ipv4: allow route dump replay with nexthop IDs Yuen Su
2026-11-18 8:45 ` [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes Yuen Su
2026-11-18 12:21 ` Ido Schimmel
2026-11-18 8:45 ` [PATCH net 2/2] selftests: net: test flushing IPv4 nexthop routes in compat mode Yuen Su
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox