diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2024-12-19 08:58:02 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2025-01-07 15:35:31 +0100 |
commit | 2bd5cd1b81a91dc6f38547f75b74e97f4e9ea5e9 (patch) | |
tree | 0d15c444dad3cea51e59d7ccab1edcfc3b22e5f2 /bgpd | |
parent | bgpd, topotests: bmp, add loc-rib peer up event for imported bgp (diff) | |
download | frr-2bd5cd1b81a91dc6f38547f75b74e97f4e9ea5e9.tar.xz frr-2bd5cd1b81a91dc6f38547f75b74e97f4e9ea5e9.zip |
bgpd, topotests: bmp imported bgp, add loc-rib peer up support when router-id changes
Add the emission of a loc-rib peer up event for an imported bgp instance
at route-id reconfiguration. Add a test to control in the BMP collector
that the peer up message is the one from that BGP instance.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_bmp.c | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 880cb2c8f..313834c02 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -3394,24 +3394,58 @@ static int bgp_bmp_early_fini(void) return 0; } +static int bmp_bgp_attribute_updated_instance(struct bmp_targets *bt, enum bmp_vrf_state *vrf_state, + struct bgp *bgp, bool withdraw, struct stream *s) +{ + bmp_bgp_update_vrf_status(vrf_state, bgp, vrf_state_unknown); + if (*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_bt(bt, s); + return 1; +} + /* called when the routerid of an instance changes */ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw) { struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp); + struct bgp *bgp_vrf; + struct bmp_targets *bt; + struct listnode *node; + struct bmp_imported_bgp *bib; + int ret = 0; + struct stream *s = bmp_peerstate(bgp->peer_self, withdraw); - if (!bmpbgp) + if (!s) return 0; - bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, 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; + if (bmpbgp) { + frr_each (bmp_targets, &bmpbgp->targets, bt) { + ret = bmp_bgp_attribute_updated_instance(bt, &bmpbgp->vrf_state, bgp, + withdraw, s); + } + } - /* vrf_state is up: trigger a peer event - */ - bmp_send_all_safe(bmpbgp, bmp_peerstate(bgp->peer_self, withdraw)); + for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { + if (bgp == bgp_vrf) + continue; + bmpbgp = bmp_bgp_find(bgp_vrf); + if (!bmpbgp) + continue; + frr_each (bmp_targets, &bmpbgp->targets, bt) { + frr_each (bmp_imported_bgps, &bt->imported_bgps, bib) { + if (bgp_lookup_by_name(bib->name) != bgp) + continue; + ret += bmp_bgp_attribute_updated_instance(bt, &bib->vrf_state, bgp, + withdraw, s); + } + } + } + stream_free(s); return 1; } |