From 5f379bebe82591c0665c29419fd3ab8758258e4e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 25 Jan 2024 13:07:37 -0500 Subject: [PATCH] bgpd: backpressure - cleanup bgp_zebra_XX func args Since installing/withdrawing routes into zebra is going to be changed around to be dest based in a list, - Retrieve the afi/safi to use based upon the dest's afi/safi instead of passing it in. - Prefix is known by the dest. Remove this arg as well Ticket: #3390099 Signed-off-by: Donald Sharp Signed-off-by: Rajasekar Raja --- bgpd/bgp_route.c | 17 +++++++---------- bgpd/bgp_zebra.c | 45 ++++++++++++++++++++++----------------------- bgpd/bgp_zebra.h | 10 ++++------ 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 520185e60f22..50c54a021d68 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3399,8 +3399,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, || new_select->sub_type == BGP_ROUTE_IMPORTED)) - bgp_zebra_announce(dest, p, old_select, - bgp, afi, safi); + bgp_zebra_announce(dest, old_select, + bgp); } } @@ -3517,10 +3517,9 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, */ if (old_select && is_route_parent_evpn(old_select)) - bgp_zebra_withdraw(p, old_select, bgp, afi, - safi); + bgp_zebra_withdraw(dest, old_select, bgp); - bgp_zebra_announce(dest, p, new_select, bgp, afi, safi); + bgp_zebra_announce(dest, new_select, bgp); } else { /* Withdraw the route from the kernel. */ if (old_select && old_select->type == ZEBRA_ROUTE_BGP @@ -3528,8 +3527,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, || old_select->sub_type == BGP_ROUTE_AGGREGATE || old_select->sub_type == BGP_ROUTE_IMPORTED)) - bgp_zebra_withdraw(p, old_select, bgp, afi, - safi); + bgp_zebra_withdraw(dest, old_select, bgp); } } @@ -4426,7 +4424,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, if (pi && pi->attr->rmap_table_id != new_attr.rmap_table_id) { if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) /* remove from RIB previous entry */ - bgp_zebra_withdraw(p, pi, bgp, afi, safi); + bgp_zebra_withdraw(dest, pi, bgp); } if (peer->sort == BGP_PEER_EBGP) { @@ -6052,8 +6050,7 @@ static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table, || pi->sub_type == BGP_ROUTE_IMPORTED)) { if (bgp_fibupd_safi(safi)) - bgp_zebra_withdraw(p, pi, bgp, afi, - safi); + bgp_zebra_withdraw(dest, pi, bgp); } dest = bgp_path_info_reap(dest, pi); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 26194f8601ba..a7bfca9073f9 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1524,9 +1524,8 @@ static void bgp_debug_zebra_nh(struct zapi_route *api) } } -void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, - struct bgp_path_info *info, struct bgp *bgp, afi_t afi, - safi_t safi) +void bgp_zebra_announce(struct bgp_dest *dest, struct bgp_path_info *info, + struct bgp *bgp) { struct bgp_path_info *bpi_ultimate; struct zapi_route api = { 0 }; @@ -1539,6 +1538,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, bool is_add; uint32_t nhg_id = 0; uint32_t recursion_flag = 0; + struct bgp_table *table = bgp_dest_table(dest); + const struct prefix *p = bgp_dest_get_prefix(dest); /* * BGP is installing this route and bgp has been configured @@ -1557,16 +1558,16 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, if (bgp->main_zebra_update_hold) return; - if (safi == SAFI_FLOWSPEC) { - bgp_pbr_update_entry(bgp, bgp_dest_get_prefix(dest), info, afi, - safi, true); + if (table->safi == SAFI_FLOWSPEC) { + bgp_pbr_update_entry(bgp, p, info, table->afi, table->safi, + true); return; } /* Make Zebra API structure. */ api.vrf_id = bgp->vrf_id; api.type = ZEBRA_ROUTE_BGP; - api.safi = safi; + api.safi = table->safi; api.prefix = *p; SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); @@ -1603,8 +1604,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, metric = info->attr->med; bgp_zebra_announce_parse_nexthop(info, p, bgp, &api, &valid_nh_count, - afi, safi, &nhg_id, &metric, &tag, - &allow_recursion); + table->afi, table->safi, &nhg_id, + &metric, &tag, &allow_recursion); is_add = (valid_nh_count || nhg_id) ? true : false; @@ -1657,7 +1658,7 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, api.tag = tag; } - distance = bgp_distance_apply(p, info, afi, safi, bgp); + distance = bgp_distance_apply(p, info, table->afi, table->safi, bgp); if (distance) { SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE); api.distance = distance; @@ -1706,9 +1707,7 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi) && (pi->sub_type == BGP_ROUTE_NORMAL || pi->sub_type == BGP_ROUTE_IMPORTED))) - bgp_zebra_announce(dest, - bgp_dest_get_prefix(dest), - pi, bgp, afi, safi); + bgp_zebra_announce(dest, pi, bgp); } /* Announce routes of any bgp subtype of a table to zebra */ @@ -1730,16 +1729,16 @@ void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi, for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) && pi->type == ZEBRA_ROUTE_BGP) - bgp_zebra_announce(dest, - bgp_dest_get_prefix(dest), - pi, bgp, afi, safi); + bgp_zebra_announce(dest, pi, bgp); } -void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info, - struct bgp *bgp, afi_t afi, safi_t safi) +void bgp_zebra_withdraw(struct bgp_dest *dest, struct bgp_path_info *info, + struct bgp *bgp) { struct zapi_route api; struct peer *peer; + struct bgp_table *table = bgp_dest_table(dest); + const struct prefix *p = bgp_dest_get_prefix(dest); /* * If we are withdrawing the route, we don't need to have this @@ -1753,16 +1752,17 @@ void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info, if (!bgp_install_info_to_zebra(bgp)) return; - if (safi == SAFI_FLOWSPEC) { + if (table->safi == SAFI_FLOWSPEC) { peer = info->peer; - bgp_pbr_update_entry(peer->bgp, p, info, afi, safi, false); + bgp_pbr_update_entry(peer->bgp, p, info, table->afi, + table->safi, false); return; } memset(&api, 0, sizeof(api)); api.vrf_id = bgp->vrf_id; api.type = ZEBRA_ROUTE_BGP; - api.safi = safi; + api.safi = table->safi; api.prefix = *p; if (info->attr->rmap_table_id) { @@ -1795,8 +1795,7 @@ void bgp_zebra_withdraw_table_all_subtypes(struct bgp *bgp, afi_t afi, safi_t sa for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) { if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) && (pi->type == ZEBRA_ROUTE_BGP)) - bgp_zebra_withdraw(bgp_dest_get_prefix(dest), - pi, bgp, afi, safi); + bgp_zebra_withdraw(dest, pi, bgp); } } } diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index 396c8335f8cc..3a7fe6501851 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -28,13 +28,11 @@ extern void bgp_zebra_destroy(void); extern int bgp_zebra_get_table_range(struct zclient *zc, uint32_t chunk_size, uint32_t *start, uint32_t *end); extern int bgp_if_update_all(void); -extern void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p, - struct bgp_path_info *path, struct bgp *bgp, - afi_t afi, safi_t safi); +extern void bgp_zebra_announce(struct bgp_dest *dest, + struct bgp_path_info *path, struct bgp *bgp); extern void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi); -extern void bgp_zebra_withdraw(const struct prefix *p, - struct bgp_path_info *path, struct bgp *bgp, - afi_t afi, safi_t safi); +extern void bgp_zebra_withdraw(struct bgp_dest *dest, + struct bgp_path_info *path, struct bgp *bgp); /* Announce routes of any bgp subtype of a table to zebra */ extern void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,