mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-04 08:21:42 +00:00
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>
This commit is contained in:
parent
f3c17d94e0
commit
4052c18a42
@ -3180,7 +3180,7 @@ static int bgp_bmp_early_fini(void)
|
||||
}
|
||||
|
||||
/* called when the routerid of an instance changes */
|
||||
static int bmp_routerid_update(struct bgp *bgp, bool withdraw)
|
||||
static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw)
|
||||
{
|
||||
struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
|
||||
|
||||
@ -3200,6 +3200,15 @@ static int bmp_routerid_update(struct bgp *bgp, bool withdraw)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bmp_routerid_update(struct bgp *bgp, bool withdraw)
|
||||
{
|
||||
return bmp_bgp_attribute_updated(bgp, withdraw);
|
||||
}
|
||||
|
||||
static int bmp_route_distinguisher_update(struct bgp *bgp, afi_t afi, bool preconfig)
|
||||
{
|
||||
return bmp_bgp_attribute_updated(bgp, preconfig);
|
||||
}
|
||||
|
||||
/* called when a bgp instance goes up/down, implying that the underlying VRF
|
||||
* has been created or deleted in zebra
|
||||
@ -3255,6 +3264,7 @@ static int bgp_bmp_module_init(void)
|
||||
hook_register(bgp_instance_state, bmp_vrf_state_changed);
|
||||
hook_register(bgp_vrf_status_changed, bmp_vrf_itf_state_changed);
|
||||
hook_register(bgp_routerid_update, bmp_routerid_update);
|
||||
hook_register(bgp_route_distinguisher_update, bmp_route_distinguisher_update);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -908,6 +908,8 @@ DECLARE_HOOK(bgp_hook_vrf_update, (struct vrf *vrf, bool enabled),
|
||||
(vrf, enabled));
|
||||
DECLARE_HOOK(bgp_instance_state, (struct bgp *bgp), (bgp));
|
||||
DECLARE_HOOK(bgp_routerid_update, (struct bgp *bgp, bool withdraw), (bgp, withdraw));
|
||||
DECLARE_HOOK(bgp_route_distinguisher_update, (struct bgp *bgp, afi_t afi, bool preconfig),
|
||||
(bgp, afi, preconfig));
|
||||
|
||||
/* Thread callback information */
|
||||
struct afi_safi_info {
|
||||
|
Loading…
Reference in New Issue
Block a user