diff options
-rw-r--r-- | bgpd/bgp_nexthop.c | 5 | ||||
-rw-r--r-- | bgpd/bgp_nht.c | 36 | ||||
-rw-r--r-- | bgpd/bgp_nht.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_zebra.c | 2 |
4 files changed, 46 insertions, 3 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 5ed6fd6eb..2ef792e12 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -628,7 +628,10 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail) if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) vty_out(vty, " Must be Connected\n"); - } + if (!CHECK_FLAG(bnc->flags, + BGP_NEXTHOP_REGISTERED)) + vty_out(vty, " Is not Registered\n"); + } tbuf = time(NULL) - (bgp_clock() - bnc->last_update); vty_out(vty, " Last update: %s", ctime(&tbuf)); vty_out(vty, "\n"); diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 2e7f17fda..8aa7798af 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -240,8 +240,8 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID); } if (bgp_route->inst_type == BGP_INSTANCE_TYPE_VIEW) { - bnc->flags |= BGP_NEXTHOP_REGISTERED; - bnc->flags |= BGP_NEXTHOP_VALID; + SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED); + SET_FLAG(bnc->flags, BGP_NEXTHOP_VALID); } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)) register_zebra_rnh(bnc, is_bgp_static_route); if (pi && pi->nexthop != bnc) { @@ -594,6 +594,11 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command) return; } + if (!bgp_zebra_num_connects()) { + if (BGP_DEBUG(zebra, ZEBRA)) + zlog_debug("%s: We have not connected yet, cannot send nexthops", + __PRETTY_FUNCTION__); + } p = &(bnc->node->p); if ((command == ZEBRA_NEXTHOP_REGISTER || command == ZEBRA_IMPORT_ROUTE_REGISTER) @@ -806,3 +811,30 @@ void path_nh_map(struct bgp_path_info *path, struct bgp_nexthop_cache *bnc, path->nexthop->path_count++; } } + +/* + * This function is called to register nexthops to zebra + * as that we may have tried to install the nexthops + * before we actually have a zebra connection + */ +void bgp_nht_register_nexthops(struct bgp *bgp) +{ + struct bgp_node *rn; + struct bgp_nexthop_cache *bnc; + afi_t afi; + + for (afi = AFI_IP; afi < AFI_MAX; afi++) { + if (!bgp->nexthop_cache_table[afi]) + continue; + + for (rn = bgp_table_top(bgp->nexthop_cache_table[afi]); rn; + rn = bgp_route_next(rn)) { + bnc = bgp_nexthop_get_node_info(rn); + + if (!bnc) + continue; + + register_zebra_rnh(bnc, 0); + } + } +} diff --git a/bgpd/bgp_nht.h b/bgpd/bgp_nht.h index 0cc045a06..96dd91559 100644 --- a/bgpd/bgp_nht.h +++ b/bgpd/bgp_nht.h @@ -81,5 +81,11 @@ extern void bgp_cleanup_nexthops(struct bgp *bgp); */ extern void path_nh_map(struct bgp_path_info *path, struct bgp_nexthop_cache *bnc, bool make); +/* + * When we actually have the connection to + * the zebra daemon, we need to reregister + * any nexthops we may have sitting around + */ +extern void bgp_nht_register_nexthops(struct bgp *bgp); #endif /* _BGP_NHT_H */ diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 0b79a9ee1..50b790eb1 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1837,6 +1837,8 @@ void bgp_zebra_instance_register(struct bgp *bgp) */ if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT && is_evpn_enabled()) bgp_zebra_advertise_all_vni(bgp, 1); + + bgp_nht_register_nexthops(bgp); } /* Deregister this instance with Zebra. Invoked upon the instance |