@@ -47,6 +47,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
47
47
static void zebra_rnhtable_node_cleanup (struct route_table * table ,
48
48
struct route_node * node );
49
49
50
+ DEFINE_MTYPE_STATIC (ZEBRA , OTHER_TABLE , "Other Table" );
51
+
50
52
/* VRF information update. */
51
53
static void zebra_vrf_add_update (struct zebra_vrf * zvrf )
52
54
{
@@ -93,6 +95,9 @@ static int zebra_vrf_new(struct vrf *vrf)
93
95
zvrf = zebra_vrf_alloc ();
94
96
vrf -> info = zvrf ;
95
97
zvrf -> vrf = vrf ;
98
+
99
+ otable_init (& zvrf -> other_tables );
100
+
96
101
router_id_init (zvrf );
97
102
return 0 ;
98
103
}
@@ -226,6 +231,7 @@ static int zebra_vrf_disable(struct vrf *vrf)
226
231
static int zebra_vrf_delete (struct vrf * vrf )
227
232
{
228
233
struct zebra_vrf * zvrf = vrf -> info ;
234
+ struct other_route_table * otable ;
229
235
struct route_table * table ;
230
236
afi_t afi ;
231
237
safi_t safi ;
@@ -274,11 +280,22 @@ static int zebra_vrf_delete(struct vrf *vrf)
274
280
route_table_finish (zvrf -> import_check_table [afi ]);
275
281
}
276
282
283
+ otable = otable_pop (& zvrf -> other_tables );
284
+ while (otable ) {
285
+ zebra_router_release_table (zvrf , otable -> table_id ,
286
+ otable -> afi , otable -> safi );
287
+ XFREE (MTYPE_OTHER_TABLE , otable );
288
+
289
+ otable = otable_pop (& zvrf -> other_tables );
290
+ }
291
+
277
292
/* Cleanup EVPN states for vrf */
278
293
zebra_vxlan_vrf_delete (zvrf );
279
294
280
295
list_delete_all_node (zvrf -> rid_all_sorted_list );
281
296
list_delete_all_node (zvrf -> rid_lo_sorted_list );
297
+
298
+ otable_fini (& zvrf -> other_tables );
282
299
XFREE (MTYPE_ZEBRA_VRF , zvrf );
283
300
vrf -> info = NULL ;
284
301
@@ -321,6 +338,8 @@ struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
321
338
uint32_t table_id )
322
339
{
323
340
struct zebra_vrf * zvrf = vrf_info_lookup (vrf_id );
341
+ struct other_route_table ort , * otable ;
342
+ struct route_table * table ;
324
343
325
344
if (!zvrf )
326
345
return NULL ;
@@ -331,7 +350,23 @@ struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
331
350
if (table_id == zvrf -> table_id )
332
351
return zebra_vrf_table (afi , safi , vrf_id );
333
352
334
- return zebra_router_get_table (zvrf , table_id , afi , safi );
353
+ ort .afi = afi ;
354
+ ort .safi = safi ;
355
+ ort .table_id = table_id ;
356
+ otable = otable_find (& zvrf -> other_tables , & ort );
357
+ if (otable )
358
+ return otable -> table ;
359
+
360
+ table = zebra_router_get_table (zvrf , table_id , afi , safi );
361
+
362
+ otable = XCALLOC (MTYPE_OTHER_TABLE , sizeof (* otable ));
363
+ otable -> afi = afi ;
364
+ otable -> safi = safi ;
365
+ otable -> table_id = table_id ;
366
+ otable -> table = table ;
367
+ otable_add (& zvrf -> other_tables , otable );
368
+
369
+ return table ;
335
370
}
336
371
337
372
void zebra_rtable_node_cleanup (struct route_table * table ,
0 commit comments