summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2024-09-19 18:35:50 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2025-01-07 15:35:31 +0100
commitc2c95b29ba27574a92626242740e61cb7ffc5ca8 (patch)
treeb10279f55d4ea8b337035c01af1685cadd59a821 /bgpd
parentbgpd: add 'bmp import-vrf-view' command (diff)
downloadfrr-c2c95b29ba27574a92626242740e61cb7ffc5ca8.tar.xz
frr-c2c95b29ba27574a92626242740e61cb7ffc5ca8.zip
bgpd: bmp, rework the bmp_route_update() function
Separate the bmp_route_update() function in two, by passing the bgpbmp structure to the internal function instead of the bgp instance. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_bmp.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c
index c67935c52..d1f2083f7 100644
--- a/bgpd/bgp_bmp.c
+++ b/bgpd/bgp_bmp.c
@@ -50,6 +50,9 @@ static struct bmp_bgp_peer *bmp_bgp_peer_find(uint64_t peerid);
static struct bmp_bgp_peer *bmp_bgp_peer_get(struct peer *peer);
static void bmp_active_disconnected(struct bmp_active *ba);
static void bmp_active_put(struct bmp_active *ba);
+static int bmp_route_update_bgpbmp(struct bmp_targets *bt, afi_t afi, safi_t safi,
+ struct bgp_dest *bn, struct bgp_path_info *old_route,
+ struct bgp_path_info *new_route);
DEFINE_MGROUP(BMP, "BMP (BGP Monitoring Protocol)");
@@ -3207,11 +3210,12 @@ static int bmp_route_update(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_path_info *old_route,
struct bgp_path_info *new_route)
{
- bool is_locribmon_enabled = false;
bool is_withdraw = old_route && !new_route;
struct bgp_path_info *updated_route =
is_withdraw ? old_route : new_route;
-
+ struct bmp_bgp *bmpbgp;
+ struct bmp_targets *bt;
+ int ret = 0;
/* this should never happen */
if (!updated_route) {
@@ -3219,23 +3223,25 @@ static int bmp_route_update(struct bgp *bgp, afi_t afi, safi_t safi,
return 0;
}
- struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
- struct peer *peer = updated_route->peer;
- struct bmp_targets *bt;
- struct bmp *bmp;
-
+ bmpbgp = bmp_bgp_find(bgp);
if (!bmpbgp)
return 0;
- frr_each (bmp_targets, &bmpbgp->targets, bt) {
- if (CHECK_FLAG(bt->afimon[afi][safi], BMP_MON_LOC_RIB)) {
- is_locribmon_enabled = true;
- break;
- }
- }
+ frr_each (bmp_targets, &bmpbgp->targets, bt)
+ if (CHECK_FLAG(bt->afimon[afi][safi], BMP_MON_LOC_RIB))
+ ret = bmp_route_update_bgpbmp(bt, afi, safi, bn, old_route, new_route);
+ return ret;
+}
- if (!is_locribmon_enabled)
- return 0;
+static int bmp_route_update_bgpbmp(struct bmp_targets *bt, afi_t afi, safi_t safi,
+ struct bgp_dest *bn, struct bgp_path_info *old_route,
+ struct bgp_path_info *new_route)
+{
+ bool is_withdraw = old_route && !new_route;
+ struct bgp_path_info *updated_route = is_withdraw ? old_route : new_route;
+ struct peer *peer = updated_route->peer;
+ struct bmp *bmp;
+ struct bmp_queue_entry *last_item;
/* route is not installed in locrib anymore and rib uptime was saved */
if (old_route && old_route->extra)
@@ -3249,26 +3255,20 @@ static int bmp_route_update(struct bgp *bgp, afi_t afi, safi_t safi,
bgp_path_info_extra_get(new_route)->bgp_rib_uptime =
monotime(NULL);
- frr_each (bmp_targets, &bmpbgp->targets, bt) {
- if (CHECK_FLAG(bt->afimon[afi][safi], BMP_MON_LOC_RIB)) {
-
- struct bmp_queue_entry *last_item = bmp_process_one(
- bt, &bt->locupdhash, &bt->locupdlist, bgp, afi,
- safi, bn, peer);
+ last_item = bmp_process_one(bt, &bt->locupdhash, &bt->locupdlist, bt->bgp, afi, safi, bn,
+ peer);
- /* if bmp_process_one returns NULL
- * we don't have anything to do next
- */
- if (!last_item)
- continue;
+ /* if bmp_process_one returns NULL
+ * we don't have anything to do next
+ */
+ if (!last_item)
+ return 0;
- frr_each (bmp_session, &bt->sessions, bmp) {
- if (!bmp->locrib_queuepos)
- bmp->locrib_queuepos = last_item;
+ frr_each (bmp_session, &bt->sessions, bmp) {
+ if (!bmp->locrib_queuepos)
+ bmp->locrib_queuepos = last_item;
- pullwr_bump(bmp->pullwr);
- };
- }
+ pullwr_bump(bmp->pullwr);
};
return 0;