Commit d936427b94 for frr

commit d936427b943ab74d6a36c6c5078bb4c94089da24
Author: Rajasekar Raja <rajasekarr@nvidia.com>
Date:   Wed Sep 30 11:03:25 2026 -0700

    bgpd: Restart conditional advertisement timer when its period changes

    The conditional advertisement scanner only picks up a new period when
    it re-arms itself after firing. Changing "bgp conditional-advertisement
    timer" therefore left the old interval running: going from 100 to 10
    seconds could delay the next scan by up to 100 seconds, even though
    "show bgp neighbors" already reported the new value.

    Restart the scanner with the new period as soon as the configured value
    changes. Re-applying the same value leaves the timer alone, so repeated
    configuration cannot keep pushing the next scan out.

    Fixes: 389e4f92d67e ("bgpd: add knob to config cond-adv scanner period")
    Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>

diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c
index 3c5d0347f8..1c3ab16750 100644
--- a/bgpd/bgp_conditional_adv.c
+++ b/bgpd/bgp_conditional_adv.c
@@ -361,6 +361,26 @@ void bgp_conditional_adv_disable(struct peer *peer, afi_t afi, safi_t safi)
 	event_cancel(&bgp->t_condition_check);
 }

+void bgp_conditional_adv_period_set(struct bgp *bgp, uint32_t period)
+{
+	/* Re-applying the same period must not delay the next scan. */
+	if (bgp->condition_check_period == period)
+		return;
+
+	bgp->condition_check_period = period;
+
+	/*
+	 * The scanner picks up the configured period only when it re-arms
+	 * itself, so restart it here or the new period would not apply until
+	 * the previously armed interval expires.
+	 */
+	if (event_is_scheduled(bgp->t_condition_check)) {
+		event_cancel(&bgp->t_condition_check);
+		event_add_timer(bm->master, bgp_conditional_adv_timer, bgp,
+				bgp->condition_check_period, &bgp->t_condition_check);
+	}
+}
+
 static void peer_advertise_map_filter_update(struct peer *peer, afi_t afi,
 					     safi_t safi, const char *amap_name,
 					     struct route_map *amap,
diff --git a/bgpd/bgp_conditional_adv.h b/bgpd/bgp_conditional_adv.h
index b1be59366a..22295d9f35 100644
--- a/bgpd/bgp_conditional_adv.h
+++ b/bgpd/bgp_conditional_adv.h
@@ -34,6 +34,7 @@ extern void bgp_conditional_adv_enable(struct peer *peer, afi_t afi,
 				       safi_t safi);
 extern void bgp_conditional_adv_disable(struct peer *peer, afi_t afi,
 					safi_t safi);
+extern void bgp_conditional_adv_period_set(struct bgp *bgp, uint32_t period);
 extern int peer_advertise_map_set(struct peer *peer, afi_t afi, safi_t safi,
 				  const char *advertise_name,
 				  struct route_map *advertise_map,
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 755da294b6..1f3d5e7c30 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -9177,9 +9177,9 @@ DEFPY (bgp_condadv_period,
 		for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer))
 			UNSET_FLAG(peer->sflags, PEER_STATUS_COND_ADV_PENDING);

-		bgp->condition_check_period = DEFAULT_CONDITIONAL_ROUTES_POLL_TIME;
+		bgp_conditional_adv_period_set(bgp, DEFAULT_CONDITIONAL_ROUTES_POLL_TIME);
 	} else {
-		bgp->condition_check_period = period;
+		bgp_conditional_adv_period_set(bgp, period);
 	}

 	return CMD_SUCCESS;
diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst
index 3bed900e15..4d26f25678 100644
--- a/doc/user/bgp.rst
+++ b/doc/user/bgp.rst
@@ -4864,7 +4864,8 @@ scanner exits early.
 .. clicmd:: bgp conditional-advertisement timer (5-240)

    Set the period to rerun the conditional advertisement scanner process. The
-   default is 60 seconds.
+   default is 60 seconds. Changing the period restarts the scanner timer, so
+   the next scan runs within the new period.

 Sample Configuration
 ^^^^^^^^^^^^^^^^^^^^^