Skip to content

Commit b1ebe54

Browse files
committed
bgpd: bmp, handle imported bgp instances in bmp_mirror
Modify the bmp_mirror() function to export the route update information to all BMP instances importing it. Signed-off-by: Philippe Guibert <[email protected]>
1 parent ee605d8 commit b1ebe54

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

bgpd/bgp_bmp.c

+35-21
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,13 @@ static void bmp_mirror_cull(struct bmp_bgp *bmpbgp)
752752
static int bmp_mirror_packet(struct peer *peer, uint8_t type, bgp_size_t size,
753753
struct stream *packet)
754754
{
755-
struct bmp_bgp *bmpbgp = bmp_bgp_find(peer->bgp);
755+
struct bmp_bgp *bmpbgp;
756756
struct timeval tv;
757-
struct bmp_mirrorq *qitem;
757+
struct bmp_mirrorq *qitem = NULL;
758758
struct bmp_targets *bt;
759759
struct bmp *bmp;
760+
struct bgp *bgp_vrf;
761+
struct listnode *node;
760762

761763
frrtrace(3, frr_bgp, bmp_mirror_packet, peer, type, packet);
762764

@@ -772,36 +774,48 @@ static int bmp_mirror_packet(struct peer *peer, uint8_t type, bgp_size_t size,
772774
memcpy(bbpeer->open_rx, packet->data, size);
773775
}
774776

775-
if (!bmpbgp)
776-
return 0;
777777

778778
qitem = XCALLOC(MTYPE_BMP_MIRRORQ, sizeof(*qitem) + size);
779779
qitem->peerid = peer->qobj_node.nid;
780780
qitem->tv = tv;
781781
qitem->len = size;
782782
memcpy(qitem->data, packet->data, size);
783783

784-
frr_each(bmp_targets, &bmpbgp->targets, bt) {
785-
if (!bt->mirror)
784+
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) {
785+
bmpbgp = bmp_bgp_find(bgp_vrf);
786+
if (!bmpbgp)
786787
continue;
787-
frr_each(bmp_session, &bt->sessions, bmp) {
788-
qitem->refcount++;
789-
if (!bmp->mirrorpos)
790-
bmp->mirrorpos = qitem;
791-
pullwr_bump(bmp->pullwr);
792-
}
793-
}
794-
if (qitem->refcount == 0)
795-
XFREE(MTYPE_BMP_MIRRORQ, qitem);
796-
else {
797-
bmpbgp->mirror_qsize += sizeof(*qitem) + size;
798-
bmp_mirrorq_add_tail(&bmpbgp->mirrorq, qitem);
788+
frr_each (bmp_targets, &bmpbgp->targets, bt) {
789+
if (!bt->mirror)
790+
continue;
791+
792+
if (bgp_vrf != peer->bgp && !bmp_imported_bgp_find(bt, peer->bgp->name))
793+
continue;
794+
795+
frr_each (bmp_session, &bt->sessions, bmp) {
796+
if (!qitem) {
797+
qitem = XCALLOC(MTYPE_BMP_MIRRORQ, sizeof(*qitem) + size);
798+
qitem->peerid = peer->qobj_node.nid;
799+
qitem->tv = tv;
800+
qitem->len = size;
801+
memcpy(qitem->data, packet->data, size);
802+
}
799803

800-
bmp_mirror_cull(bmpbgp);
804+
qitem->refcount++;
805+
if (!bmp->mirrorpos)
806+
bmp->mirrorpos = qitem;
807+
pullwr_bump(bmp->pullwr);
808+
}
809+
bmpbgp->mirror_qsize += sizeof(*qitem) + size;
810+
bmp_mirrorq_add_tail(&bmpbgp->mirrorq, qitem);
801811

802-
bmpbgp->mirror_qsizemax = MAX(bmpbgp->mirror_qsizemax,
803-
bmpbgp->mirror_qsize);
812+
bmp_mirror_cull(bmpbgp);
813+
814+
bmpbgp->mirror_qsizemax = MAX(bmpbgp->mirror_qsizemax, bmpbgp->mirror_qsize);
815+
}
804816
}
817+
if (qitem && qitem->refcount == 0)
818+
XFREE(MTYPE_BMP_MIRRORQ, qitem);
805819
return 0;
806820
}
807821

0 commit comments

Comments
 (0)