Commit 4a8473955a for frr
commit 4a8473955a793ad8f064c860fbc0546880a055c7
Author: Rajesh Varatharaj <rvaratharaj@nvidia.com>
Date: Sat May 30 17:44:27 2026 -0700
zebra: send deprecate RA (lifetime=0) before removing SLAAC prefix
When a SLAAC prefix is removed from the RA prefix list (via CLI
or kernel address deletion), FRR silently drops it from the RB-tree
without notifying hosts. Hosts keep the stale SLAAC address until
the previously advertised valid-lifetime expires (default 30 days).
This matters wherever the prefix on a port is replaced while its hosts
stay attached: without a deprecation signal, a host retains the old
address for 30 days alongside the new one.
Fix by sending one RA with valid-lifetime=0 and preferred-lifetime=0
for the prefix being removed, before deleting it from the RB-tree.
Per RFC 4862 Section 5.5.3, the host immediately deprecates the
address (preferred-lifetime=0) and clamps valid-lifetime to 2 hours
(DoS floor), after which the address is removed entirely.
Skip the deprecate RA on global RA cease (rtadv_stop_ra_all), which
already sends router-lifetime=0 per RFC 4861 Section 6.2.5.
A kernel address deletion retires its prefix only once no other
address on the interface is in it. Removing one of two addresses in
the same prefix used to drop the entry while the other address still
served it, and with the deprecation added here hosts would also lose
their addresses in a prefix the link still carries.
Before fix (host retains old address for 30 days):
2001:db8:0:2::.../64 scope global dynamic (new)
2001:db8:0:1::.../64 scope global dynamic (old, 30 days)
After fix (old address deprecated immediately, removed in ~2 hours):
2001:db8:0:2::.../64 scope global dynamic (new)
2001:db8:0:1::.../64 scope global deprecated (old, pref=0, ~2h)
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 7e2032f05a..67764f4323 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -1352,7 +1352,7 @@ static struct rtadv_prefix *rtadv_prefix_set(struct zebra_if *zif,
}
static void rtadv_prefix_reset(struct zebra_if *zif, struct rtadv_prefix *rp,
- struct rtadv_prefix *rprefix)
+ struct rtadv_prefix *rprefix, bool deprecate)
{
if (!rprefix)
rprefix = rtadv_prefixes_find(zif->rtadv.prefixes, rp);
@@ -1386,6 +1386,24 @@ static void rtadv_prefix_reset(struct zebra_if *zif, struct rtadv_prefix *rp,
}
}
+ /*
+ * Best-effort: before dropping a SLAAC prefix, tell hosts to
+ * stop using it by advertising it once with preferred/valid
+ * lifetime 0 (deprecate). Skipped on global RA cease, which
+ * already signals router-lifetime 0 per RFC 4861 6.2.5.
+ */
+ if (deprecate && zif->rtadv.AdvSendAdvertisements &&
+ rprefix->AdvAutonomousFlag) {
+ struct zebra_vrf *zvrf =
+ rtadv_interface_get_zvrf(zif->ifp);
+
+ rprefix->AdvPreferredLifetime = 0;
+ rprefix->AdvValidLifetime = 0;
+ if (zvrf)
+ rtadv_send_packet(zvrf->rtadv.sock, zif->ifp,
+ RA_ENABLE);
+ }
+
rtadv_prefixes_del(zif->rtadv.prefixes, rprefix);
rtadv_prefix_free(rprefix);
}
@@ -1405,7 +1423,7 @@ void rtadv_delete_prefix_manual(struct zebra_if *zif,
rp.AdvPrefixCreate = PREFIX_SRC_MANUAL;
- rtadv_prefix_reset(zif, &rp, rprefix);
+ rtadv_prefix_reset(zif, &rp, rprefix, true);
}
/* Add IPv6 prefixes learned from the kernel to the RA prefix list */
@@ -1423,11 +1441,24 @@ void rtadv_add_prefix(struct zebra_if *zif, const struct prefix_ipv6 *p)
void rtadv_delete_prefix(struct zebra_if *zif, const struct prefix *p)
{
struct rtadv_prefix rp;
+ struct connected *ifc;
+
+ /*
+ * Another address on the interface may still be in this prefix. The
+ * link still serves it then, so it stays advertised, and retiring it
+ * would deprecate the addresses hosts formed from it. The address
+ * being deleted is still on the list at this point.
+ */
+ frr_each (if_connected, zif->ifp->connected, ifc) {
+ if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL) && prefix_cmp(ifc->address, p) == 0 &&
+ !prefix_same(ifc->address, p))
+ return;
+ }
rp.prefix = *((struct prefix_ipv6 *)p);
apply_mask_ipv6(&rp.prefix);
rp.AdvPrefixCreate = PREFIX_SRC_AUTO;
- rtadv_prefix_reset(zif, &rp, NULL);
+ rtadv_prefix_reset(zif, &rp, NULL, true);
}
static void rtadv_start_interface_events(struct zebra_vrf *zvrf,
@@ -1677,7 +1708,7 @@ void rtadv_stop_ra_all(void)
frr_each_safe (rtadv_prefixes, zif->rtadv.prefixes,
rprefix)
- rtadv_prefix_reset(zif, rprefix, rprefix);
+ rtadv_prefix_reset(zif, rprefix, rprefix, false);
rtadv_stop_ra(ifp, false);
}