mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 20:51:17 +00:00
bgpd, topotests: bmp, send peer down when unconfiguring imported vrf
When unconfiguring an imported BGP instance, a peer down should be sent to notify BMP collector that the BGP instance is leaving. Add a test that controls the presence of the peer down loc-rib message. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
62891717e3
commit
ca7699f4ae
@ -705,6 +705,17 @@ static void bmp_send_bt_safe(struct bmp_targets *bt, struct stream *s)
|
||||
stream_free(s);
|
||||
}
|
||||
|
||||
static void bmp_send_peerdown_vrf_per_instance(struct bmp_targets *bt, struct bgp *bgp)
|
||||
{
|
||||
struct stream *s;
|
||||
|
||||
s = bmp_peerstate(bgp->peer_self, true);
|
||||
if (!s)
|
||||
return;
|
||||
bmp_send_bt(bt, s);
|
||||
stream_free(s);
|
||||
}
|
||||
|
||||
/* send a stream to all bmp sessions configured in a bgp instance */
|
||||
/* XXX: kludge - filling the pullwr's buffer */
|
||||
static void bmp_send_all(struct bmp_bgp *bmpbgp, struct stream *s)
|
||||
@ -2765,7 +2776,10 @@ DEFPY(bmp_import_vrf,
|
||||
vty_out(vty, "%% BMP imported BGP instance not found\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
/* TODO: handle loc-rib peer down change */
|
||||
bgp = bgp_lookup_by_name(bib->name);
|
||||
if (!bgp)
|
||||
return CMD_WARNING;
|
||||
bmp_send_peerdown_vrf_per_instance(bt, bgp);
|
||||
bmp_imported_bgp_put(bt, bib);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
@ -188,6 +188,31 @@ def _test_prefixes(policy, vrf=None, step=0):
|
||||
assert success, "Checking the updated prefixes has failed ! %s" % res
|
||||
|
||||
|
||||
def _test_peer_up(check_locrib=True):
|
||||
"""
|
||||
Checking for BMP peers up messages
|
||||
"""
|
||||
|
||||
tgen = get_topogen()
|
||||
if check_locrib:
|
||||
peers = ["0.0.0.0", "192.168.1.3", "192:167::3"]
|
||||
else:
|
||||
peers = ["192.168.1.3", "192:167::3"]
|
||||
|
||||
logger.info("checking for BMP peers up messages")
|
||||
|
||||
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,
|
||||
)
|
||||
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
|
||||
assert success, "Checking the updated prefixes has been failed !."
|
||||
|
||||
|
||||
def test_bmp_server_logging():
|
||||
"""
|
||||
Assert the logging of the bmp server.
|
||||
@ -206,26 +231,8 @@ def test_bmp_server_logging():
|
||||
assert success, "The BMP server is not logging"
|
||||
|
||||
|
||||
def test_peer_up():
|
||||
"""
|
||||
Checking for BMP peers up messages
|
||||
"""
|
||||
|
||||
tgen = get_topogen()
|
||||
peers = ["0.0.0.0", "192.168.1.3", "192:167::3"]
|
||||
|
||||
logger.info("checking for BMP peers up messages")
|
||||
|
||||
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,
|
||||
)
|
||||
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
|
||||
assert success, "Checking the updated prefixes has been failed !."
|
||||
def test_bmp_peer_up_start():
|
||||
_test_peer_up()
|
||||
|
||||
|
||||
def test_bmp_bgp_unicast():
|
||||
@ -353,6 +360,43 @@ def test_bgp_instance_flapping():
|
||||
assert success, "Checking the BMP peer up LOC-RIB message failed !."
|
||||
|
||||
|
||||
def test_peer_up_after_flush():
|
||||
"""
|
||||
Checking for BMP peers down messages
|
||||
"""
|
||||
_test_peer_up(check_locrib=False)
|
||||
|
||||
|
||||
def test_peer_down_locrib():
|
||||
"""
|
||||
Checking for BMP peers down loc-rib messages
|
||||
"""
|
||||
tgen = get_topogen()
|
||||
|
||||
tgen.gears["r1import"].vtysh_cmd(
|
||||
"""
|
||||
configure terminal
|
||||
router bgp 65501
|
||||
bmp targets bmp1
|
||||
no bmp import-vrf-view vrf1
|
||||
"""
|
||||
)
|
||||
|
||||
peers = ["0.0.0.0"]
|
||||
|
||||
logger.info("checking for BMP peers down messages")
|
||||
|
||||
test_func = partial(
|
||||
bmp_check_for_peer_message,
|
||||
peers,
|
||||
"peer down",
|
||||
tgen.gears["bmp1import"],
|
||||
os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
|
||||
)
|
||||
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
|
||||
assert success, "Checking the BMP peer down message has failed !."
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = ["-s"] + sys.argv[1:]
|
||||
sys.exit(pytest.main(args))
|
||||
|
Loading…
Reference in New Issue
Block a user