diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index e464e47b1f0c..34db978ead33 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -158,6 +158,10 @@ static int zebra_vrf_enable(struct vrf *vrf) static int zebra_vrf_disable(struct vrf *vrf) { struct zebra_vrf *zvrf = vrf->info; + struct zebra_vrf *zvrf_default = vrf_info_lookup(VRF_DEFAULT); + struct rib_table_info *info; + struct route_entry *re; + struct route_node *rn; struct interface *ifp; afi_t afi; safi_t safi; @@ -216,8 +220,21 @@ static int zebra_vrf_disable(struct vrf *vrf) * we no-longer need this pointer. */ for (safi = SAFI_UNICAST; safi <= SAFI_MULTICAST; safi++) { - zebra_router_release_table(zvrf, zvrf->table_id, afi, - safi); + if (!zvrf->table[afi][safi]) + continue; + + info = route_table_get_info(zvrf->table[afi][safi]); + info->zvrf = zvrf_default; + + for (rn = route_top(zvrf->table[afi][safi]); rn; + rn = route_next(rn)) { + if (!rn->info) + continue; + + RNODE_FOREACH_RE (rn, re) + re->vrf_id = VRF_DEFAULT; + } + zvrf->table[afi][safi] = NULL; } } @@ -349,6 +366,9 @@ static void zebra_rnhtable_node_cleanup(struct route_table *table, static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi, safi_t safi) { + vrf_id_t vrf_id = zvrf->vrf->vrf_id; + struct rib_table_info *info; + struct route_entry *re; struct route_node *rn; struct prefix p; @@ -357,6 +377,17 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi, zvrf->table[afi][safi] = zebra_router_get_table(zvrf, zvrf->table_id, afi, safi); + info = route_table_get_info(zvrf->table[afi][safi]); + info->zvrf = zvrf; + + for (rn = route_top(zvrf->table[afi][safi]); rn; rn = route_next(rn)) { + if (!rn->info) + continue; + + RNODE_FOREACH_RE (rn, re) + re->vrf_id = vrf_id; + } + memset(&p, 0, sizeof(p)); p.family = afi2family(afi);