Skip to content

Commit

Permalink
bgpd: update bmp bgp labels
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Younsi <[email protected]>
  • Loading branch information
mxyns committed Nov 9, 2024
1 parent f45cb25 commit 706e774
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,7 @@ static int bmp_monitor_rib_out_pre_updgrp_walkcb(struct update_group *updgrp, vo
struct peer_af *paf;
uint32_t addpath_tx_id;
struct bgp_path_info *bpi = ctx->bpi;
uint8_t bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);

UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
struct attr dummy_attr = { 0 };
Expand All @@ -1429,8 +1430,8 @@ static int bmp_monitor_rib_out_pre_updgrp_walkcb(struct update_group *updgrp, vo
bmp_get_peer_type(PAF_PEER(paf)),
bgp_dest_get_prefix(ctx->dest), ctx->prd, ctx->attr,
SUBGRP_AFI(subgrp), SUBGRP_SAFI(subgrp), addpath_tx_id,
(time_t)(-1L), bpi && bpi->extra ? bpi->extra->labels->label : NULL,
bpi && bpi->extra ? bpi->extra->labels->num_labels : 0);
(time_t)(-1L), bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);

*ctx->written_ref = true;
}
Expand Down Expand Up @@ -1482,6 +1483,7 @@ static int bmp_monitor_rib_out_post_updgrp_walkcb(struct update_group *updgrp, v
struct attr *advertised_attr;
uint32_t addpath_tx_id;
struct bgp_path_info *bpi = ctx->bpi;
uint8_t bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);

UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
addpath_tx_id =
Expand All @@ -1503,8 +1505,8 @@ static int bmp_monitor_rib_out_post_updgrp_walkcb(struct update_group *updgrp, v
bmp_get_peer_type(PAF_PEER(paf)), ctx->pfx, ctx->prd,
advertised_attr, SUBGRP_AFI(subgrp), SUBGRP_SAFI(subgrp),
addpath_tx_id, (time_t)(-1L),
bpi && bpi->extra ? bpi->extra->labels->label : NULL,
bpi && bpi->extra ? bpi->extra->labels->num_labels : 0);
bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);

*ctx->written_ref = true;
}
Expand Down Expand Up @@ -1901,8 +1903,8 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr)

/* retrieve info about the selected path
*/
bool is_vpn = (bqe->afi == AFI_L2VPN && bqe->safi == SAFI_EVPN) ||
(bqe->safi == SAFI_MPLS_VPN);
bool is_vpn = (afi == AFI_L2VPN && safi == SAFI_EVPN) ||
(safi == SAFI_MPLS_VPN);

struct prefix_rd *prd = is_vpn ? &bqe->rd : NULL;

Expand All @@ -1915,21 +1917,22 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr)
if (bpi->peer != peer || bpi->addpath_rx_id != addpath_rx_id)
continue;

uint8_t bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);

/* rib-in post-policy configured and path is valid */
if (CHECK_FLAG(flags, BMP_MON_IN_POSTPOLICY) &&
CHECK_FLAG(bpi->flags, BGP_PATH_VALID)) {
bmp_monitor(bmp, peer, BMP_PEER_FLAG_L, bmp_get_peer_type(peer), &bqe->p,
prd, bpi->attr, afi, safi, addpath_rx_id, bpi->uptime,
bpi && bpi->extra ? bpi->extra->labels->label : NULL,
bpi && bpi->extra ? bpi->extra->labels->num_labels : 0);
bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);
ribin = bpi;
written = true;
}

/* loc-rib configured and path is selected */
if (CHECK_FLAG(flags, BMP_MON_LOC_RIB) &&
CHECK_FLAG(bpi->flags, BGP_PATH_SELECTED | BGP_PATH_MULTIPATH)) {
uint8_t bpi_num_labels = BGP_PATH_INFO_NUM_LABELS(bpi);

bmp_monitor(bmp, peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE, &bqe->p, prd,
bpi->attr, afi, safi, addpath_rx_id,
Expand Down

0 comments on commit 706e774

Please sign in to comment.