Skip to content

Commit

Permalink
Merge pull request #27 from opensourcerouting/pr-volta-peer-color-fix
Browse files Browse the repository at this point in the history
bgpd: do not unregister for prefix nexthop updates if nh exists
  • Loading branch information
GalaxyGorilla authored Jun 30, 2020
2 parents 060e7f8 + 629933d commit fe4e5e7
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 @@ -107,6 +107,7 @@ extern int bgp_nexthop_self(struct bgp *, struct in_addr);
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 @@ -75,8 +75,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 fe4e5e7

Please sign in to comment.