🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
5 messages
5 total messages Started by Yuen Su Wed, 18 Nov 2026 08:45
[PATCH net 0/2] ipv4: allow route dump replay with nexthop IDs
#18375
Author: Yuen Su
Date: Wed, 18 Nov 2026 08:45
33 lines
11826 bytes
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
[PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes
#18376
Author: Yuen Su
Date: Wed, 18 Nov 2026 08:45
53 lines
12870 bytes
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,
[PATCH net 2/2] selftests: net: test flushing IPv4 nexthop routes in compat mode
#18377
Author: Yuen Su
Date: Wed, 18 Nov 2026 08:45
32 lines
12237 bytes
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
Re: [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes
#19234
Author: David Ahern
Date: Thu, 19 Nov 2026 15:47
22 lines
8824 bytes
On 11/18/26 2:45 AM, Yuen Su wrote:
> 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,

as the error message at this point shows, the 2 specifications must be
mutually exclusive. iproute2 will need to strip the nh_id or the nexthop
spec.
Re: [PATCH net 1/2] ipv4: accept nexthop dump attributes in route deletes
#20388
Author: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 09:50
128 lines
12501 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch fixes `ip route flush` of nexthop-object routes for
  IPv4 only.
- [Low] The commit message says the failure occurs "with nexthop
  compatibility mode enabled" and gives a reproducer "in a fresh network…

--

ipv4: accept nexthop dump attributes in route deletes

This commit skips the check in rtm_to_fib_config() that makes RTA_NH_ID
and the expanded nexthop attributes mutually exclusive, but only for
RTM_DELROUTE requests. This lets ip route flush delete routes that use
nexthop objects when the dump carries both. The check stays in place for
RTM_NEWROUTE.

Link: https://lists.openwall.net/netdev/2026/10/26/186

> 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.

[ ... ]

> report below. An unmodified kernel and iproute2 reproduced it without
> fault injection in a fresh network namespace with compatibility mode
> enabled.

[Severity: Low]
This isn't a bug, but "with nexthop compatibility mode enabled" reads like
an opt-in setting. Isn't compat mode already on by default in every network
namespace?

net/ipv4/af_inet.c:inet_init_net() {
    ...
	net->ipv4.sysctl_nexthop_compat_mode = 1;
    ...
}

fib_dump_info() leaves out the expanded attributes only when compat mode
has been set to 0, so default configurations hit this bug.

Could the commit message say that default configurations are affected? That
would help with stable triage.

> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index 8c123b111b3d8..6b012c8c6ea30 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,

[Severity: High]
Does IPv6 need the same change? rtm_to_fib6_config() in net/ipv6/route.c
still runs this check for every message type, including RTM_DELROUTE:

net/ipv6/route.c:rtm_to_fib6_config() {
    ...
	if (tb[RTA_NH_ID]) {
		if (tb[RTA_GATEWAY]   || tb[RTA_OIF] ||
		    tb[RTA_MULTIPATH] || tb[RTA_ENCAP]) {
			NL_SET_ERR_MSG(extack,
				       "Nexthop specification and nexthop id are mutually exclusive");
			goto errout;
		}
		cfg->fc_nh_id = nla_get_u32(tb[RTA_NH_ID]);
	}
    ...
}

err is already -EINVAL at this point.

In compat mode, rt6_fill_node() adds RTA_NH_ID to the dump and then calls
rt6_fill_node_nexthop(). For a group, that adds RTA_MULTIPATH. For a single
nexthop, fib_nexthop_info() adds RTA_OIF, plus RTA_GATEWAY when there is a
gateway. IPv6 nexthops always have a device, so RTA_OIF is always there.

When iproute2 sends that message back as RTM_DELROUTE, won't ip -6 route
flush on nhid routes fail with -EINVAL the same way, and leave the routes
installed?

ip6_route_del() already matches on the nexthop ID:

	if (rt->nh && cfg->fc_nh_id &&
	    rt->nh->id != cfg->fc_nh_id)
		continue;

It also skips routes without a nexthop object when fc_nh_id is set. That
suggests the same RTM_DELROUTE exemption would be safe in
rtm_to_fib6_config().

The commit message also says:

    The IPv4 group and IPv6 compatibility selftests also passed with the fix.

This could be read as saying IPv6 is not affected. However, those selftests
never run ip -6 route flush, and this patch leaves the IPv6 path unchanged.

The later patch in the series ("selftests: net: test flushing IPv4 nexthop
routes in compat mode") also covers only IPv4 and does not touch
net/ipv6/route.c.

Could the series be extended to cover the IPv6 parser too?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118084510.332821-1-zypulsecore%40gmail.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads