From 496e2f9605cedde4c52fb8a6e5b10f2d5b5054e6 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 23 Sep 2024 16:03:13 +0200 Subject: [PATCH] bgpd: bmp, add peer type and distinguisher support for stat messages Signed-off-by: Philippe Guibert --- bgpd/bgp_bmp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index f8a4343d07d3..fbc8242f3f9f 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -1729,6 +1729,8 @@ static void bmp_stats(struct event *thread) struct peer *peer; struct listnode *node; struct timeval tv; + uint8_t peer_type_flag; + uint64_t peer_distinguisher = 0; if (bt->stat_msec) event_add_timer_msec(bm->master, bmp_stats, bt, bt->stat_msec, @@ -1745,8 +1747,14 @@ static void bmp_stats(struct event *thread) s = stream_new(BGP_MAX_PACKET_SIZE); bmp_common_hdr(s, BMP_VERSION_3, BMP_TYPE_STATISTICS_REPORT); - bmp_per_peer_hdr(s, bt->bgp, peer, 0, - BMP_PEER_TYPE_GLOBAL_INSTANCE, 0, &tv); + peer_type_flag = bmp_get_peer_type(peer); + if (bmp_get_peer_distinguisher(peer->bgp, AFI_UNSPEC, peer_type_flag, + &peer_distinguisher)) { + zlog_warn("skipping bmp message for peer %s: can't get peer distinguisher", + peer->host); + continue; + } + bmp_per_peer_hdr(s, bt->bgp, peer, 0, peer_type_flag, peer_distinguisher, &tv); count_pos = stream_get_endp(s); stream_putl(s, 0);