summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_vty.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2024-11-03 22:44:55 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2024-12-30 15:13:38 +0100
commit4052c18a42b87feb2f3240cde33b8762f548f4fa (patch)
tree62dd240994b72b2f8e7f6e765df06c8808bd8bd6 /bgpd/bgp_vty.c
parentbgpd: bmp, define hook for router-id updates (diff)
downloadfrr-4052c18a42b87feb2f3240cde33b8762f548f4fa.tar.xz
frr-4052c18a42b87feb2f3240cde33b8762f548f4fa.zip
bgpd: bmp, define hook for route distinguisher updates
At startup, if bmp loc-rib is enabled, the peer_id of the loc-rib per peer header message has the route distinguisher set to 0:0. Actually, the route distinguisher has been updated after the peer up message is sent, and the information is not refreshed. Create a hook API to handle route distinguisher config events: pre and post configuration. Use that hook in BMP module to send peer down, and peer up events when necessary. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_vty.c')
-rw-r--r--bgpd/bgp_vty.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 550adf93d..2da77c314 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -141,6 +141,8 @@ DEFINE_HOOK(bgp_inst_config_write,
DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp));
DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp));
DEFINE_HOOK(bgp_snmp_traps_config_write, (struct vty * vty), (vty));
+DEFINE_HOOK(bgp_route_distinguisher_update, (struct bgp *bgp, afi_t afi, bool preconfig),
+ (bgp, afi, preconfig));
static struct peer_group *listen_range_exists(struct bgp *bgp,
struct prefix *range, int exact);
@@ -9805,6 +9807,14 @@ DEFPY (af_rd_vpn_export,
vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi,
bgp_get_default(), bgp);
+ if (!bgp->vpn_policy[afi].tovpn_rd_pretty && !rd_str)
+ return CMD_SUCCESS;
+
+ if (yes && bgp->vpn_policy[afi].tovpn_rd_pretty && rd_str &&
+ strmatch(rd_str, bgp->vpn_policy[afi].tovpn_rd_pretty))
+ return CMD_SUCCESS;
+
+ hook_call(bgp_route_distinguisher_update, bgp, afi, true);
if (yes) {
if (bgp->vpn_policy[afi].tovpn_rd_pretty)
XFREE(MTYPE_BGP_NAME, bgp->vpn_policy[afi].tovpn_rd_pretty);
@@ -9815,9 +9825,11 @@ DEFPY (af_rd_vpn_export,
BGP_VPN_POLICY_TOVPN_RD_SET);
} else {
XFREE(MTYPE_BGP_NAME, bgp->vpn_policy[afi].tovpn_rd_pretty);
+ bgp->vpn_policy[afi].tovpn_rd_pretty = NULL;
UNSET_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_RD_SET);
}
+ hook_call(bgp_route_distinguisher_update, bgp, afi, false);
/* post-change: re-export vpn routes */
vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi,