]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Cleanup NHT state when underlying VRF goes down
authorvivek <vivek@cumulusnetworks.com>
Thu, 10 Aug 2017 00:32:19 +0000 (17:32 -0700)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 17 Aug 2017 09:54:14 +0000 (02:54 -0700)
When the underlying VRF is deleted, ensure that state for the
next hops that BGP registers with zebra for tracking purposes is
properly updated. Otherwise BGP will not re-register the next hop
when the VRF is re-created, resulting in the next hop staying
unresolved.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Ticket: CM-17456
Reviewed By: CCR-6587
Testing Done: Manual, bgp-min, vrf

bgpd/bgp_nht.c
bgpd/bgp_nht.h
bgpd/bgpd.c

index 3a7a60b14d368d97576fc43339f21d743244c63e..55a2f10132453a8b9cb982bcd7f15e7451497c55 100644 (file)
@@ -482,6 +482,33 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
        evaluate_paths(bnc);
 }
 
+/*
+ * Cleanup nexthop registration and status information for BGP nexthops
+ * pertaining to this VRF. This is invoked upon VRF deletion.
+ */
+void bgp_cleanup_nexthops(struct bgp *bgp)
+{
+       afi_t afi;
+       struct bgp_node *rn;
+       struct bgp_nexthop_cache *bnc;
+
+       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)) {
+                       if ((bnc = rn->info) == NULL)
+                               continue;
+
+                       /* Clear relevant flags. */
+                       UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
+                       UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
+                       UNSET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
+               }
+       }
+}
+
 /**
  * make_prefix - make a prefix structure from the path (essentially
  * path's node.
index f649bb225963012dd47456ec0a1fb9d95c23bf68..4b297f410c80f3102ca574883546e61fb8f475a4 100644 (file)
@@ -66,4 +66,10 @@ void bgp_unlink_nexthop_by_peer(struct peer *);
  */
 extern void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer);
 
+/*
+ * Cleanup nexthop registration and status information for BGP nexthops
+ * pertaining to this VRF. This is invoked upon VRF deletion.
+ */
+extern void bgp_cleanup_nexthops(struct bgp *bgp);
+
 #endif /* _BGP_NHT_H */
index c58e4e70cd726721a9afdd884785b8bdfaab1715..a017c4fa263b02929caf314d4fc269f62d1acbfc 100644 (file)
@@ -3031,6 +3031,9 @@ void bgp_instance_down(struct bgp *bgp)
 
        /* Purge network and redistributed routes. */
        bgp_purge_static_redist_routes(bgp);
+
+       /* Cleanup registered nexthops (flags) */
+       bgp_cleanup_nexthops(bgp);
 }
 
 /* Delete BGP instance. */