diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2023-04-26 23:25:27 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2023-07-05 11:49:36 -0400 |
| commit | 6a3ae11c9b1480966b22d4f9b67a40b76d96aa15 (patch) | |
| tree | c01ee9579924a91b3970c76ad412ac5e55a0ab20 /zebra/zebra_vrf.c | |
| parent | d6caf0dbd7bc9c516d178430ca571ac0c94df84d (diff) | |
zebra: Rename vrf_lookup_by_tableid to zebra_vrf_lookup..
Rename the vrf_lookup_by_id function to zebra_vrf_lookup_by_id
and move to zebra_vrf.c where it nominally belongs, as that
we need zebra specific data to find this vrf_id and as such
it does not belong in vrf.c
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_vrf.c')
| -rw-r--r-- | zebra/zebra_vrf.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 3365cdcdba..74b9d106cd 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -376,6 +376,33 @@ struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf) return zvrf; } +/* +Pending: create an efficient table_id (in a tree/hash) based lookup) + */ +vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id) +{ + struct vrf *vrf; + struct zebra_vrf *zvrf; + + RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { + zvrf = vrf->info; + if (zvrf == NULL) + continue; + /* case vrf with netns : match the netnsid */ + if (vrf_is_backend_netns()) { + if (ns_id == zvrf_id(zvrf)) + return zvrf_id(zvrf); + } else { + /* VRF is VRF_BACKEND_VRF_LITE */ + if (zvrf->table_id != table_id) + continue; + return zvrf_id(zvrf); + } + } + + return VRF_DEFAULT; +} + /* Lookup VRF by identifier. */ struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id) { |
