if (afi >= AFI_MAX)
return (-1);
- table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST, vrf_id,
- table_id);
+ table = zebra_vrf_get_table_with_table_id(afi, SAFI_UNICAST, vrf_id,
+ table_id);
if (table == NULL) {
return 0;
} else if (IS_ZEBRA_DEBUG_RIB) {
if ((!rmap_name) || (strcmp(rmap_name, rmap) != 0))
return;
- table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST,
- zvrf->vrf->vrf_id, table_id);
+ table = zebra_vrf_get_table_with_table_id(afi, SAFI_UNICAST,
+ zvrf->vrf->vrf_id, table_id);
if (!table) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%s: Table id=%d not found", __func__,
/* Locate rn and re(s) from ctx */
- table = zebra_vrf_table_with_table_id(dplane_ctx_get_afi(ctx),
- dplane_ctx_get_safi(ctx),
- dplane_ctx_get_vrf(ctx),
- dplane_ctx_get_table(ctx));
+ table = zebra_vrf_lookup_table_with_table_id(
+ dplane_ctx_get_afi(ctx), dplane_ctx_get_safi(ctx),
+ dplane_ctx_get_vrf(ctx), dplane_ctx_get_table(ctx));
if (table == NULL) {
if (IS_ZEBRA_DEBUG_DPLANE) {
zlog_debug("Failed to find route for ctx: no table for afi %d, safi %d, vrf %u",
assert(!src_p || !src_p->prefixlen || afi == AFI_IP6);
/* Lookup table. */
- table = zebra_vrf_table_with_table_id(afi, safi, re->vrf_id, re->table);
+ table = zebra_vrf_get_table_with_table_id(afi, safi, re->vrf_id,
+ re->table);
if (!table) {
if (re->ng)
nexthop_group_delete(&re->ng);
assert(!src_p || !src_p->prefixlen || afi == AFI_IP6);
/* Lookup table. */
- table = zebra_vrf_table_with_table_id(afi, safi, vrf_id, table_id);
+ table = zebra_vrf_lookup_table_with_table_id(afi, safi, vrf_id,
+ table_id);
if (!table)
return;
* - case VRF backend is default : on default VRF only
* - case VRF backend is netns : on all VRFs
*/
-struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
- vrf_id_t vrf_id,
- uint32_t table_id)
+struct route_table *zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi,
+ vrf_id_t vrf_id,
+ uint32_t table_id)
{
struct zebra_vrf *zvrf = vrf_info_lookup(vrf_id);
struct other_route_table ort, *otable;
- struct route_table *table;
if (!zvrf)
return NULL;
ort.safi = safi;
ort.table_id = table_id;
otable = otable_find(&zvrf->other_tables, &ort);
+
if (otable)
return otable->table;
+ return NULL;
+}
+
+struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi, safi_t safi,
+ vrf_id_t vrf_id,
+ uint32_t table_id)
+{
+ struct zebra_vrf *zvrf = vrf_info_lookup(vrf_id);
+ struct other_route_table *otable;
+ struct route_table *table;
+
+ table = zebra_vrf_lookup_table_with_table_id(afi, safi, vrf_id,
+ table_id);
+
+ if (table)
+ goto done;
+
+ /* Create it as an `other` table */
table = zebra_router_get_table(zvrf, table_id, afi, safi);
otable = XCALLOC(MTYPE_OTHER_TABLE, sizeof(*otable));
otable->table = table;
otable_add(&zvrf->other_tables, otable);
+done:
return table;
}
DECLARE_RBTREE_UNIQ(otable, struct other_route_table, next,
zvrf_other_table_compare_func)
-struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
- vrf_id_t vrf_id,
- uint32_t table_id);
+extern struct route_table *
+zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi, vrf_id_t vrf_id,
+ uint32_t table_id);
+extern struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi,
+ safi_t safi,
+ vrf_id_t vrf_id,
+ uint32_t table_id);
extern void zebra_vrf_update_all(struct zserv *client);
extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id);
if ((zvrf = vrf->info) == NULL)
continue;
- table = zebra_vrf_table_with_table_id(afi,
- SAFI_UNICAST,
- zvrf->vrf->vrf_id,
- table_id);
+ table = zebra_vrf_lookup_table_with_table_id(
+ afi, SAFI_UNICAST, zvrf->vrf->vrf_id, table_id);
+
if (!table)
continue;
if (vrf_name)
VRF_GET_ID(vrf_id, vrf_name, false);
- table = zebra_vrf_table_with_table_id(afi,
- SAFI_UNICAST,
- vrf_id, table_id);
+ table = zebra_vrf_lookup_table_with_table_id(afi, SAFI_UNICAST,
+ vrf_id, table_id);
if (!table)
return CMD_SUCCESS;