From 8412fa8f9861f9b2d9d1374452d40f9526f9024a Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 2 Sep 2024 14:58:10 +0300 Subject: [PATCH 1/3] bgpd: Allow setting default-originate rescan to be up to 65535 seconds Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index c9c7b8049644..012cd893eb5c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8416,7 +8416,7 @@ DEFPY (bgp_condadv_period, DEFPY (bgp_def_originate_eval, bgp_def_originate_eval_cmd, - "[no$no] bgp default-originate timer (0-3600)$timer", + "[no$no] bgp default-originate timer (0-65535)$timer", NO_STR BGP_STR "Control default-originate\n" From d12306d3e0b86c7fa6ea848b422a830a31384ccf Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 2 Sep 2024 15:02:10 +0300 Subject: [PATCH 2/3] bgpd: Do not scan update-groups if default-originate timer is set to 0 With lots of update-groups, subgroups, this could be very tricky and the timer is spawned even if it's totally unnecessary (default-originate is not enabled). Signed-off-by: Donatas Abraitis --- bgpd/bgp_route.c | 3 ++- doc/user/bgp.rst | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 3ff7dbc07041..eda5e94b7b54 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3757,7 +3757,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, if (old_select || new_select) { bgp_bump_version(dest); - if (!bgp->t_rmap_def_originate_eval) + if (!bgp->t_rmap_def_originate_eval && + bgp->rmap_def_originate_eval_timer) event_add_timer( bm->master, update_group_refresh_default_originate_route_map, diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index aa62d274f03f..c6f9aabad3df 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -1972,12 +1972,14 @@ Configuring Peers and will not be displayed as part of a `show run`. The no form of the command turns off this ability. -.. clicmd:: bgp default-originate timer (0-3600) +.. clicmd:: bgp default-originate timer (0-65535) Set the period to rerun the default-originate route-map scanner process. The default is 5 seconds. With a full routing table, it might be useful to increase this setting to avoid scanning the whole BGP table aggressively. + Setting to 0 turns off the scanning at all. + .. clicmd:: bgp default ipv4-unicast This command allows the user to specify that the IPv4 Unicast address From 5b24d3b223dd8598bf14dd4582844144fe207ea7 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 3 Sep 2024 16:09:26 +0300 Subject: [PATCH 3/3] bgpd: Turn off default-originate timer If the neighbor is not configured with `neighbor X default-originate route-map ...`, then this timer is useless. Change the logic to be it disabled by default, but enabled automatically once the route-map is configured for default-originate command. Automatically assigned timer value is as before, 5 seconds. Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 8 ++++---- bgpd/bgpd.c | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 012cd893eb5c..a942ba4e6096 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8425,8 +8425,7 @@ DEFPY (bgp_def_originate_eval, { VTY_DECLVAR_CONTEXT(bgp, bgp); - bgp->rmap_def_originate_eval_timer = - no ? RMAP_DEFAULT_ORIGINATE_EVAL_TIMER : timer; + bgp->rmap_def_originate_eval_timer = no ? 0 : timer; if (bgp->t_rmap_def_originate_eval) EVENT_OFF(bgp->t_rmap_def_originate_eval); @@ -19778,8 +19777,9 @@ int bgp_config_write(struct vty *vty) bgp->condition_check_period); /* default-originate timer configuration */ - if (bgp->rmap_def_originate_eval_timer != - RMAP_DEFAULT_ORIGINATE_EVAL_TIMER) + if (bgp->rmap_def_originate_eval_timer && + bgp->rmap_def_originate_eval_timer != + RMAP_DEFAULT_ORIGINATE_EVAL_TIMER) vty_out(vty, " bgp default-originate timer %u\n", bgp->rmap_def_originate_eval_timer); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index a88de651f50c..ccff51a91a5b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3520,7 +3520,7 @@ static struct bgp *bgp_create(as_t *as, const char *name, bgp_addpath_init_bgp_data(&bgp->tx_addpath); bgp->fast_convergence = false; bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; - bgp->rmap_def_originate_eval_timer = RMAP_DEFAULT_ORIGINATE_EVAL_TIMER; + bgp->rmap_def_originate_eval_timer = 0; #ifdef ENABLE_BGP_VNC if (inst_type != BGP_INSTANCE_TYPE_VRF) { @@ -5783,6 +5783,10 @@ int peer_default_originate_set(struct peer *peer, afi_t afi, safi_t safi, subgrp = peer_subgroup(peer, afi, safi); if (rmap) { + if (!peer->bgp->rmap_def_originate_eval_timer) + peer->bgp->rmap_def_originate_eval_timer = + RMAP_DEFAULT_ORIGINATE_EVAL_TIMER; + if (!peer->default_rmap[afi][safi].name || strcmp(rmap, peer->default_rmap[afi][safi].name) != 0) { struct route_map *map = NULL; @@ -5865,6 +5869,10 @@ int peer_default_originate_set(struct peer *peer, afi_t afi, safi_t safi, if (rmap) { struct route_map *map = NULL; + if (!member->bgp->rmap_def_originate_eval_timer) + member->bgp->rmap_def_originate_eval_timer = + RMAP_DEFAULT_ORIGINATE_EVAL_TIMER; + if (member->default_rmap[afi][safi].name) { map = route_map_lookup_by_name( member->default_rmap[afi][safi].name);