* [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route
@ 2025-11-15 9:59 Fernando Fernandez Mancera
2025-11-15 9:59 ` [PATCH 2/2 net-next v2] selftests: fib_tests: add fib6 from ra to static test Fernando Fernandez Mancera
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Fernando Fernandez Mancera @ 2025-11-15 9:59 UTC (permalink / raw)
To: netdev
Cc: davem, dsahern, edumazet, kuba, pabeni, horms,
Fernando Fernandez Mancera, Garri Djavadyan
When an IPv6 Router Advertisement (RA) is received for a prefix, the
kernel creates the corresponding on-link route with flags RTF_ADDRCONF
and RTF_PREFIX_RT configured and RTF_EXPIRES if lifetime is set.
If later a user configures a static IPv6 address on the same prefix the
kernel clears the RTF_EXPIRES flag but it doesn't clear the RTF_ADDRCONF
and RTF_PREFIX_RT. When the next RA for that prefix is received, the
kernel sees the route as RA-learned and wrongly configures back the
lifetime. This is problematic because if the route expires, the static
address won't have the corresponding on-link route.
This fix clears the RTF_ADDRCONF and RTF_PREFIX_RT flags preventing that
the lifetime is configured when the next RA arrives. If the static
address is deleted, the route becomes RA-learned again.
Fixes: 14ef37b6d00e ("ipv6: fix route lookup in addrconf_prefix_rcv()")
Reported-by: Garri Djavadyan <g.djavadyan@gmail.com>
Closes: https://lore.kernel.org/netdev/ba807d39aca5b4dcf395cc11dca61a130a52cfd3.camel@gmail.com/
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
v2: rebase in top of net-next.git instead of net.git
---
net/ipv6/ip6_fib.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 02c16909f618..2111af022d94 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1138,6 +1138,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
fib6_set_expires(iter, rt->expires);
fib6_add_gc_list(iter);
}
+ if (!(rt->fib6_flags & (RTF_ADDRCONF | RTF_PREFIX_RT))) {
+ iter->fib6_flags &= ~RTF_ADDRCONF;
+ iter->fib6_flags &= ~RTF_PREFIX_RT;
+ }
if (rt->fib6_pmtu)
fib6_metric_set(iter, RTAX_MTU,
--
2.51.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2 net-next v2] selftests: fib_tests: add fib6 from ra to static test
2025-11-15 9:59 [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
@ 2025-11-15 9:59 ` Fernando Fernandez Mancera
2025-11-19 2:56 ` [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route David Ahern
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Fernando Fernandez Mancera @ 2025-11-15 9:59 UTC (permalink / raw)
To: netdev
Cc: davem, dsahern, edumazet, kuba, pabeni, horms,
Fernando Fernandez Mancera
The new test checks that a route that has been promoted from RA-learned
to static does not switch back when a new RA message arrives. In
addition, it checks that the route is owned by RA again when the static
address is removed.
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
v2: added this patch to the series
---
tools/testing/selftests/net/fib_tests.sh | 66 +++++++++++++++++++++++-
1 file changed, 65 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index a94b73a53f72..a88f797c549a 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -11,7 +11,8 @@ TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify \
ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics \
ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr \
ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test \
- ipv4_mpath_list ipv6_mpath_list ipv4_mpath_balance ipv6_mpath_balance"
+ ipv4_mpath_list ipv6_mpath_list ipv4_mpath_balance ipv6_mpath_balance \
+ fib6_ra_to_static"
VERBOSE=0
PAUSE_ON_FAIL=no
@@ -1476,6 +1477,68 @@ ipv6_route_metrics_test()
route_cleanup
}
+fib6_ra_to_static()
+{
+ setup
+
+ echo
+ echo "Fib6 route promotion from RA-learned to static test"
+ set -e
+
+ # ra6 is required for the test. (ipv6toolkit)
+ if [ ! -x "$(command -v ra6)" ]; then
+ echo "SKIP: ra6 not found."
+ set +e
+ cleanup &> /dev/null
+ return
+ fi
+
+ # Create a pair of veth devices to send a RA message from one
+ # device to another.
+ $IP link add veth1 type veth peer name veth2
+ $IP link set dev veth1 up
+ $IP link set dev veth2 up
+ $IP -6 address add 2001:10::1/64 dev veth1 nodad
+ $IP -6 address add 2001:10::2/64 dev veth2 nodad
+
+ # Make veth1 ready to receive RA messages.
+ $NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_ra=2
+
+ # Send a RA message with a prefix from veth2.
+ $NS_EXEC ra6 -i veth2 -d 2001:10::1 -P 2001:12::/64\#LA\#120\#60
+
+ # Wait for the RA message.
+ sleep 1
+
+ # systemd may mess up the test. Make sure that
+ # systemd-networkd.service and systemd-networkd.socket are stopped.
+ check_rt_num_clean 2 $($IP -6 route list|grep expires|wc -l) || return
+
+ # Configure static address on the same prefix
+ $IP -6 address add 2001:12::dead/64 dev veth1 nodad
+
+ # On-link route won't expire anymore, default route still owned by RA
+ check_rt_num 1 $($IP -6 route list |grep expires|wc -l)
+
+ # Send a second RA message with a prefix from veth2.
+ $NS_EXEC ra6 -i veth2 -d 2001:10::1 -P 2001:12::/64\#LA\#120\#60
+ sleep 1
+
+ # Expire is not back, on-link route is still static
+ check_rt_num 1 $($IP -6 route list |grep expires|wc -l)
+
+ $IP -6 address del 2001:12::dead/64 dev veth1 nodad
+
+ # Expire is back, on-link route is now owned by RA again
+ check_rt_num 2 $($IP -6 route list |grep expires|wc -l)
+
+ log_test $ret 0 "ipv6 promote RA route to static"
+
+ set +e
+
+ cleanup &> /dev/null
+}
+
# add route for a prefix, flushing any existing routes first
# expected to be the first step of a test
add_route()
@@ -2798,6 +2861,7 @@ do
ipv6_mpath_list) ipv6_mpath_list_test;;
ipv4_mpath_balance) ipv4_mpath_balance_test;;
ipv6_mpath_balance) ipv6_mpath_balance_test;;
+ fib6_ra_to_static) fib6_ra_to_static;;
help) echo "Test names: $TESTS"; exit 0;;
esac
--
2.51.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route
2025-11-15 9:59 [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
2025-11-15 9:59 ` [PATCH 2/2 net-next v2] selftests: fib_tests: add fib6 from ra to static test Fernando Fernandez Mancera
@ 2025-11-19 2:56 ` David Ahern
2025-11-19 3:30 ` patchwork-bot+netdevbpf
2025-12-10 15:55 ` Uwe Kleine-König
3 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2025-11-19 2:56 UTC (permalink / raw)
To: Fernando Fernandez Mancera, netdev
Cc: davem, edumazet, kuba, pabeni, horms, Garri Djavadyan
On 11/15/25 2:59 AM, Fernando Fernandez Mancera wrote:
> When an IPv6 Router Advertisement (RA) is received for a prefix, the
> kernel creates the corresponding on-link route with flags RTF_ADDRCONF
> and RTF_PREFIX_RT configured and RTF_EXPIRES if lifetime is set.
>
> If later a user configures a static IPv6 address on the same prefix the
> kernel clears the RTF_EXPIRES flag but it doesn't clear the RTF_ADDRCONF
> and RTF_PREFIX_RT. When the next RA for that prefix is received, the
> kernel sees the route as RA-learned and wrongly configures back the
> lifetime. This is problematic because if the route expires, the static
> address won't have the corresponding on-link route.
>
> This fix clears the RTF_ADDRCONF and RTF_PREFIX_RT flags preventing that
> the lifetime is configured when the next RA arrives. If the static
> address is deleted, the route becomes RA-learned again.
>
> Fixes: 14ef37b6d00e ("ipv6: fix route lookup in addrconf_prefix_rcv()")
> Reported-by: Garri Djavadyan <g.djavadyan@gmail.com>
> Closes: https://lore.kernel.org/netdev/ba807d39aca5b4dcf395cc11dca61a130a52cfd3.camel@gmail.com/
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
> ---
> v2: rebase in top of net-next.git instead of net.git
> ---
> net/ipv6/ip6_fib.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index 02c16909f618..2111af022d94 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -1138,6 +1138,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
> fib6_set_expires(iter, rt->expires);
> fib6_add_gc_list(iter);
> }
> + if (!(rt->fib6_flags & (RTF_ADDRCONF | RTF_PREFIX_RT))) {
> + iter->fib6_flags &= ~RTF_ADDRCONF;
> + iter->fib6_flags &= ~RTF_PREFIX_RT;
> + }
>
> if (rt->fib6_pmtu)
> fib6_metric_set(iter, RTAX_MTU,
Converting an RA route to a static route should be a very rare use case.
I can't find a reason why this is wrong, so:
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route
2025-11-15 9:59 [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
2025-11-15 9:59 ` [PATCH 2/2 net-next v2] selftests: fib_tests: add fib6 from ra to static test Fernando Fernandez Mancera
2025-11-19 2:56 ` [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route David Ahern
@ 2025-11-19 3:30 ` patchwork-bot+netdevbpf
2025-12-10 15:55 ` Uwe Kleine-König
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-19 3:30 UTC (permalink / raw)
To: Fernando Fernandez Mancera
Cc: netdev, davem, dsahern, edumazet, kuba, pabeni, horms,
g.djavadyan
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 15 Nov 2025 10:59:38 +0100 you wrote:
> When an IPv6 Router Advertisement (RA) is received for a prefix, the
> kernel creates the corresponding on-link route with flags RTF_ADDRCONF
> and RTF_PREFIX_RT configured and RTF_EXPIRES if lifetime is set.
>
> If later a user configures a static IPv6 address on the same prefix the
> kernel clears the RTF_EXPIRES flag but it doesn't clear the RTF_ADDRCONF
> and RTF_PREFIX_RT. When the next RA for that prefix is received, the
> kernel sees the route as RA-learned and wrongly configures back the
> lifetime. This is problematic because if the route expires, the static
> address won't have the corresponding on-link route.
>
> [...]
Here is the summary with links:
- [1/2,net-next,v2] ipv6: clear RA flags when adding a static route
https://git.kernel.org/netdev/net-next/c/f72514b3c569
- [2/2,net-next,v2] selftests: fib_tests: add fib6 from ra to static test
https://git.kernel.org/netdev/net-next/c/d7dbda878920
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route
2025-11-15 9:59 [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
` (2 preceding siblings ...)
2025-11-19 3:30 ` patchwork-bot+netdevbpf
@ 2025-12-10 15:55 ` Uwe Kleine-König
3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2025-12-10 15:55 UTC (permalink / raw)
To: Fernando Fernandez Mancera, Greg Kroah-Hartman
Cc: netdev, davem, dsahern, edumazet, kuba, pabeni, horms,
Garri Djavadyan, stable, 1117959
[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]
Hello,
On Sat, Nov 15, 2025 at 10:59:38AM +0100, Fernando Fernandez Mancera wrote:
> When an IPv6 Router Advertisement (RA) is received for a prefix, the
> kernel creates the corresponding on-link route with flags RTF_ADDRCONF
> and RTF_PREFIX_RT configured and RTF_EXPIRES if lifetime is set.
>
> If later a user configures a static IPv6 address on the same prefix the
> kernel clears the RTF_EXPIRES flag but it doesn't clear the RTF_ADDRCONF
> and RTF_PREFIX_RT. When the next RA for that prefix is received, the
> kernel sees the route as RA-learned and wrongly configures back the
> lifetime. This is problematic because if the route expires, the static
> address won't have the corresponding on-link route.
>
> This fix clears the RTF_ADDRCONF and RTF_PREFIX_RT flags preventing that
> the lifetime is configured when the next RA arrives. If the static
> address is deleted, the route becomes RA-learned again.
>
> Fixes: 14ef37b6d00e ("ipv6: fix route lookup in addrconf_prefix_rcv()")
> Reported-by: Garri Djavadyan <g.djavadyan@gmail.com>
> Closes: https://lore.kernel.org/netdev/ba807d39aca5b4dcf395cc11dca61a130a52cfd3.camel@gmail.com/
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
this commit is in the mainline now as
f72514b3c5698e4b900b25345e09f9ed33123de6 and is supposed to fix
https://bugs.debian.org/1117959.
I would have expected this to get backported to stable (here: 6.12.x),
but it's not in the list for 6.12.62-rc1[1].
Can we please have this patch backported?
[1] https://lore.kernel.org/all/20251210072948.125620687@linuxfoundation.org/
Thanks
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-10 15:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-15 9:59 [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
2025-11-15 9:59 ` [PATCH 2/2 net-next v2] selftests: fib_tests: add fib6 from ra to static test Fernando Fernandez Mancera
2025-11-19 2:56 ` [PATCH 1/2 net-next v2] ipv6: clear RA flags when adding a static route David Ahern
2025-11-19 3:30 ` patchwork-bot+netdevbpf
2025-12-10 15:55 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).