mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] ipv6: fix prefix route expiry in modify_prefix_route()
@ 2026-09-23 13:20 Qishuai Liu
  2026-09-24  1:18 ` Hangbin Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Qishuai Liu @ 2026-09-23 13:20 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel, Qishuai Liu

modify_prefix_route() is given the lifetime in clock_t relative to now,
but fib6_set_expires() wants an absolute jiffies value. So when a
permanent address is changed to a finite valid_lft, the prefix route
ends up already expired and GC removes it.

Steps to reproduce:

  ip link add dummy9 type dummy
  ip link set dummy9 up
  ip -6 addr add 2001:db8:9::1/64 dev dummy9
  ip -6 addr change 2001:db8:9::1/64 dev dummy9 valid_lft 3600 preferred_lft 3600
  ip -6 route show dev dummy9    # expires is negative

Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
Signed-off-by: Qishuai Liu <lqs@lqs.me>
---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9d89be7e0544..c90ee6dd7446 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4874,7 +4874,7 @@ static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp,
 			fib6_clean_expires(f6i);
 			fib6_may_remove_gc_list(net, f6i);
 		} else {
-			fib6_set_expires(f6i, expires);
+			fib6_set_expires(f6i, jiffies + clock_t_to_jiffies(expires));
 			fib6_add_gc_list(f6i);
 		}
 
-- 
2.43.0


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

* Re: [PATCH net] ipv6: fix prefix route expiry in modify_prefix_route()
  2026-09-23 13:20 [PATCH net] ipv6: fix prefix route expiry in modify_prefix_route() Qishuai Liu
@ 2026-09-24  1:18 ` Hangbin Liu
  2026-09-24  3:35   ` Qishuai Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2026-09-24  1:18 UTC (permalink / raw)
  To: Qishuai Liu
  Cc: netdev, dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel

On Wed, Sep 23, 2026 at 01:20:48PM +0000, Qishuai Liu wrote:
> modify_prefix_route() is given the lifetime in clock_t relative to now,
> but fib6_set_expires() wants an absolute jiffies value. So when a
> permanent address is changed to a finite valid_lft, the prefix route
> ends up already expired and GC removes it.
> 
> Steps to reproduce:
> 
>   ip link add dummy9 type dummy
>   ip link set dummy9 up
>   ip -6 addr add 2001:db8:9::1/64 dev dummy9
>   ip -6 addr change 2001:db8:9::1/64 dev dummy9 valid_lft 3600 preferred_lft 3600
>   ip -6 route show dev dummy9    # expires is negative

nit: Does GC really removes it? I see the expires is negative, but the time
seems overflow and GC won't remove it.

> 
> Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
> Signed-off-by: Qishuai Liu <lqs@lqs.me>
> ---
>  net/ipv6/addrconf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 9d89be7e0544..c90ee6dd7446 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -4874,7 +4874,7 @@ static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp,
>  			fib6_clean_expires(f6i);
>  			fib6_may_remove_gc_list(net, f6i);
>  		} else {
> -			fib6_set_expires(f6i, expires);
> +			fib6_set_expires(f6i, jiffies + clock_t_to_jiffies(expires));
>  			fib6_add_gc_list(f6i);
>  		}

The code looks good to me.

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>

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

* Re: [PATCH net] ipv6: fix prefix route expiry in modify_prefix_route()
  2026-09-24  1:18 ` Hangbin Liu
@ 2026-09-24  3:35   ` Qishuai Liu
  2026-09-24 11:27     ` Hangbin Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Qishuai Liu @ 2026-09-24  3:35 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: netdev, dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel

On Thu, Sep 24, 2026 at 10:18 AM Hangbin Liu <hangbin.liu@linux.dev> wrote:
>
> On Wed, Sep 23, 2026 at 01:20:48PM +0000, Qishuai Liu wrote:
> > modify_prefix_route() is given the lifetime in clock_t relative to now,
> > but fib6_set_expires() wants an absolute jiffies value. So when a
> > permanent address is changed to a finite valid_lft, the prefix route
> > ends up already expired and GC removes it.
>
> nit: Does GC really removes it? I see the expires is negative, but the time
> seems overflow and GC won't remove it.

Yes, it is removed once the fib6 GC runs, i.e. within gc_interval if
the GC timer is already armed by another expiring route, or right away
with "sysctl -w net.ipv6.route.flush=1".

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

* Re: [PATCH net] ipv6: fix prefix route expiry in modify_prefix_route()
  2026-09-24  3:35   ` Qishuai Liu
@ 2026-09-24 11:27     ` Hangbin Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Hangbin Liu @ 2026-09-24 11:27 UTC (permalink / raw)
  To: Qishuai Liu
  Cc: netdev, dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel

On Thu, Sep 24, 2026 at 12:35:18PM +0900, Qishuai Liu wrote:
> On Thu, Sep 24, 2026 at 10:18 AM Hangbin Liu <hangbin.liu@linux.dev> wrote:
> >
> > On Wed, Sep 23, 2026 at 01:20:48PM +0000, Qishuai Liu wrote:
> > > modify_prefix_route() is given the lifetime in clock_t relative to now,
> > > but fib6_set_expires() wants an absolute jiffies value. So when a
> > > permanent address is changed to a finite valid_lft, the prefix route
> > > ends up already expired and GC removes it.
> >
> > nit: Does GC really removes it? I see the expires is negative, but the time
> > seems overflow and GC won't remove it.
> 
> Yes, it is removed once the fib6 GC runs, i.e. within gc_interval if
> the GC timer is already armed by another expiring route, or right away
> with "sysctl -w net.ipv6.route.flush=1".

Ah, yes.

Thanks
Hangbin

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

end of thread, other threads:[~2026-09-24 11:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 13:20 [PATCH net] ipv6: fix prefix route expiry in modify_prefix_route() Qishuai Liu
2026-09-24  1:18 ` Hangbin Liu
2026-09-24  3:35   ` Qishuai Liu
2026-09-24 11:27     ` Hangbin Liu

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

all inboxes | Powered by JetHome®