mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-17 15:46:26 +00:00
bgpd: bmp, define hook for router-id updates
At startup, if bmp loc-rib is enabled, the peer_id of the loc-rib per peer header message has the router-id set to 0.0.0.0. Actually, the router-id has been updated after the peer up message is sent, and the information is not refreshed. Create a hook API to handle router id events: withdraw and updates. 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
bb02fb186a
commit
f3c17d94e0
@ -3179,6 +3179,28 @@ static int bgp_bmp_early_fini(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* called when the routerid of an instance changes */
|
||||||
|
static int bmp_routerid_update(struct bgp *bgp, bool withdraw)
|
||||||
|
{
|
||||||
|
struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
|
||||||
|
|
||||||
|
if (!bmpbgp)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
bmp_bgp_update_vrf_status(bmpbgp, vrf_state_unknown);
|
||||||
|
|
||||||
|
if (bmpbgp->vrf_state == vrf_state_down)
|
||||||
|
/* do not send peer events, router id will not be enough to set state to up
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* vrf_state is up: trigger a peer event
|
||||||
|
*/
|
||||||
|
bmp_send_all_safe(bmpbgp, bmp_peerstate(bgp->peer_self, withdraw));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* called when a bgp instance goes up/down, implying that the underlying VRF
|
/* called when a bgp instance goes up/down, implying that the underlying VRF
|
||||||
* has been created or deleted in zebra
|
* has been created or deleted in zebra
|
||||||
*/
|
*/
|
||||||
@ -3232,6 +3254,7 @@ static int bgp_bmp_module_init(void)
|
|||||||
hook_register(frr_early_fini, bgp_bmp_early_fini);
|
hook_register(frr_early_fini, bgp_bmp_early_fini);
|
||||||
hook_register(bgp_instance_state, bmp_vrf_state_changed);
|
hook_register(bgp_instance_state, bmp_vrf_state_changed);
|
||||||
hook_register(bgp_vrf_status_changed, bmp_vrf_itf_state_changed);
|
hook_register(bgp_vrf_status_changed, bmp_vrf_itf_state_changed);
|
||||||
|
hook_register(bgp_routerid_update, bmp_routerid_update);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ DEFINE_QOBJ_TYPE(bgp);
|
|||||||
DEFINE_QOBJ_TYPE(peer);
|
DEFINE_QOBJ_TYPE(peer);
|
||||||
DEFINE_HOOK(bgp_inst_delete, (struct bgp *bgp), (bgp));
|
DEFINE_HOOK(bgp_inst_delete, (struct bgp *bgp), (bgp));
|
||||||
DEFINE_HOOK(bgp_instance_state, (struct bgp *bgp), (bgp));
|
DEFINE_HOOK(bgp_instance_state, (struct bgp *bgp), (bgp));
|
||||||
|
DEFINE_HOOK(bgp_routerid_update, (struct bgp *bgp, bool withdraw), (bgp, withdraw));
|
||||||
|
|
||||||
/* BGP process wide configuration. */
|
/* BGP process wide configuration. */
|
||||||
static struct bgp_master bgp_master;
|
static struct bgp_master bgp_master;
|
||||||
@ -301,6 +302,8 @@ static int bgp_router_id_set(struct bgp *bgp, const struct in_addr *id,
|
|||||||
|
|
||||||
vpn_handle_router_id_update(bgp, true, is_config);
|
vpn_handle_router_id_update(bgp, true, is_config);
|
||||||
|
|
||||||
|
hook_call(bgp_routerid_update, bgp, true);
|
||||||
|
|
||||||
IPV4_ADDR_COPY(&bgp->router_id, id);
|
IPV4_ADDR_COPY(&bgp->router_id, id);
|
||||||
|
|
||||||
/* Set all peer's local identifier with this value. */
|
/* Set all peer's local identifier with this value. */
|
||||||
@ -318,6 +321,7 @@ static int bgp_router_id_set(struct bgp *bgp, const struct in_addr *id,
|
|||||||
|
|
||||||
vpn_handle_router_id_update(bgp, false, is_config);
|
vpn_handle_router_id_update(bgp, false, is_config);
|
||||||
|
|
||||||
|
hook_call(bgp_routerid_update, bgp, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,6 +907,7 @@ DECLARE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp));
|
|||||||
DECLARE_HOOK(bgp_hook_vrf_update, (struct vrf *vrf, bool enabled),
|
DECLARE_HOOK(bgp_hook_vrf_update, (struct vrf *vrf, bool enabled),
|
||||||
(vrf, enabled));
|
(vrf, enabled));
|
||||||
DECLARE_HOOK(bgp_instance_state, (struct bgp *bgp), (bgp));
|
DECLARE_HOOK(bgp_instance_state, (struct bgp *bgp), (bgp));
|
||||||
|
DECLARE_HOOK(bgp_routerid_update, (struct bgp *bgp, bool withdraw), (bgp, withdraw));
|
||||||
|
|
||||||
/* Thread callback information */
|
/* Thread callback information */
|
||||||
struct afi_safi_info {
|
struct afi_safi_info {
|
||||||
|
Loading…
Reference in New Issue
Block a user