Skip to content

Commit 5f379be

Browse files
donaldsharpraja-rajasekar
authored andcommitted
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 <sharpd@nvidia.com> Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
1 parent 705fed7 commit 5f379be

File tree

3 files changed

+33
-39
lines changed

3 files changed

+33
-39
lines changed

bgpd/bgp_route.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,8 +3399,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
33993399
|| new_select->sub_type
34003400
== BGP_ROUTE_IMPORTED))
34013401

3402-
bgp_zebra_announce(dest, p, old_select,
3403-
bgp, afi, safi);
3402+
bgp_zebra_announce(dest, old_select,
3403+
bgp);
34043404
}
34053405
}
34063406

@@ -3517,19 +3517,17 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
35173517
*/
35183518
if (old_select &&
35193519
is_route_parent_evpn(old_select))
3520-
bgp_zebra_withdraw(p, old_select, bgp, afi,
3521-
safi);
3520+
bgp_zebra_withdraw(dest, old_select, bgp);
35223521

3523-
bgp_zebra_announce(dest, p, new_select, bgp, afi, safi);
3522+
bgp_zebra_announce(dest, new_select, bgp);
35243523
} else {
35253524
/* Withdraw the route from the kernel. */
35263525
if (old_select && old_select->type == ZEBRA_ROUTE_BGP
35273526
&& (old_select->sub_type == BGP_ROUTE_NORMAL
35283527
|| old_select->sub_type == BGP_ROUTE_AGGREGATE
35293528
|| old_select->sub_type == BGP_ROUTE_IMPORTED))
35303529

3531-
bgp_zebra_withdraw(p, old_select, bgp, afi,
3532-
safi);
3530+
bgp_zebra_withdraw(dest, old_select, bgp);
35333531
}
35343532
}
35353533

@@ -4426,7 +4424,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
44264424
if (pi && pi->attr->rmap_table_id != new_attr.rmap_table_id) {
44274425
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
44284426
/* remove from RIB previous entry */
4429-
bgp_zebra_withdraw(p, pi, bgp, afi, safi);
4427+
bgp_zebra_withdraw(dest, pi, bgp);
44304428
}
44314429

44324430
if (peer->sort == BGP_PEER_EBGP) {
@@ -6052,8 +6050,7 @@ static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table,
60526050
|| pi->sub_type == BGP_ROUTE_IMPORTED)) {
60536051

60546052
if (bgp_fibupd_safi(safi))
6055-
bgp_zebra_withdraw(p, pi, bgp, afi,
6056-
safi);
6053+
bgp_zebra_withdraw(dest, pi, bgp);
60576054
}
60586055

60596056
dest = bgp_path_info_reap(dest, pi);

bgpd/bgp_zebra.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,9 +1524,8 @@ static void bgp_debug_zebra_nh(struct zapi_route *api)
15241524
}
15251525
}
15261526

1527-
void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
1528-
struct bgp_path_info *info, struct bgp *bgp, afi_t afi,
1529-
safi_t safi)
1527+
void bgp_zebra_announce(struct bgp_dest *dest, struct bgp_path_info *info,
1528+
struct bgp *bgp)
15301529
{
15311530
struct bgp_path_info *bpi_ultimate;
15321531
struct zapi_route api = { 0 };
@@ -1539,6 +1538,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
15391538
bool is_add;
15401539
uint32_t nhg_id = 0;
15411540
uint32_t recursion_flag = 0;
1541+
struct bgp_table *table = bgp_dest_table(dest);
1542+
const struct prefix *p = bgp_dest_get_prefix(dest);
15421543

15431544
/*
15441545
* 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,
15571558
if (bgp->main_zebra_update_hold)
15581559
return;
15591560

1560-
if (safi == SAFI_FLOWSPEC) {
1561-
bgp_pbr_update_entry(bgp, bgp_dest_get_prefix(dest), info, afi,
1562-
safi, true);
1561+
if (table->safi == SAFI_FLOWSPEC) {
1562+
bgp_pbr_update_entry(bgp, p, info, table->afi, table->safi,
1563+
true);
15631564
return;
15641565
}
15651566

15661567
/* Make Zebra API structure. */
15671568
api.vrf_id = bgp->vrf_id;
15681569
api.type = ZEBRA_ROUTE_BGP;
1569-
api.safi = safi;
1570+
api.safi = table->safi;
15701571
api.prefix = *p;
15711572
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
15721573

@@ -1603,8 +1604,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
16031604
metric = info->attr->med;
16041605

16051606
bgp_zebra_announce_parse_nexthop(info, p, bgp, &api, &valid_nh_count,
1606-
afi, safi, &nhg_id, &metric, &tag,
1607-
&allow_recursion);
1607+
table->afi, table->safi, &nhg_id,
1608+
&metric, &tag, &allow_recursion);
16081609

16091610
is_add = (valid_nh_count || nhg_id) ? true : false;
16101611

@@ -1657,7 +1658,7 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
16571658
api.tag = tag;
16581659
}
16591660

1660-
distance = bgp_distance_apply(p, info, afi, safi, bgp);
1661+
distance = bgp_distance_apply(p, info, table->afi, table->safi, bgp);
16611662
if (distance) {
16621663
SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
16631664
api.distance = distance;
@@ -1706,9 +1707,7 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
17061707
&& (pi->sub_type == BGP_ROUTE_NORMAL
17071708
|| pi->sub_type == BGP_ROUTE_IMPORTED)))
17081709

1709-
bgp_zebra_announce(dest,
1710-
bgp_dest_get_prefix(dest),
1711-
pi, bgp, afi, safi);
1710+
bgp_zebra_announce(dest, pi, bgp);
17121711
}
17131712

17141713
/* 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,
17301729
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
17311730
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
17321731
pi->type == ZEBRA_ROUTE_BGP)
1733-
bgp_zebra_announce(dest,
1734-
bgp_dest_get_prefix(dest),
1735-
pi, bgp, afi, safi);
1732+
bgp_zebra_announce(dest, pi, bgp);
17361733
}
17371734

1738-
void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
1739-
struct bgp *bgp, afi_t afi, safi_t safi)
1735+
void bgp_zebra_withdraw(struct bgp_dest *dest, struct bgp_path_info *info,
1736+
struct bgp *bgp)
17401737
{
17411738
struct zapi_route api;
17421739
struct peer *peer;
1740+
struct bgp_table *table = bgp_dest_table(dest);
1741+
const struct prefix *p = bgp_dest_get_prefix(dest);
17431742

17441743
/*
17451744
* 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,
17531752
if (!bgp_install_info_to_zebra(bgp))
17541753
return;
17551754

1756-
if (safi == SAFI_FLOWSPEC) {
1755+
if (table->safi == SAFI_FLOWSPEC) {
17571756
peer = info->peer;
1758-
bgp_pbr_update_entry(peer->bgp, p, info, afi, safi, false);
1757+
bgp_pbr_update_entry(peer->bgp, p, info, table->afi,
1758+
table->safi, false);
17591759
return;
17601760
}
17611761

17621762
memset(&api, 0, sizeof(api));
17631763
api.vrf_id = bgp->vrf_id;
17641764
api.type = ZEBRA_ROUTE_BGP;
1765-
api.safi = safi;
1765+
api.safi = table->safi;
17661766
api.prefix = *p;
17671767

17681768
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
17951795
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
17961796
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
17971797
&& (pi->type == ZEBRA_ROUTE_BGP))
1798-
bgp_zebra_withdraw(bgp_dest_get_prefix(dest),
1799-
pi, bgp, afi, safi);
1798+
bgp_zebra_withdraw(dest, pi, bgp);
18001799
}
18011800
}
18021801
}

bgpd/bgp_zebra.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ extern void bgp_zebra_destroy(void);
2828
extern int bgp_zebra_get_table_range(struct zclient *zc, uint32_t chunk_size,
2929
uint32_t *start, uint32_t *end);
3030
extern int bgp_if_update_all(void);
31-
extern void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
32-
struct bgp_path_info *path, struct bgp *bgp,
33-
afi_t afi, safi_t safi);
31+
extern void bgp_zebra_announce(struct bgp_dest *dest,
32+
struct bgp_path_info *path, struct bgp *bgp);
3433
extern void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi);
35-
extern void bgp_zebra_withdraw(const struct prefix *p,
36-
struct bgp_path_info *path, struct bgp *bgp,
37-
afi_t afi, safi_t safi);
34+
extern void bgp_zebra_withdraw(struct bgp_dest *dest,
35+
struct bgp_path_info *path, struct bgp *bgp);
3836

3937
/* Announce routes of any bgp subtype of a table to zebra */
4038
extern void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,

0 commit comments

Comments
 (0)