Skip to content

Commit

Permalink
bgpd: bmp, handle imported bgp instances for bmp statistics
Browse files Browse the repository at this point in the history
Only the BMP statistics of the current BGP instance are handled.
Extend the transmission of BMP statistics for imported BGP instances.
-  Separate the bmp_stats() function in two, and pass the bgp
instance to process its bgp peers, as a separate parameter.
- Pass the BGP peers from imported instances as parameter

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Jan 7, 2025
1 parent 841ae62 commit 5fda10f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static int bmp_route_update_bgpbmp(struct bmp_targets *bt, afi_t afi, safi_t saf
struct bgp_path_info *new_route);
static void bmp_send_all_bgp(struct peer *peer, bool down);
static struct bmp_imported_bgp *bmp_imported_bgp_find(struct bmp_targets *bt, char *name);
static void bmp_stats_per_instance(struct bgp *bgp, struct bmp_targets *bt);

DEFINE_MGROUP(BMP, "BMP (BGP Monitoring Protocol)");

Expand Down Expand Up @@ -1798,21 +1799,33 @@ static void bmp_stat_put_u64(struct stream *s, size_t *cnt, uint16_t type,
static void bmp_stats(struct event *thread)
{
struct bmp_targets *bt = EVENT_ARG(thread);
struct bmp_imported_bgp *bib;
struct bgp *bgp;

if (bt->stat_msec)
event_add_timer_msec(bm->master, bmp_stats, bt, bt->stat_msec, &bt->t_stats);

bmp_stats_per_instance(bt->bgp, bt);
frr_each (bmp_imported_bgps, &bt->imported_bgps, bib) {
bgp = bgp_lookup_by_name(bib->name);
if (bgp)
bmp_stats_per_instance(bgp, bt);
}
}

static void bmp_stats_per_instance(struct bgp *bgp, struct bmp_targets *bt)
{
struct stream *s;
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,
&bt->t_stats);

gettimeofday(&tv, NULL);

/* Walk down all peers */
for (ALL_LIST_ELEMENTS_RO(bt->bgp->peer, node, peer)) {
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
size_t count = 0, count_pos, len;

if (!peer_established(peer->connection))
Expand Down

0 comments on commit 5fda10f

Please sign in to comment.