* [PATCH net] ipv6: clear RA flags when adding a static route
@ 2025-11-10 23:04 Fernando Fernandez Mancera
2025-11-13 12:03 ` Paolo Abeni
0 siblings, 1 reply; 4+ messages in thread
From: Fernando Fernandez Mancera @ 2025-11-10 23:04 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>
---
Note: this has been broken probably since forever but I belive the
commit in the fixes tag was aiming to fix this too. Anyway, any
recommendation for a fixes tag is welcomed.
---
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.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] ipv6: clear RA flags when adding a static route
2025-11-10 23:04 [PATCH net] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
@ 2025-11-13 12:03 ` Paolo Abeni
2025-11-13 12:15 ` Fernando Fernandez Mancera
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2025-11-13 12:03 UTC (permalink / raw)
To: Fernando Fernandez Mancera, netdev
Cc: davem, dsahern, edumazet, kuba, horms, Garri Djavadyan
On 11/11/25 12:04 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>
> ---
> Note: this has been broken probably since forever but I belive the
> commit in the fixes tag was aiming to fix this too. Anyway, any
> recommendation for a fixes tag is welcomed.
> ---
> 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,
The patch makes sense to me, but I don't want to rush it in the net PR
I'm going to send soon. Also it would be great to have self-test
covering this case, could you have a reasonable shot at it?
Thanks.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] ipv6: clear RA flags when adding a static route
2025-11-13 12:03 ` Paolo Abeni
@ 2025-11-13 12:15 ` Fernando Fernandez Mancera
2025-11-13 12:23 ` Paolo Abeni
0 siblings, 1 reply; 4+ messages in thread
From: Fernando Fernandez Mancera @ 2025-11-13 12:15 UTC (permalink / raw)
To: Paolo Abeni, netdev
Cc: davem, dsahern, edumazet, kuba, horms, Garri Djavadyan
On 11/13/25 1:03 PM, Paolo Abeni wrote:
> On 11/11/25 12:04 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>
>> ---
>> Note: this has been broken probably since forever but I belive the
>> commit in the fixes tag was aiming to fix this too. Anyway, any
>> recommendation for a fixes tag is welcomed.
>> ---
>> 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,
>
> The patch makes sense to me, but I don't want to rush it in the net PR
> I'm going to send soon. Also it would be great to have self-test
> covering this case, could you have a reasonable shot at it?
>
Sure, I am fine with aiming this for net-next instead if you consider it
safer.
Thanks,
Fernando.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] ipv6: clear RA flags when adding a static route
2025-11-13 12:15 ` Fernando Fernandez Mancera
@ 2025-11-13 12:23 ` Paolo Abeni
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2025-11-13 12:23 UTC (permalink / raw)
To: Fernando Fernandez Mancera, netdev
Cc: davem, dsahern, edumazet, kuba, horms, Garri Djavadyan
On 11/13/25 1:15 PM, Fernando Fernandez Mancera wrote:
> On 11/13/25 1:03 PM, Paolo Abeni wrote:
>> On 11/11/25 12:04 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>
>>> ---
>>> Note: this has been broken probably since forever but I belive the
>>> commit in the fixes tag was aiming to fix this too. Anyway, any
>>> recommendation for a fixes tag is welcomed.
>>> ---
>>> 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,
>>
>> The patch makes sense to me, but I don't want to rush it in the net PR
>> I'm going to send soon. Also it would be great to have self-test
>> covering this case, could you have a reasonable shot at it?
>>
>
> Sure, I am fine with aiming this for net-next instead if you consider it
> safer.
Yep, net-next would be better, I think.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-13 12:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 23:04 [PATCH net] ipv6: clear RA flags when adding a static route Fernando Fernandez Mancera
2025-11-13 12:03 ` Paolo Abeni
2025-11-13 12:15 ` Fernando Fernandez Mancera
2025-11-13 12:23 ` Paolo Abeni
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).