diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index eca7093fcd..e2818988ea 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -173,7 +173,6 @@ int bgp_router_destroy(struct nb_cb_destroy_args *args) case NB_EV_APPLY: bgp = nb_running_unset_entry(args->dnode); - bgp_vpn_leak_unimport(bgp); bgp_delete(bgp); break; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d2d94707a7..4cd603ee8b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3382,6 +3382,14 @@ int bgp_delete(struct bgp *bgp) assert(bgp); + /* make sure we withdraw any exported routes */ + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), + bgp); + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_get_default(), + bgp); + + bgp_vpn_leak_unimport(bgp); + hook_call(bgp_inst_delete, bgp); THREAD_OFF(bgp->t_startup);