diff options
-rw-r--r-- | bgpd/bgp_bmp.c | 32 | ||||
-rw-r--r-- | bgpd/bgp_bmp.h | 1 | ||||
-rw-r--r-- | tests/topotests/bgp_bmp/test_bgp_bmp_3.py | 1 |
3 files changed, 28 insertions, 6 deletions
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index b1f8c3f10..880cb2c8f 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -650,21 +650,40 @@ static int bmp_send_peerup(struct bmp *bmp) return 0; } -static int bmp_send_peerup_vrf(struct bmp *bmp) +static void bmp_send_peerup_vrf_per_instance(struct bmp *bmp, enum bmp_vrf_state *vrf_state, + struct bgp *bgp) { - struct bmp_bgp *bmpbgp = bmp->targets->bmpbgp; struct stream *s; /* send unconditionally because state may has been set before the * session was up. and in this case the peer up has not been sent. */ - bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bmpbgp->bgp, vrf_state_unknown); + bmp_bgp_update_vrf_status(vrf_state, bgp, vrf_state_unknown); - s = bmp_peerstate(bmpbgp->bgp->peer_self, bmpbgp->vrf_state == vrf_state_down); + s = bmp_peerstate(bgp->peer_self, *vrf_state == vrf_state_down); if (s) { pullwr_write_stream(bmp->pullwr, s); stream_free(s); } +} + +static int bmp_send_peerup_vrf(struct bmp *bmp) +{ + struct bgp *bgp; + struct bmp_imported_bgp *bib; + struct bmp_bgp *bmpbgp = bmp->targets->bmpbgp; + struct bmp_targets *bt; + + bmp_send_peerup_vrf_per_instance(bmp, &bmpbgp->vrf_state, bmpbgp->bgp); + + frr_each (bmp_targets, &bmpbgp->targets, bt) { + frr_each (bmp_imported_bgps, &bt->imported_bgps, bib) { + bgp = bgp_lookup_by_name(bib->name); + if (!bgp) + continue; + bmp_send_peerup_vrf_per_instance(bmp, &bib->vrf_state, bgp); + } + } return 0; } @@ -2341,6 +2360,7 @@ static struct bmp_imported_bgp *bmp_imported_bgp_get(struct bmp_targets *bt, cha bib = XCALLOC(MTYPE_BMP_IMPORTED_BGP, sizeof(*bib)); if (name) bib->name = XSTRDUP(MTYPE_BMP_IMPORTED_BGP, name); + bib->vrf_state = vrf_state_unknown; bib->targets = bt; bmp_imported_bgps_add(&bt->imported_bgps, bib); @@ -2747,13 +2767,13 @@ DEFPY(bmp_import_vrf, bgp = bgp_lookup_by_name(bib->name); if (!bgp) return CMD_SUCCESS; - /* TODO: handle loc-rib peer up changes - * TODO: Start the syncronisation + /* 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); + bmp_send_peerup_vrf_per_instance(bmp, &bib->vrf_state, bgp); } return CMD_SUCCESS; } diff --git a/bgpd/bgp_bmp.h b/bgpd/bgp_bmp.h index f5d981d63..6eb3eacb5 100644 --- a/bgpd/bgp_bmp.h +++ b/bgpd/bgp_bmp.h @@ -283,6 +283,7 @@ struct bmp_imported_bgp { struct bmp_imported_bgps_item bib; struct bmp_targets *targets; char *name; + enum bmp_vrf_state vrf_state; }; struct bmp_bgp { diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp_3.py b/tests/topotests/bgp_bmp/test_bgp_bmp_3.py index 0d2bf181b..088f4cb45 100644 --- a/tests/topotests/bgp_bmp/test_bgp_bmp_3.py +++ b/tests/topotests/bgp_bmp/test_bgp_bmp_3.py @@ -222,6 +222,7 @@ def test_peer_up(): "peer up", tgen.gears["bmp1import"], os.path.join(tgen.logdir, "bmp1import", "bmp.log"), + is_rd_instance=True, ) success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1) assert success, "Checking the updated prefixes has been failed !." |