Skip to content

Commit 6c7b2ab

Browse files
committed
bgpd, topotests: bmp imported bgp, send peer up events when config param changed
When a BGP instance is created or becomes valid, and when a parameter is updated (router-id, route distinguisher), the peer up messages other than loc rib peer up messages, are sent. Add a test that controls if peer down and peer up messages are sent accordingly with correct route distinguisher values. Signed-off-by: Philippe Guibert <[email protected]>
1 parent ca7699f commit 6c7b2ab

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

bgpd/bgp_bmp.c

+23-1
Original file line numberDiff line numberDiff line change
@@ -3443,6 +3443,7 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw)
34433443
struct bmp_imported_bgp *bib;
34443444
int ret = 0;
34453445
struct stream *s = bmp_peerstate(bgp->peer_self, withdraw);
3446+
struct bmp *bmp;
34463447

34473448
if (!s)
34483449
return 0;
@@ -3451,6 +3452,10 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw)
34513452
frr_each (bmp_targets, &bmpbgp->targets, bt) {
34523453
ret = bmp_bgp_attribute_updated_instance(bt, &bmpbgp->vrf_state, bgp,
34533454
withdraw, s);
3455+
if (withdraw)
3456+
continue;
3457+
frr_each (bmp_session, &bt->sessions, bmp)
3458+
bmp_send_peerup_per_instance(bmp, bgp);
34543459
}
34553460
}
34563461

@@ -3466,6 +3471,10 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw)
34663471
continue;
34673472
ret += bmp_bgp_attribute_updated_instance(bt, &bib->vrf_state, bgp,
34683473
withdraw, s);
3474+
if (withdraw)
3475+
continue;
3476+
frr_each (bmp_session, &bt->sessions, bmp)
3477+
bmp_send_peerup_per_instance(bmp, bgp);
34693478
}
34703479
}
34713480
}
@@ -3490,10 +3499,18 @@ static void _bmp_vrf_state_changed_internal(struct bgp *bgp, enum bmp_vrf_state
34903499
struct bmp_targets *bt;
34913500
struct listnode *node;
34923501
struct bmp_imported_bgp *bib;
3502+
struct bmp *bmp;
34933503

3494-
if (bmpbgp && bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, vrf_state))
3504+
if (bmpbgp && bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, vrf_state)) {
34953505
bmp_send_all_safe(bmpbgp, bmp_peerstate(bgp->peer_self,
34963506
bmpbgp->vrf_state == vrf_state_down));
3507+
if (vrf_state == vrf_state_up && bmpbgp->vrf_state == vrf_state_up) {
3508+
frr_each (bmp_targets, &bmpbgp->targets, bt) {
3509+
frr_each (bmp_session, &bt->sessions, bmp)
3510+
bmp_send_peerup_per_instance(bmp, bgp);
3511+
}
3512+
}
3513+
}
34973514

34983515
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) {
34993516
bmpbgp = bmp_bgp_find(bgp_vrf);
@@ -3509,6 +3526,11 @@ static void _bmp_vrf_state_changed_internal(struct bgp *bgp, enum bmp_vrf_state
35093526
bmp_send_bt_safe(bt, bmp_peerstate(bgp->peer_self,
35103527
bib->vrf_state ==
35113528
vrf_state_down));
3529+
if (vrf_state == vrf_state_up &&
3530+
bib->vrf_state == vrf_state_up) {
3531+
frr_each (bmp_session, &bt->sessions, bmp)
3532+
bmp_send_peerup_per_instance(bmp, bgp);
3533+
}
35123534
break;
35133535
}
35143536
}

tests/topotests/bgp_bmp/test_bgp_bmp_3.py

+75
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,81 @@ def test_peer_down():
270270
assert success, "Checking the updated prefixes has been failed !."
271271

272272

273+
def test_reconfigure_route_distinguisher_vrf1():
274+
"""
275+
Checking for BMP peers down messages
276+
"""
277+
tgen = get_topogen()
278+
279+
bmp_update_seq(
280+
tgen.gears["bmp1import"], os.path.join(tgen.logdir, "bmp1import", "bmp.log")
281+
)
282+
peers = ["0.0.0.0"]
283+
284+
tgen.gears["r1import"].vtysh_cmd(
285+
"""
286+
configure terminal
287+
router bgp 65501 vrf vrf1
288+
address-family ipv4 unicast
289+
rd vpn export 666:22
290+
exit-address-family
291+
address-family ipv6 unicast
292+
rd vpn export 666:22
293+
"""
294+
)
295+
logger.info(
296+
"checking for BMP peer down LOC-RIB message with route-distinguisher set to 444:1"
297+
)
298+
test_func = partial(
299+
bmp_check_for_peer_message,
300+
peers,
301+
"peer down",
302+
tgen.gears["bmp1import"],
303+
os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
304+
is_rd_instance=True,
305+
peer_distinguisher="444:1",
306+
)
307+
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
308+
assert (
309+
success
310+
), "Checking the BMP peer down LOC-RIB message with route-distinguisher set to 444:1 failed !."
311+
312+
logger.info(
313+
"checking for BMP peer up LOC-RIB messages with route-distinguisher set to 666:22"
314+
)
315+
test_func = partial(
316+
bmp_check_for_peer_message,
317+
peers,
318+
"peer up",
319+
tgen.gears["bmp1import"],
320+
os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
321+
is_rd_instance=True,
322+
peer_distinguisher="666:22",
323+
)
324+
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
325+
assert (
326+
success
327+
), "Checking the BMP peer up LOC-RIB message with route-distinguisher set to 666:22 failed !."
328+
329+
logger.info(
330+
"checking for BMP peer up messages with route-distinguisher set to 666:22"
331+
)
332+
peers = ["192.168.1.3", "192:167::3"]
333+
test_func = partial(
334+
bmp_check_for_peer_message,
335+
peers,
336+
"peer up",
337+
tgen.gears["bmp1import"],
338+
os.path.join(tgen.logdir, "bmp1import", "bmp.log"),
339+
is_rd_instance=True,
340+
peer_distinguisher="666:22",
341+
)
342+
success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
343+
assert (
344+
success
345+
), "Checking the BMP peer up messages with route-distinguisher set to 666:22 failed !."
346+
347+
273348
def test_bgp_routerid_changed():
274349
"""
275350
Checking for BGP loc-rib up messages with new router-id

0 commit comments

Comments
 (0)