summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2024-09-23 12:01:20 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2025-01-07 15:35:31 +0100
commit841ae62a898d12d29bd8f6e721de423870650439 (patch)
treeda7f037d1ba66e4674b66aa479e3cb4d087beb57 /bgpd
parentb1ebe54b29524ed3df5c92cac65f06ab374eb236 (diff)
bgpd: bmp, handle imported bgp instances in bmp_send_peerup()
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 <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_bmp.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c
index 3bac6a8f1d..f98361f0ab 100644
--- a/bgpd/bgp_bmp.c
+++ b/bgpd/bgp_bmp.c
@@ -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;
}
@@ -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");
@@ -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;
}