mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 09:43:27 +00:00
bgpd, topotests: bmp, add loc-rib peer up event for imported bgp
Add the emission of a loc-rib peer up event for an imported bgp instance at import-vrf configuration. Add a test to control in the BMP collector that the peer up message is the one from that BGP instance. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
b68b4aa70e
commit
ab31e964e4
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 !."
|
||||
|
Loading…
Reference in New Issue
Block a user