mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-26 23:23:35 +00:00
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>
This commit is contained in:
parent
ab31e964e4
commit
2bd5cd1b81
@ -3394,24 +3394,58 @@ static int bgp_bmp_early_fini(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* called when the routerid of an instance changes */
|
||||
static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw)
|
||||
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)
|
||||
{
|
||||
struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
|
||||
|
||||
if (!bmpbgp)
|
||||
return 0;
|
||||
|
||||
bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, vrf_state_unknown);
|
||||
|
||||
if (bmpbgp->vrf_state == vrf_state_down)
|
||||
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_all_safe(bmpbgp, bmp_peerstate(bgp->peer_self, withdraw));
|
||||
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 (!s)
|
||||
return 0;
|
||||
|
||||
if (bmpbgp) {
|
||||
frr_each (bmp_targets, &bmpbgp->targets, bt) {
|
||||
ret = bmp_bgp_attribute_updated_instance(bt, &bmpbgp->vrf_state, bgp,
|
||||
withdraw, s);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -263,6 +263,57 @@ def test_peer_down():
|
||||
assert success, "Checking the updated prefixes has been failed !."
|
||||
|
||||
|
||||
def test_bgp_routerid_changed():
|
||||
"""
|
||||
Checking for BGP loc-rib up messages with new router-id
|
||||
"""
|
||||
tgen = get_topogen()
|
||||
|
||||
tgen.gears["r1import"].vtysh_cmd(
|
||||
"""
|
||||
configure terminal
|
||||
router bgp 65501 vrf vrf1
|
||||
bgp router-id 192.168.1.77
|
||||
"""
|
||||
)
|
||||
|
||||
peers = ["0.0.0.0"]
|
||||
|
||||
logger.info(
|
||||
"checking for BMP peer down LOC-RIB message with router-id set to 192.168.0.1."
|
||||
)
|
||||
test_func = partial(
|
||||
bmp_check_for_peer_message,
|
||||
peers,
|
||||
"peer down",
|
||||
tgen.gears["bmp1import"],
|
||||
os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
|
||||
is_rd_instance=True,
|
||||
peer_bgp_id="192.168.0.1",
|
||||
)
|
||||
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
|
||||
assert (
|
||||
success
|
||||
), "Checking the BMP peer down LOC-RIB message with router-id set to 192.168.0.1 failed !."
|
||||
|
||||
logger.info(
|
||||
"checking for BMP peer up LOC-RIB message with router-id set to 192.168.1.77."
|
||||
)
|
||||
test_func = partial(
|
||||
bmp_check_for_peer_message,
|
||||
peers,
|
||||
"peer up",
|
||||
tgen.gears["bmp1import"],
|
||||
os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
|
||||
is_rd_instance=True,
|
||||
peer_bgp_id="192.168.1.77",
|
||||
)
|
||||
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
|
||||
assert (
|
||||
success
|
||||
), "Checking the BMP peer up LOC-RIB message with router-id set to 192.168.1.77 failed !."
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = ["-s"] + sys.argv[1:]
|
||||
sys.exit(pytest.main(args))
|
||||
|
Loading…
Reference in New Issue
Block a user