From 8198dec807ca8cbd00421fd88d607ff6b00fd484 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 30 Oct 2024 21:24:44 +0100 Subject: [PATCH] bgpd, topotests: fix wrong peer type for loc-rib peer events When running the bgp_bmp test, peer_up message from the loc-rib are received with a wrong peer type. > {"peer_type": "global instance", "policy": "pre-policy", "ipv6": false, "peer_ip": "0.0.0.0", > "peer_distinguisher": "0:0", "peer_asn": 0, "peer_bgp_id": "0.0.0.0", > "timestamp": "2024-10-16 21:59:53.111963", "bmp_log_type": "peer up", "local_ip": "0.0.0.0", > "local_port": 0, "remote_port": 0, "seq": 1} RFC9069 mentions in 5.1 that peer address must be set to 0.0.0.0, and the peer_type value must be set to 3. Today, the value set is 0 (global instance). This is wrong. Fix this by modifying the BMP client, update the peer type value to loc-rib on peer up messages. Modify the current BMP test, by checking the peer up messages for the 0.0.0.0 IP address (which is the value used for loc-rib). > {"peer_type": "loc-rib instance", "is_filtered": false, "policy": "loc-rib", > "peer_distinguisher": "0:0", "peer_asn": 65501, "peer_bgp_id": "192.168.0.1", > "timestamp": "2024-10-16 21:59:53.111963", "bmp_log_type": "peer up", "local_ip": "0.0.0.0", > "local_port": 0, "remote_port": 0, "seq": 1} Signed-off-by: Philippe Guibert --- bgpd/bgp_bmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index d6df560260..e86e80ba27 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -481,6 +481,9 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down) /* TODO: remove this when other RD and local instances supported */ peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE; + if (is_locrib == false) + peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE; + #define BGP_BMP_MAX_PACKET_SIZE 1024 #define BMP_PEERUP_INFO_TYPE_STRING 0 s = stream_new(BGP_MAX_PACKET_SIZE); @@ -552,9 +555,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, - BMP_PEER_TYPE_GLOBAL_INSTANCE, 0, - &uptime_real); + bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, 0, &uptime_real); type_pos = stream_get_endp(s); stream_putc(s, 0); /* placeholder for down reason */ -- 2.39.5