summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_nexthop.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 0cb9bc7e2b..fd8d894878 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -364,6 +364,22 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
bgp_unlock_node(rn);
}
+static void bgp_connected_cleanup(struct route_table *table,
+ struct route_node *rn)
+{
+ struct bgp_connected_ref *bc;
+
+ bc = rn->info;
+ if (!bc)
+ return;
+
+ bc->refcnt--;
+ if (bc->refcnt == 0) {
+ XFREE(MTYPE_BGP_CONN, bc);
+ rn->info = NULL;
+ }
+}
+
int bgp_nexthop_self(struct bgp *bgp, struct in_addr nh_addr)
{
struct bgp_addr tmp, *addr;
@@ -643,6 +659,8 @@ void bgp_scan_finish(struct bgp *bgp)
bgp_table_unlock(bgp->nexthop_cache_table[afi]);
bgp->nexthop_cache_table[afi] = NULL;
+ bgp->connected_table[afi]->route_table->cleanup =
+ bgp_connected_cleanup;
bgp_table_unlock(bgp->connected_table[afi]);
bgp->connected_table[afi] = NULL;