-struct route_table *zebra_ns_find_table(struct zebra_ns *zns, uint32_t tableid,
- afi_t afi)
-{
- struct zebra_ns_table finder;
- struct zebra_ns_table *znst;
-
- memset(&finder, 0, sizeof(finder));
- finder.afi = afi;
- finder.tableid = tableid;
- finder.ns_id = zns->ns_id;
- znst = RB_FIND(zebra_ns_table_head, &zns->ns_tables, &finder);
-
- if (znst)
- return znst->table;
- else
- return NULL;
-}
-
-unsigned long zebra_ns_score_proto(uint8_t proto, unsigned short instance)
-{
- struct zebra_ns *zns;
- struct zebra_ns_table *znst;
- unsigned long cnt = 0;
-
- zns = zebra_ns_lookup(NS_DEFAULT);
-
- RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables) {
- if (znst->ns_id != NS_DEFAULT)
- continue;
- cnt += rib_score_proto_table(proto, instance, znst->table);
- }
- return cnt;
-}
-
-void zebra_ns_sweep_route(void)
-{
- struct zebra_ns_table *znst;
- struct zebra_ns *zns;
-
- zns = zebra_ns_lookup(NS_DEFAULT);
-
- RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables) {
- if (znst->ns_id != NS_DEFAULT)
- continue;
- rib_sweep_table(znst->table);
- }
-}
-
-struct route_table *zebra_ns_get_table(struct zebra_ns *zns,
- struct zebra_vrf *zvrf, uint32_t tableid,
- afi_t afi)
-{
- struct zebra_ns_table finder;
- struct zebra_ns_table *znst;
- rib_table_info_t *info;
-
- memset(&finder, 0, sizeof(finder));
- finder.afi = afi;
- finder.tableid = tableid;
- finder.ns_id = zns->ns_id;
- znst = RB_FIND(zebra_ns_table_head, &zns->ns_tables, &finder);
-
- if (znst)
- return znst->table;
-
- znst = XCALLOC(MTYPE_ZEBRA_NS, sizeof(*znst));
- znst->tableid = tableid;
- znst->afi = afi;
- znst->ns_id = zns->ns_id;
- znst->table =
- (afi == AFI_IP6) ? srcdest_table_init() : route_table_init();
-
- info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info));
- info->zvrf = zvrf;
- info->afi = afi;
- info->safi = SAFI_UNICAST;
- znst->table->info = info;
- znst->table->cleanup = zebra_rtable_node_cleanup;
-
- RB_INSERT(zebra_ns_table_head, &zns->ns_tables, znst);
- return znst->table;
-}
-
-static void zebra_ns_free_table(struct zebra_ns_table *znst)
-{
- void *table_info;
-
- rib_close_table(znst->table);
-
- table_info = znst->table->info;
- route_table_finish(znst->table);
- XFREE(MTYPE_RIB_TABLE_INFO, table_info);
- XFREE(MTYPE_ZEBRA_NS, znst);
-}
-