]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Allow registration of nexthops after zebra connection
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 5 Oct 2018 15:31:29 +0000 (11:31 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 31 Oct 2018 10:31:41 +0000 (06:31 -0400)
If we attempt to register nexthops before we have the zebra
connection, they will not be installed.  After we have noticed
that we are up, re-install them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_nht.h
bgpd/bgp_zebra.c

index 5ed6fd6ebedea4880ff0de945ed51f846b884328..2ef792e12901244aac28724307ff96ef1a59729c 100644 (file)
@@ -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");
index 2e7f17fdaecebf5a023e9bb487493af74521ecf3..8aa7798af4254bd4227dcfefc2f35b147a8325e2 100644 (file)
@@ -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);
+               }
+       }
+}
index 0cc045a065e9a506a38bb06c25d35c7052536a35..96dd9155964c10baab84b6fb2a6dd34749c55b87 100644 (file)
@@ -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 */
index 0b79a9ee18df30f1c1e370576bcb8d80fd2fe85a..50b790eb118a4ddd59491546133c94c8cd87ca3c 100644 (file)
@@ -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