Skip to content

Commit

Permalink
Merge pull request FRRouting#13798 from donaldsharp/bgp_suppression
Browse files Browse the repository at this point in the history
bgpd: some safi's do not mix with bgp suppress-fib
  • Loading branch information
ton31337 committed Jun 18, 2023
2 parents 253135c + 4d616f0 commit 4230f85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,7 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
* is pending (BGP_NODE_FIB_INSTALL_PENDING), do not advertise the
* route
*/
advertise = bgp_check_advertise(bgp, dest);
advertise = bgp_check_advertise(bgp, dest, safi);

if (selected) {
if (subgroup_announce_check(dest, selected, subgrp, p, &attr,
Expand All @@ -2933,7 +2933,7 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
* in FIB, then it is advertised
*/
if (advertise) {
if (!bgp_check_withdrawal(bgp, dest)) {
if (!bgp_check_withdrawal(bgp, dest, safi)) {
struct attr *adv_attr =
bgp_attr_intern(&attr);

Expand Down Expand Up @@ -7752,7 +7752,7 @@ bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
/* If suppress fib is enabled and route not installed
* in FIB, skip the route
*/
if (!bgp_check_advertise(bgp, dest))
if (!bgp_check_advertise(bgp, dest, safi))
continue;

match = 0;
Expand Down Expand Up @@ -8266,7 +8266,7 @@ void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
/* If suppress fib is enabled and route not installed
* in FIB, do not update the aggregate route
*/
if (!bgp_check_advertise(bgp, pi->net))
if (!bgp_check_advertise(bgp, pi->net, safi))
return;

child = bgp_node_get(table, p);
Expand Down
11 changes: 8 additions & 3 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,12 @@ static inline void prep_for_rmap_apply(struct bgp_path_info *dst_pi,
}
}

static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest)
static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest,
safi_t safi)
{
if (!bgp_fibupd_safi(safi))
return true;

return (!(BGP_SUPPRESS_FIB_ENABLED(bgp) &&
CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING) &&
(!bgp_option_check(BGP_OPT_NO_FIB))));
Expand All @@ -605,11 +609,12 @@ static inline bool bgp_check_advertise(struct bgp *bgp, struct bgp_dest *dest)
* This function assumes that bgp_check_advertise was already returned
* as good to go.
*/
static inline bool bgp_check_withdrawal(struct bgp *bgp, struct bgp_dest *dest)
static inline bool bgp_check_withdrawal(struct bgp *bgp, struct bgp_dest *dest,
safi_t safi)
{
struct bgp_path_info *pi, *selected = NULL;

if (!BGP_SUPPRESS_FIB_ENABLED(bgp))
if (!bgp_fibupd_safi(safi) || !BGP_SUPPRESS_FIB_ENABLED(bgp))
return false;

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
Expand Down
11 changes: 7 additions & 4 deletions bgpd/bgp_updgrp_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ static void subgroup_coalesce_timer(struct event *thread)
{
struct update_subgroup *subgrp;
struct bgp *bgp;
safi_t safi;

subgrp = EVENT_ARG(thread);
if (bgp_debug_update(NULL, NULL, subgrp->update_group, 0))
Expand All @@ -317,7 +318,7 @@ static void subgroup_coalesce_timer(struct event *thread)
subgrp->v_coalesce = 0;
bgp = SUBGRP_INST(subgrp);
subgroup_announce_route(subgrp);

safi = SUBGRP_SAFI(subgrp);

/* While the announce_route() may kick off the route advertisement timer
* for
Expand All @@ -328,7 +329,8 @@ static void subgroup_coalesce_timer(struct event *thread)
* announce, this is the method currently employed to trigger the EOR.
*/
if (!bgp_update_delay_active(SUBGRP_INST(subgrp)) &&
!(BGP_SUPPRESS_FIB_ENABLED(bgp))) {
!(bgp_fibupd_safi(safi) && BGP_SUPPRESS_FIB_ENABLED(bgp))) {

struct peer_af *paf;
struct peer *peer;

Expand Down Expand Up @@ -549,7 +551,8 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
* the flag PEER_STATUS_ADV_DELAY which will allow
* more routes to be sent in the update message
*/
if (BGP_SUPPRESS_FIB_ENABLED(bgp)) {
if (bgp_fibupd_safi(safi) &&
BGP_SUPPRESS_FIB_ENABLED(bgp)) {
adv_peer = PAF_PEER(paf);
if (!bgp_adv_fifo_count(
&subgrp->sync->withdraw))
Expand Down Expand Up @@ -1014,7 +1017,7 @@ void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi,
/* If suppress fib is enabled, the route will be advertised when
* FIB status is received
*/
if (!bgp_check_advertise(bgp, dest))
if (!bgp_check_advertise(bgp, dest, safi))
return;

update_group_af_walk(bgp, afi, safi, group_announce_route_walkcb, &ctx);
Expand Down

0 comments on commit 4230f85

Please sign in to comment.