Skip to content

Commit

Permalink
bgpd: Remove prefix from call to bgp_zebra_announce/withdraw
Browse files Browse the repository at this point in the history
This prefix is known by the dest.  Let's remove this data.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Jan 31, 2024
1 parent 346c90d commit 247fb76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
12 changes: 6 additions & 6 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -3398,7 +3398,7 @@ 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_zebra_announce(dest, old_select,
bgp);
}
}
Expand Down Expand Up @@ -3516,17 +3516,17 @@ 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(dest, p, old_select, bgp);
bgp_zebra_withdraw(dest, old_select, bgp);

bgp_zebra_announce(dest, p, new_select, bgp);
bgp_zebra_announce(dest, new_select, bgp);
} else {
/* Withdraw the route from the kernel. */
if (old_select && old_select->type == ZEBRA_ROUTE_BGP
&& (old_select->sub_type == BGP_ROUTE_NORMAL
|| old_select->sub_type == BGP_ROUTE_AGGREGATE
|| old_select->sub_type == BGP_ROUTE_IMPORTED))

bgp_zebra_withdraw(dest, p, old_select, bgp);
bgp_zebra_withdraw(dest, old_select, bgp);
}
}

Expand Down Expand Up @@ -4427,7 +4427,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(dest, p, pi, bgp);
bgp_zebra_withdraw(dest, pi, bgp);
}

if (peer->sort == BGP_PEER_EBGP) {
Expand Down Expand Up @@ -6053,7 +6053,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(dest, p, pi, bgp);
bgp_zebra_withdraw(dest, pi, bgp);
}

dest = bgp_path_info_reap(dest, pi);
Expand Down
22 changes: 9 additions & 13 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1507,8 +1507,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)
void bgp_zebra_announce(struct bgp_dest *dest, struct bgp_path_info *info,
struct bgp *bgp)
{
struct zapi_route api = { 0 };
unsigned int valid_nh_count = 0;
Expand All @@ -1520,6 +1520,7 @@ 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;
const struct prefix *p = bgp_dest_get_prefix(dest);
struct bgp_table *bti;

bti = bgp_dest_table(dest);
Expand Down Expand Up @@ -1696,9 +1697,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);
bgp_zebra_announce(dest, pi, bgp);
}

/* Announce routes of any bgp subtype of a table to zebra */
Expand All @@ -1720,17 +1719,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);
bgp_zebra_announce(dest, pi, bgp);
}

void bgp_zebra_withdraw(struct bgp_dest *dest, const struct prefix *p,
struct bgp_path_info *info, struct bgp *bgp)
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 *bti = 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
Expand Down Expand Up @@ -1787,9 +1785,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(dest,
bgp_dest_get_prefix(dest),
pi, bgp);
bgp_zebra_withdraw(dest, pi, bgp);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_zebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ 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,
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(struct bgp_dest *dest, const struct prefix *p,
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 */
Expand Down

0 comments on commit 247fb76

Please sign in to comment.