From 986ff8b916d707da8900be36092f9e7575d0a856 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 31 Oct 2024 10:19:48 +0100 Subject: [PATCH] bgpd, topotests: bmp, fix wrong peer distinguisher value for peer vrf up/down When running the bgp_bmp_2 vrf test, peer vrf up/down events from the pre and post policy are received with a wrong peer distinguisher value. > {"peer_type": "route distinguisher instance", "policy": "pre-policy", > "ipv6": true, "peer_ip": "192:168::2", "peer_distinguisher": "0:0", > "peer_asn": 65502, "peer_bgp_id": "192.168.0.2", "timestamp": > "2024-10-16 21:59:53.111962", "bmp_log_type": "peer up", "local_ip": > "192:168::1", "local_port": 179, "remote_port": 50836, "seq": 5} RFC7854 mentions in 4.2 that if the peer is a "RD Instance Peer", it is set to the route distinguisher of the particular instance the peer belongs to. Fix this by modifying the BMP client, update the peer distinguisher value by filling the peer distinguisher in the bmp_peerstate function. > {"peer_type": "route distinguisher instance", "policy": "pre-policy", > "ipv6": true, "peer_ip": "192:168::2", "peer_distinguisher": "444:1", > "peer_asn": 65502, "peer_bgp_id": "192.168.0.2", "timestamp": > "2024-10-16 21:59:53.111962", "bmp_log_type": "peer up", "local_ip": > "192:168::1", "local_port": 179, "remote_port": 50836, "seq": 5} Add a test to check that peer_distinguisher value is not 0:0 when an RD instance is set. Signed-off-by: Philippe Guibert --- bgpd/bgp_bmp.c | 4 ++-- tests/topotests/bgp_bmp/bgpbmp.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 9ba092a5944e..271fc6d9e0d8 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -494,7 +494,7 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down) bmp_common_hdr(s, BMP_VERSION_3, BMP_TYPE_PEER_UP_NOTIFICATION); - bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, 0, &uptime_real); + bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, peer_distinguisher, &uptime_real); /* Local Address (16 bytes) */ if (is_locrib) @@ -556,7 +556,7 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down) bmp_common_hdr(s, BMP_VERSION_3, BMP_TYPE_PEER_DOWN_NOTIFICATION); - bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, 0, &uptime_real); + bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, peer_distinguisher, &uptime_real); type_pos = stream_get_endp(s); stream_putc(s, 0); /* placeholder for down reason */ diff --git a/tests/topotests/bgp_bmp/bgpbmp.py b/tests/topotests/bgp_bmp/bgpbmp.py index 9d9b3e49f81d..eac78a63f767 100644 --- a/tests/topotests/bgp_bmp/bgpbmp.py +++ b/tests/topotests/bgp_bmp/bgpbmp.py @@ -187,7 +187,7 @@ def bmp_check_for_prefixes( def bmp_check_for_peer_message( - expected_peers, bmp_log_type, bmp_collector, bmp_log_file, is_rd_instance=False + expected_peers, bmp_log_type, bmp_collector, bmp_log_file, is_rd_instance=False ): """ Check for the presence of a peer up message for the peer @@ -206,6 +206,8 @@ def bmp_check_for_peer_message( # get the list of pairs (prefix, policy, seq) for the given message type peers = [] for m in messages: + if is_rd_instance and m["peer_distinguisher"] == "0:0": + continue if ( "peer_ip" in m.keys() and m["peer_ip"] != "0.0.0.0"