Skip to content

Commit

Permalink
Merge pull request FRRouting#29 from opensourcerouting/pr-volta-peer-…
Browse files Browse the repository at this point in the history
…color-fix-rebase

bgpd: do not unregister for prefix nexthop updates if nh exists
  • Loading branch information
GalaxyGorilla authored Jun 30, 2020
2 parents 6dee0bf + 01150ad commit 8879517
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions bgpd/bgp_nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
return bnc;
}

bool bnc_existing_for_prefix(struct bgp_nexthop_cache *bnc)
{
struct bgp_nexthop_cache *bnc_tmp;

RB_FOREACH (bnc_tmp, bgp_nexthop_cache_head, bnc->tree) {
if (bnc_tmp == bnc)
continue;
if (prefix_cmp(&bnc->prefix, &bnc_tmp->prefix) == 0)
return true;
}
return false;
}

void bnc_free(struct bgp_nexthop_cache *bnc)
{
bnc_nexthop_free(bnc);
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_nexthop.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
extern struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
struct prefix *prefix,
uint32_t srte_color);
extern bool bnc_existing_for_prefix(struct bgp_nexthop_cache *bnc);
extern void bnc_free(struct bgp_nexthop_cache *bnc);
extern struct bgp_nexthop_cache *bnc_find(struct bgp_nexthop_cache_head *tree,
struct prefix *prefix,
Expand Down
7 changes: 5 additions & 2 deletions bgpd/bgp_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc)
bnc_str(bnc, buf, PREFIX2STR_BUFFER),
bnc->srte_color, bnc->bgp->name_pretty);
}
unregister_zebra_rnh(bnc,
CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE));
/* only unregister if this is the last nh for this prefix*/
if (!bnc_existing_for_prefix(bnc))
unregister_zebra_rnh(bnc,
CHECK_FLAG(bnc->flags,
BGP_STATIC_ROUTE));
bnc_free(bnc);
}
}
Expand Down

0 comments on commit 8879517

Please sign in to comment.