Commit 2f1abf673f for frr

commit 2f1abf673f4cfbae6ca6bf779de334cc3346f3f3
Author: Rajesh Varatharaj <rvaratharaj@nvidia.com>
Date:   Wed Sep 2 13:30:08 2026 -0700

    zebra: add ipv6 nd prefix-lifetime

    FRR advertises the prefixes it derives from an interface's addresses
    with the RFC 4861 defaults, 2592000 seconds valid and 604800 preferred.
    A host that moves to a different port forms an address from whatever
    prefix that port advertises, and keeps it for thirty days after the move
    is corrected. Shortening that today means naming the prefix, which the
    operator does not necessarily know.

    Allow the lifetimes to be set once per interface. The rule is: a prefix
    that names its own lifetimes keeps them, everything else follows
    "ipv6 nd prefix-lifetime", and with that unset everything else takes the
    RFC 4861 values. Everything else covers both the prefixes derived from
    addresses on the interface and "ipv6 nd prefix" entries that left the
    lifetimes out; on a link where every prefix is configured explicitly
    the knob would otherwise apply to nothing. The rule lives in one helper
    that the re-stamp, the manual add and the address-derived defaults all
    call, so the three cannot drift apart.

    Both lifetime leaves of a prefix carry a YANG default, so their
    northbound callbacks fire whether or not the operator named them.
    yang_dnode_is_default() tells a named value from an implied one, which
    is the test the "ipv6 nd prefix" cli_write already uses to decide
    whether to print them back, so a pair equal to the RFC 4861 defaults
    counts as not named, matching what running-config shows. Removing an
    explicit pair hands the prefix back to the interface default rather
    than leaving the RFC values behind, which needs the interface at modify
    time. The leaf callbacks find it by starting nb_running_get_entry() at
    the prefix-list, as the pref64 callbacks do; from the leaf the walk
    would stop at the prefix's own entry.

    Both values must be given together because RFC 4861 4.6.2 has hosts
    discard a prefix option whose preferred lifetime exceeds its valid one,
    so taking one without the other would remove the prefix from
    autoconfiguration rather than shorten it.

    Changing the value re-stamps the prefixes already in the list. That is
    picked up by arming the existing fast-retransmit counter rather than
    sending inline, since a reload replays a value change as a delete
    followed by an add and an inline send would put the old lifetime on the
    wire in between.

    A short lifetime costs availability, because hosts lose the address
    whenever advertisements stop rather than riding it out. That is a
    deliberate trade, so it warns rather than rejects.

    Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>

diff --git a/doc/user/ipv6.rst b/doc/user/ipv6.rst
index 7a76486149..3598750cd4 100644
--- a/doc/user/ipv6.rst
+++ b/doc/user/ipv6.rst
@@ -88,6 +88,35 @@ Router Advertisement

      Default: not set, i.e. hosts do not assume a complete IP address is placed.

+.. clicmd:: ipv6 nd prefix-lifetime <valid-lifetime|infinite> <preferred-lifetime|infinite>
+
+   Lifetimes advertised for every prefix on the interface that does not name its
+   own, whether it was derived from an address configured on the interface or
+   came from an ``ipv6 nd prefix`` entry that left the lifetimes out. This avoids
+   having to name each prefix in order to shorten its lifetime.
+
+   A prefix whose ``ipv6 nd prefix`` entry gives lifetimes of its own carries
+   those and is not affected by this command. An entry that gives exactly the
+   RFC 4861 defaults, ``2592000`` and ``604800``, counts as giving none; the
+   running configuration leaves them out too.
+
+   Both values must be given. RFC 4861 section 4.6.2 requires hosts to discard a
+   prefix option whose preferred lifetime exceeds its valid lifetime, so
+   lowering one without the other would remove the prefix from stateless address
+   autoconfiguration entirely.
+
+   Note that RFC 4862 section 5.5.3 clamps the stored valid lifetime of an
+   address a host already holds to a minimum of two hours, so a value below
+   ``7200`` only takes full effect for addresses formed after the change.
+
+   A prefix lifetime shorter than a few advertisement intervals will cause a
+   host that misses an advertisement to lose the address, so ``ra-interval``
+   should be lowered alongside it. A warning is logged when the valid lifetime
+   is below three advertisement intervals.
+
+   Range: ``(0-4294967295)``  Default: not set, i.e. ``2592000`` and ``604800``
+   are used.
+
 .. clicmd:: ipv6 nd ra-interval [(1-1800)]

    The maximum time allowed between sending unsolicited multicast router
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang
index 845695a1f6..534532aa7d 100644
--- a/yang/frr-zebra.yang
+++ b/yang/frr-zebra.yang
@@ -2710,6 +2710,51 @@ module frr-zebra {
           reference
             "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
                        - AdvPrefixList";
+          container default-lifetimes {
+            presence "Lifetimes for prefixes that name none of their own.";
+            description
+              "Lifetimes advertised for every prefix on the
+              interface that does not carry lifetimes of its own,
+              whether it was derived from an address configured on
+              the interface or comes from an entry in the 'prefix'
+              list that left them out.
+
+              A prefix whose entry in that list gives its own
+              lifetimes carries those and is not affected. An entry
+              whose lifetimes both equal their defaults counts as
+              giving none.
+
+              When this container is absent the RFC 4861 defaults of
+              2592000 and 604800 seconds are used.";
+            leaf valid-lifetime {
+              type uint32;
+              units "seconds";
+              mandatory true;
+              description
+                "Value to be placed in the Valid Lifetime in the
+                Prefix Information option.  0xffffffff represents
+                infinity.";
+              reference
+                "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
+                           - AdvValidLifetime";
+            }
+            leaf preferred-lifetime {
+              type uint32;
+              units "seconds";
+              mandatory true;
+              must ". <= ../valid-lifetime" {
+                error-message
+                  "preferred-lifetime must not be greater than valid-lifetime";
+              }
+              description
+                "Value to be placed in the Preferred Lifetime in the
+                Prefix Information option.  0xffffffff represents
+                infinity.";
+              reference
+                "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
+                           - AdvPreferredLifetime";
+            }
+          }
           list prefix {
             key "prefix-spec";
             description
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index f6e7382ba5..26789ad8f3 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -1739,13 +1739,49 @@ static struct rtadv_prefix *rtadv_prefix_get(struct rtadv_prefixes_head *list,
 	return rprefix;
 }

-static void rtadv_prefix_set_defaults(struct rtadv_prefix *rp)
+/*
+ * Lifetimes for a prefix that named none of its own: "ipv6 nd prefix-lifetime"
+ * when the interface has it, otherwise the RFC 4861 defaults.  Every path that
+ * leaves a prefix unqualified comes through here, so the precedence rule lives
+ * in one place.  An operator can therefore shorten a whole link without naming
+ * each prefix, which is the mis-cabling case: the wrong prefix a host picked up
+ * ages out on its own once it stops being advertised at that host.
+ */
+static void rtadv_prefix_inherit_lifetimes(struct zebra_if *zif, struct rtadv_prefix *rp)
+{
+	if (zif->rtadv.AdvPrefixLifetimeSet) {
+		rp->AdvPreferredLifetime = zif->rtadv.AdvPrefixPreferredLifetime;
+		rp->AdvValidLifetime = zif->rtadv.AdvPrefixValidLifetime;
+	} else {
+		rp->AdvPreferredLifetime = RTADV_PREFERRED_LIFETIME;
+		rp->AdvValidLifetime = RTADV_VALID_LIFETIME;
+	}
+}
+
+/*
+ * A per-prefix lifetime leaf changed.  When the prefix no longer names its own
+ * the interface-wide default has to be put back, otherwise removing an explicit
+ * pair would silently leave the RFC values behind until the next re-stamp.
+ */
+void rtadv_prefix_lifetime_reeval(struct interface *ifp, struct rtadv_prefix *rprefix, bool named)
+{
+	struct zebra_if *zif = ifp->info;
+
+	rprefix->AdvLifetimeSet = named;
+
+	if (!named)
+		rtadv_prefix_inherit_lifetimes(zif, rprefix);
+}
+
+/* Reset a prefix to what an address on the interface alone would give it. */
+static void rtadv_prefix_set_defaults(struct zebra_if *zif, struct rtadv_prefix *rp)
 {
 	rp->AdvAutonomousFlag = 1;
 	rp->AdvOnLinkFlag = 1;
 	rp->AdvRouterAddressFlag = 0;
-	rp->AdvPreferredLifetime = RTADV_PREFERRED_LIFETIME;
-	rp->AdvValidLifetime = RTADV_VALID_LIFETIME;
+	rp->AdvLifetimeSet = false;
+
+	rtadv_prefix_inherit_lifetimes(zif, rp);
 }

 static struct rtadv_prefix *rtadv_prefix_set(struct zebra_if *zif,
@@ -1776,14 +1812,18 @@ static struct rtadv_prefix *rtadv_prefix_set(struct zebra_if *zif,
 		rprefix->AdvAutonomousFlag = rp->AdvAutonomousFlag;
 		rprefix->AdvOnLinkFlag = rp->AdvOnLinkFlag;
 		rprefix->AdvRouterAddressFlag = rp->AdvRouterAddressFlag;
-		rprefix->AdvPreferredLifetime = rp->AdvPreferredLifetime;
-		rprefix->AdvValidLifetime = rp->AdvValidLifetime;
+		rprefix->AdvLifetimeSet = rp->AdvLifetimeSet;
+		if (rp->AdvLifetimeSet) {
+			rprefix->AdvPreferredLifetime = rp->AdvPreferredLifetime;
+			rprefix->AdvValidLifetime = rp->AdvValidLifetime;
+		} else
+			rtadv_prefix_inherit_lifetimes(zif, rprefix);
 	} else if (rp->AdvPrefixCreate == PREFIX_SRC_AUTO) {
 		if (rprefix->AdvPrefixCreate == PREFIX_SRC_MANUAL)
 			rprefix->AdvPrefixCreate = PREFIX_SRC_BOTH;
 		else if (rprefix->AdvPrefixCreate != PREFIX_SRC_BOTH) {
 			rprefix->AdvPrefixCreate = PREFIX_SRC_AUTO;
-			rtadv_prefix_set_defaults(rprefix);
+			rtadv_prefix_set_defaults(zif, rprefix);
 		}
 	}

@@ -1808,7 +1848,7 @@ static void rtadv_prefix_reset(struct zebra_if *zif, struct rtadv_prefix *rp,
 		if (rp->AdvPrefixCreate == PREFIX_SRC_MANUAL) {
 			if (rprefix->AdvPrefixCreate == PREFIX_SRC_BOTH) {
 				rprefix->AdvPrefixCreate = PREFIX_SRC_AUTO;
-				rtadv_prefix_set_defaults(rprefix);
+				rtadv_prefix_set_defaults(zif, rprefix);
 				return;
 			} else if (rprefix->AdvPrefixCreate == PREFIX_SRC_AUTO)
 				return;
@@ -1872,6 +1912,91 @@ void rtadv_delete_prefix_manual(struct zebra_if *zif,
 	rtadv_prefix_reset(zif, &rp, rprefix, true);
 }

+/*
+ * Apply the interface-wide lifetimes to the prefixes already in the list.
+ *
+ * PREFIX_SRC_AUTO only.  A PREFIX_SRC_BOTH entry holds the values the operator
+ * typed into "ipv6 nd prefix", and those are kept live by the per-leaf
+ * northbound callbacks; re-stamping one here would put a lifetime on the wire
+ * that running-config does not mention, with nothing able to explain the
+ * difference.  An AUTO entry has no configuration to contradict.
+ */
+static void rtadv_prefix_lifetime_restamp(struct zebra_if *zif)
+{
+	struct rtadv_prefix *rprefix;
+
+	frr_each (rtadv_prefixes, zif->rtadv.prefixes, rprefix) {
+		/*
+		 * A prefix that named its own lifetimes keeps them.  Everything
+		 * else follows the interface, whether it came from an address
+		 * on the link or from an "ipv6 nd prefix" line that left the
+		 * lifetimes out: an operator setting an interface-wide default
+		 * means it to cover the prefixes they did not qualify, and on a
+		 * link where every prefix is configured explicitly the knob
+		 * would otherwise reach nothing at all.
+		 */
+		if (rprefix->AdvLifetimeSet)
+			continue;
+
+		rtadv_prefix_inherit_lifetimes(zif, rprefix);
+	}
+
+	/*
+	 * Nudge the next RA out rather than sending one from here.  frr-reload
+	 * replays a value change as a delete followed by an add, so an inline
+	 * send would put the RFC defaults on the wire in between the two.  The
+	 * existing fast-retransmit counter is wheel-driven and coalesces the
+	 * pair.  When fast retransmit is off the change simply appears on the
+	 * next periodic RA, which is fine: nothing here is time critical.
+	 */
+	if (zif->rtadv.AdvSendAdvertisements && zif->rtadv.MaxRtrAdvInterval >= 1000 &&
+	    zif->rtadv.UseFastRexmit) {
+		zif->rtadv.inFastRexmit = 1;
+		zif->rtadv.NumFastReXmitsRemain = RTADV_NUM_FAST_REXMITS;
+	}
+}
+
+void rtadv_prefix_lifetime_set(struct interface *ifp, uint32_t valid, uint32_t preferred)
+{
+	struct zebra_if *zif = ifp->info;
+
+	/*
+	 * RFC 4861 6.2.1 wants a prefix to outlive a few advertisement
+	 * intervals so a host that misses one does not drop the address.  Warn
+	 * rather than reject: aggressively short lifetimes are the whole point
+	 * of this knob, and 0 is legitimate for retiring a prefix outright.
+	 */
+	if (valid != 0 && valid < (uint32_t)(3 * (zif->rtadv.MaxRtrAdvInterval / 1000)))
+		zlog_warn("%s: valid lifetime %u is under three ra-intervals (%d ms); a host missing two RAs will lose its address",
+			  ifp->name, valid, zif->rtadv.MaxRtrAdvInterval);
+
+	/*
+	 * RFC 4862 5.5.3 floors the stored valid lifetime at two hours for an
+	 * address a host already holds, so a shorter value only takes full
+	 * effect for addresses formed after this point.
+	 */
+	if (valid != 0 && valid < 7200)
+		zlog_warn("%s: valid lifetime %u is under two hours; hosts already holding an address will retain it for up to 7200 seconds (RFC 4862 5.5.3)",
+			  ifp->name, valid);
+
+	zif->rtadv.AdvPrefixValidLifetime = valid;
+	zif->rtadv.AdvPrefixPreferredLifetime = preferred;
+	zif->rtadv.AdvPrefixLifetimeSet = true;
+
+	rtadv_prefix_lifetime_restamp(zif);
+}
+
+void rtadv_prefix_lifetime_reset(struct interface *ifp)
+{
+	struct zebra_if *zif = ifp->info;
+
+	zif->rtadv.AdvPrefixLifetimeSet = false;
+	zif->rtadv.AdvPrefixValidLifetime = RTADV_VALID_LIFETIME;
+	zif->rtadv.AdvPrefixPreferredLifetime = RTADV_PREFERRED_LIFETIME;
+
+	rtadv_prefix_lifetime_restamp(zif);
+}
+
 /* Add IPv6 prefixes learned from the kernel to the RA prefix list */
 void rtadv_add_prefix(struct zebra_if *zif, const struct prefix_ipv6 *p)
 {
@@ -2428,6 +2553,10 @@ static int nd_dump_vty(struct vty *vty, json_object *json_if, struct interface *
 		else
 			vty_out(vty,
 				"  ND router advertisements lifetime tracks ra-interval\n");
+		if (rtadv->AdvPrefixLifetimeSet)
+			vty_out(vty,
+				"  ND derived prefixes advertised with valid %u preferred %u seconds\n",
+				rtadv->AdvPrefixValidLifetime, rtadv->AdvPrefixPreferredLifetime);
 		vty_out(vty,
 			"  ND router advertisement default router preference is %s\n",
 			rtadv_pref_strs[rtadv->DefaultPreference]);
@@ -2497,6 +2626,13 @@ static int nd_dump_vty(struct vty *vty, json_object *json_if, struct interface *
 						"ndRouterAdvertisementsLifetimeTracksRaInterval",
 						true);

+		if (rtadv->AdvPrefixLifetimeSet) {
+			json_object_int_add(json_if, "ndDerivedPrefixValidLifetimeSecs",
+					    rtadv->AdvPrefixValidLifetime);
+			json_object_int_add(json_if, "ndDerivedPrefixPreferredLifetimeSecs",
+					    rtadv->AdvPrefixPreferredLifetime);
+		}
+
 		json_object_string_add(json_if, "ndRouterAdvertisementDefaultRouterPreference",
 				       rtadv_pref_strs[rtadv->DefaultPreference]);

@@ -2645,6 +2781,9 @@ void rtadv_if_init(struct zebra_if *zif)
 	rtadv->AdvIntervalOption = 0;
 	rtadv->UseFastRexmit = true;
 	rtadv->DefaultPreference = RTADV_PREF_MEDIUM;
+	rtadv->AdvPrefixLifetimeSet = false;
+	rtadv->AdvPrefixValidLifetime = RTADV_VALID_LIFETIME;
+	rtadv->AdvPrefixPreferredLifetime = RTADV_PREFERRED_LIFETIME;

 	rtadv_prefixes_init(rtadv->prefixes);

diff --git a/zebra/rtadv.h b/zebra/rtadv.h
index dcd1f00d9b..275236ebf4 100644
--- a/zebra/rtadv.h
+++ b/zebra/rtadv.h
@@ -194,6 +194,19 @@ struct rtadvconf {
 	   included in the list of advertised prefixes. */
 	struct rtadv_prefixes_head prefixes[1];

+	/*
+	 * Lifetimes stamped on the prefixes derived from the addresses
+	 * configured on this interface.  A prefix named by "ipv6 nd prefix"
+	 * carries its own lifetimes and is never stamped from here, so what
+	 * the operator spelled out stays authoritative.
+	 *
+	 * Default: unset, in which case RTADV_VALID_LIFETIME and
+	 * RTADV_PREFERRED_LIFETIME are used.
+	 */
+	uint32_t AdvPrefixValidLifetime;
+	uint32_t AdvPrefixPreferredLifetime;
+	bool AdvPrefixLifetimeSet;
+
 	/* The true/false value to be placed in the "Home agent"
 	   flag field in the Router Advertisement.  See [RFC6275 7.1].

@@ -342,6 +355,16 @@ struct rtadv_prefix {
 	uint32_t AdvPreferredLifetime;
 #define RTADV_PREFERRED_LIFETIME 604800

+	/*
+	 * The lifetimes above were named by this prefix's own configuration
+	 * rather than inherited from "ipv6 nd prefix-lifetime" on the
+	 * interface.  The values alone cannot say which, as an inherited pair
+	 * looks the same as a named one.  A pair equal to the RFC 4861 values
+	 * counts as not named: the running config leaves it out, so it would
+	 * be inherited after a reload anyway.
+	 */
+	bool AdvLifetimeSet;
+
 	/* The value to be placed in the Autonomous Flag. */
 	int AdvAutonomousFlag;

@@ -490,6 +513,11 @@ struct rtadv_prefix *rtadv_add_prefix_manual(struct zebra_if *zif,
 void rtadv_delete_prefix_manual(struct zebra_if *zif,
 				struct rtadv_prefix *rprefix);

+/* interface-wide lifetimes for every prefix that names none of its own */
+void rtadv_prefix_lifetime_set(struct interface *ifp, uint32_t valid, uint32_t preferred);
+void rtadv_prefix_lifetime_reset(struct interface *ifp);
+void rtadv_prefix_lifetime_reeval(struct interface *ifp, struct rtadv_prefix *rprefix, bool named);
+
 /* returns created address */
 struct rtadv_rdnss *rtadv_rdnss_set(struct zebra_if *zif,
 				    struct rtadv_rdnss *rdnss);
diff --git a/zebra/zebra_cli.c b/zebra/zebra_cli.c
index 28b789e050..31f66b892b 100644
--- a/zebra/zebra_cli.c
+++ b/zebra/zebra_cli.c
@@ -1997,6 +1997,69 @@ lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_cli_write(
 	vty_out(vty, "\n");
 }

+DEFPY_YANG (ipv6_nd_prefix_lifetime,
+	ipv6_nd_prefix_lifetime_cmd,
+	"[no] ipv6 nd prefix-lifetime [<(0-4294967295)|infinite>$valid <(0-4294967295)|infinite>$preferred]",
+	NO_STR
+	"Interface IPv6 config commands\n"
+	"Neighbor discovery\n"
+	"Lifetimes for the prefixes advertised by default\n"
+	"Valid lifetime in seconds\n"
+	"Infinite valid lifetime\n"
+	"Preferred lifetime in seconds\n"
+	"Infinite preferred lifetime\n")
+{
+	if (!no) {
+		/*
+		 * RFC 4861 4.6.2: a host discards a prefix option whose
+		 * preferred lifetime exceeds its valid lifetime, so accepting
+		 * one without the other would leave the operator advertising a
+		 * prefix hosts silently ignore.
+		 */
+		if (!valid || !preferred) {
+			vty_out(vty, "%% both valid and preferred lifetime are required\n");
+			return CMD_WARNING_CONFIG_FAILED;
+		}
+
+		if (strmatch(valid, "infinite"))
+			valid = "4294967295";
+		if (strmatch(preferred, "infinite"))
+			preferred = "4294967295";
+
+		nb_cli_enqueue_change(vty, "./default-lifetimes", NB_OP_CREATE, NULL);
+		nb_cli_enqueue_change(vty, "./default-lifetimes/valid-lifetime", NB_OP_MODIFY,
+				      valid);
+		nb_cli_enqueue_change(vty, "./default-lifetimes/preferred-lifetime", NB_OP_MODIFY,
+				      preferred);
+	} else {
+		nb_cli_enqueue_change(vty, "./default-lifetimes", NB_OP_DESTROY, NULL);
+	}
+
+	return nb_cli_apply_changes(vty,
+				    "./frr-zebra:zebra/ipv6-router-advertisements/prefix-list");
+}
+
+static void lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_cli_write(
+	struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
+{
+	uint32_t valid = yang_dnode_get_uint32(dnode, "valid-lifetime");
+	uint32_t preferred = yang_dnode_get_uint32(dnode, "preferred-lifetime");
+
+	vty_out(vty, " ipv6 nd prefix-lifetime");
+
+	if (valid == UINT32_MAX)
+		vty_out(vty, " infinite");
+	else
+		vty_out(vty, " %u", valid);
+
+	if (preferred == UINT32_MAX)
+		vty_out(vty, " infinite");
+	else
+		vty_out(vty, " %u", preferred);
+
+	vty_out(vty, "\n");
+}
+
 DEFPY_YANG (ipv6_nd_router_preference,
 	ipv6_nd_router_preference_cmd,
 	"[no] ipv6 nd router-preference ![<high|medium|low>$pref]",
@@ -3303,6 +3366,10 @@ const struct frr_yang_module_info frr_zebra_cli_info = {
 			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-router-preference",
 			.cbs.cli_show = lib_interface_zebra_ipv6_router_advertisements_default_router_preference_cli_write,
 		},
+		{
+			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes",
+			.cbs.cli_show = lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_cli_write,
+		},
 		{
 			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/prefix",
 			.cbs.cli_show = lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_cli_write,
@@ -3429,6 +3496,7 @@ void zebra_cli_init(void)
 	install_element(INTERFACE_NODE, &ipv6_nd_homeagent_lifetime_cmd);
 	install_element(INTERFACE_NODE, &ipv6_nd_adv_interval_config_option_cmd);
 	install_element(INTERFACE_NODE, &ipv6_nd_prefix_cmd);
+	install_element(INTERFACE_NODE, &ipv6_nd_prefix_lifetime_cmd);
 	install_element(INTERFACE_NODE, &ipv6_nd_router_preference_cmd);
 	install_element(INTERFACE_NODE, &ipv6_nd_mtu_cmd);
 	install_element(INTERFACE_NODE, &ipv6_nd_rdnss_cmd);
diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c
index 276834f835..dd7338d63d 100644
--- a/zebra/zebra_nb.c
+++ b/zebra/zebra_nb.c
@@ -729,6 +729,25 @@ const struct frr_yang_module_info frr_zebra_info = {
 				.modify = lib_interface_zebra_ipv6_router_advertisements_default_router_preference_modify,
 			}
 		},
+		{
+			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes",
+			.cbs = {
+				.create = lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_create,
+				.destroy = lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_destroy,
+			}
+		},
+		{
+			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes/valid-lifetime",
+			.cbs = {
+				.modify = lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_valid_lifetime_modify,
+			}
+		},
+		{
+			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes/preferred-lifetime",
+			.cbs = {
+				.modify = lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_preferred_lifetime_modify,
+			}
+		},
 		{
 			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/prefix",
 			.cbs = {
diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h
index e8b276657a..71c8aa3829 100644
--- a/zebra/zebra_nb.h
+++ b/zebra/zebra_nb.h
@@ -251,6 +251,14 @@ int lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_destroy(
 	struct nb_cb_destroy_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_default_router_preference_modify(
 	struct nb_cb_modify_args *args);
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_create(
+	struct nb_cb_create_args *args);
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_destroy(
+	struct nb_cb_destroy_args *args);
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_valid_lifetime_modify(
+	struct nb_cb_modify_args *args);
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_preferred_lifetime_modify(
+	struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_create(
 	struct nb_cb_create_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_destroy(
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c
index 6313333f22..a7ba9dafa2 100644
--- a/zebra/zebra_nb_config.c
+++ b/zebra/zebra_nb_config.c
@@ -3110,6 +3110,100 @@ int lib_interface_zebra_ipv6_router_advertisements_default_router_preference_mod
 	return NB_OK;
 }

+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes
+ */
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_create(
+	struct nb_cb_create_args *args)
+{
+	struct interface *ifp;
+
+	if (args->event != NB_EV_APPLY)
+		return NB_OK;
+
+	ifp = nb_running_get_entry(args->dnode, NULL, true);
+
+	rtadv_prefix_lifetime_set(ifp, yang_dnode_get_uint32(args->dnode, "valid-lifetime"),
+				  yang_dnode_get_uint32(args->dnode, "preferred-lifetime"));
+
+	return NB_OK;
+}
+
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_destroy(
+	struct nb_cb_destroy_args *args)
+{
+	struct interface *ifp;
+
+	if (args->event != NB_EV_APPLY)
+		return NB_OK;
+
+	ifp = nb_running_get_entry(args->dnode, NULL, true);
+
+	rtadv_prefix_lifetime_reset(ifp);
+
+	return NB_OK;
+}
+
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes/valid-lifetime
+ */
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_valid_lifetime_modify(
+	struct nb_cb_modify_args *args)
+{
+	struct interface *ifp;
+
+	if (args->event != NB_EV_APPLY)
+		return NB_OK;
+
+	ifp = nb_running_get_entry(args->dnode, NULL, true);
+
+	/*
+	 * Both leaves are mandatory inside the container, so the sibling is
+	 * always present.  Going through the setter for a single-leaf change
+	 * keeps the re-stamp in one place.
+	 */
+	rtadv_prefix_lifetime_set(ifp, yang_dnode_get_uint32(args->dnode, "../valid-lifetime"),
+				  yang_dnode_get_uint32(args->dnode, "../preferred-lifetime"));
+
+	return NB_OK;
+}
+
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/default-lifetimes/preferred-lifetime
+ */
+int lib_interface_zebra_ipv6_router_advertisements_prefix_list_default_lifetimes_preferred_lifetime_modify(
+	struct nb_cb_modify_args *args)
+{
+	struct interface *ifp;
+
+	if (args->event != NB_EV_APPLY)
+		return NB_OK;
+
+	ifp = nb_running_get_entry(args->dnode, NULL, true);
+
+	rtadv_prefix_lifetime_set(ifp, yang_dnode_get_uint32(args->dnode, "../valid-lifetime"),
+				  yang_dnode_get_uint32(args->dnode, "../preferred-lifetime"));
+
+	return NB_OK;
+}
+
+/*
+ * Both lifetime leaves carry a YANG default, so their callbacks fire even when
+ * the operator named neither.  Treat the pair as configured only when at least
+ * one holds a non-default value -- the same test the "ipv6 nd prefix" cli_write
+ * uses to decide whether to print them back out.  A prefix that named nothing
+ * inherits "ipv6 nd prefix-lifetime" from the interface instead.
+ */
+static bool rtadv_prefix_lifetimes_named(const struct lyd_node *dnode, const char *base)
+{
+	char valid[XPATH_MAXLEN], preferred[XPATH_MAXLEN];
+
+	snprintfrr(valid, sizeof(valid), "%svalid-lifetime", base);
+	snprintfrr(preferred, sizeof(preferred), "%spreferred-lifetime", base);
+
+	return !yang_dnode_is_default(dnode, valid) || !yang_dnode_is_default(dnode, preferred);
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/prefix-list/prefix
  */
@@ -3134,6 +3228,7 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_create(
 						    "valid-lifetime");
 	rp.AdvPreferredLifetime = yang_dnode_get_uint32(args->dnode,
 							"preferred-lifetime");
+	rp.AdvLifetimeSet = rtadv_prefix_lifetimes_named(args->dnode, "");

 	prefix = rtadv_add_prefix_manual(ifp->info, &rp);
 	nb_running_set_entry(args->dnode, prefix);
@@ -3165,13 +3260,28 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_valid_life
 	struct nb_cb_modify_args *args)
 {
 	struct rtadv_prefix *prefix;
+	struct interface *ifp;

 	if (args->event != NB_EV_APPLY)
 		return NB_OK;

 	prefix = nb_running_get_entry(args->dnode, NULL, true);

-	prefix->AdvValidLifetime = yang_dnode_get_uint32(args->dnode, NULL);
+	/*
+	 * Read both leaves.  A sibling named with its default value fires no
+	 * callback of its own, so it would otherwise keep whatever this prefix
+	 * last inherited from the interface.
+	 */
+	prefix->AdvValidLifetime = yang_dnode_get_uint32(args->dnode, "../valid-lifetime");
+	prefix->AdvPreferredLifetime = yang_dnode_get_uint32(args->dnode, "../preferred-lifetime");
+
+	/*
+	 * The interface is the nearest registered entry above the prefix-list.
+	 * Start there: nb_running_get_entry() ignores the xpath when given a
+	 * dnode, and from this leaf it would stop at the prefix itself.
+	 */
+	ifp = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, true);
+	rtadv_prefix_lifetime_reeval(ifp, prefix, rtadv_prefix_lifetimes_named(args->dnode, "../"));

 	return NB_OK;
 }
@@ -3201,13 +3311,28 @@ int lib_interface_zebra_ipv6_router_advertisements_prefix_list_prefix_preferred_
 	struct nb_cb_modify_args *args)
 {
 	struct rtadv_prefix *prefix;
+	struct interface *ifp;

 	if (args->event != NB_EV_APPLY)
 		return NB_OK;

 	prefix = nb_running_get_entry(args->dnode, NULL, true);

-	prefix->AdvPreferredLifetime = yang_dnode_get_uint32(args->dnode, NULL);
+	/*
+	 * Read both leaves.  A sibling named with its default value fires no
+	 * callback of its own, so it would otherwise keep whatever this prefix
+	 * last inherited from the interface.
+	 */
+	prefix->AdvValidLifetime = yang_dnode_get_uint32(args->dnode, "../valid-lifetime");
+	prefix->AdvPreferredLifetime = yang_dnode_get_uint32(args->dnode, "../preferred-lifetime");
+
+	/*
+	 * The interface is the nearest registered entry above the prefix-list.
+	 * Start there: nb_running_get_entry() ignores the xpath when given a
+	 * dnode, and from this leaf it would stop at the prefix itself.
+	 */
+	ifp = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, true);
+	rtadv_prefix_lifetime_reeval(ifp, prefix, rtadv_prefix_lifetimes_named(args->dnode, "../"));

 	return NB_OK;
 }