Skip to content

Commit

Permalink
bgpd: bmp, handle imported bgp instances in bmp_send_peerup()
Browse files Browse the repository at this point in the history
When a BMP target comes up, only the peer up events of the
current BGP instance are sent.
- Apply the peer up event for external peers that are imported
by the BMP target.
- handle the peer up event when an imported vrf is
configured in a target.

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Jan 7, 2025
1 parent b1ebe54 commit 841ae62
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,21 +617,34 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
return s;
}


static int bmp_send_peerup(struct bmp *bmp)
static int bmp_send_peerup_per_instance(struct bmp *bmp, struct bgp *bgp)
{
struct peer *peer;
struct listnode *node;
struct stream *s;

/* Walk down all peers */
for (ALL_LIST_ELEMENTS_RO(bmp->targets->bgp->peer, node, peer)) {
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
s = bmp_peerstate(peer, false);
if (s) {
pullwr_write_stream(bmp->pullwr, s);
stream_free(s);
}
}
return 0;
}

static int bmp_send_peerup(struct bmp *bmp)
{
struct bmp_imported_bgp *bib;
struct bgp *bgp;

bmp_send_peerup_per_instance(bmp, bmp->targets->bgp);
frr_each (bmp_imported_bgps, &bmp->targets->imported_bgps, bib) {
bgp = bgp_lookup_by_name(bib->name);
if (bgp)
bmp_send_peerup_per_instance(bmp, bgp);
}

return 0;
}
Expand Down Expand Up @@ -2691,6 +2704,8 @@ DEFPY(bmp_import_vrf,
{
VTY_DECLVAR_CONTEXT_SUB(bmp_targets, bt);
struct bmp_imported_bgp *bib;
struct bgp *bgp;
struct bmp *bmp;

if (!bt->bgp) {
vty_out(vty, "%% BMP target, BGP instance not found\n");
Expand All @@ -2715,10 +2730,18 @@ DEFPY(bmp_import_vrf,
if (bib)
return CMD_SUCCESS;

bmp_imported_bgp_get(bt, (char *)vrfname);
/* TODO: handle loc-rib peer up and other peers state changes
bib = bmp_imported_bgp_get(bt, (char *)vrfname);
bgp = bgp_lookup_by_name(bib->name);
if (!bgp)
return CMD_SUCCESS;
/* TODO: handle loc-rib peer up changes
* TODO: Start the syncronisation
*/
frr_each (bmp_session, &bt->sessions, bmp) {
if (bmp->state != BMP_PeerUp && bmp->state != BMP_Run)
continue;
bmp_send_peerup_per_instance(bmp, bgp);
}
return CMD_SUCCESS;
}

Expand Down

0 comments on commit 841ae62

Please sign in to comment.