Commit f72514b3 authored by Fernando Fernandez Mancera's avatar Fernando Fernandez Mancera Committed by Jakub Kicinski
Browse files

ipv6: clear RA flags when adding a static route



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: 14ef37b6 ("ipv6: fix route lookup in addrconf_prefix_rcv()")
Reported-by: default avatarGarri Djavadyan <g.djavadyan@gmail.com>
Closes: https://lore.kernel.org/netdev/ba807d39aca5b4dcf395cc11dca61a130a52cfd3.camel@gmail.com/


Signed-off-by: default avatarFernando Fernandez Mancera <fmancera@suse.de>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20251115095939.6967-1-fmancera@suse.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cbf4d314
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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,