if (IS_BGP_INST_KNOWN_TO_ZEBRA(bgp))
bgp_zebra_instance_deregister (bgp);
+ /* Free interfaces in this instance. */
+ bgp_if_finish (bgp);
+
/* If Default instance or VRF, unlink from the VRF structure. */
vrf = bgp_vrf_lookup_by_instance_type (bgp);
if (vrf)
}
/*
- * Free up connected routes and interfaces; invoked upon bgp_exit()
+ * Free up connected routes and interfaces for a BGP instance. Invoked upon
+ * instance delete (non-default only) or BGP exit.
*/
void
-bgp_if_finish (void)
+bgp_if_finish (struct bgp *bgp)
{
- struct bgp *bgp;
- struct listnode *node, *nnode;
-
- for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
- {
- struct listnode *ifnode, *ifnnode;
- struct interface *ifp;
+ struct listnode *ifnode, *ifnnode;
+ struct interface *ifp;
- if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
- continue;
+ if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+ return;
- for (ALL_LIST_ELEMENTS (vrf_iflist(bgp->vrf_id), ifnode, ifnnode, ifp))
- {
- struct listnode *c_node, *c_nnode;
- struct connected *c;
+ for (ALL_LIST_ELEMENTS (vrf_iflist(bgp->vrf_id), ifnode, ifnnode, ifp))
+ {
+ struct listnode *c_node, *c_nnode;
+ struct connected *c;
- for (ALL_LIST_ELEMENTS (ifp->connected, c_node, c_nnode, c))
- bgp_connected_delete (bgp, c);
-
- if_delete (ifp);
- }
- list_free (vrf_iflist(bgp->vrf_id));
+ for (ALL_LIST_ELEMENTS (ifp->connected, c_node, c_nnode, c))
+ bgp_connected_delete (bgp, c);
}
+ vrf_iflist_terminate (bgp->vrf_id);
}
void
extern int bgp_config_write (struct vty *);
extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *);
-extern void bgp_if_finish (void);
+extern void bgp_if_finish (struct bgp *);
extern void bgp_master_init (void);
extern void bgp_init (void);
extern struct list *vrf_iflist (vrf_id_t);
/* Get the interface list of the specified VRF. Create one if not find. */
extern struct list *vrf_iflist_get (vrf_id_t);
+/* Free the interface list of the specified VRF. */
+extern void vrf_iflist_terminate (vrf_id_t vrf_id);
/*
* VRF bit-map: maintaining flags, one bit per VRF ID