mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-30 06:42:17 +00:00
zebra: zvni_map_to_svi() adaptation for other network namespaces
the function is called with all the network namespaces. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
6fe516bd4b
commit
2a9dccb647
@ -3682,6 +3682,42 @@ static zebra_vni_t *zvni_from_svi(struct interface *ifp,
|
|||||||
return zvni;
|
return zvni;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int zvni_map_to_svi_zns(struct zebra_ns *zns,
|
||||||
|
void *_in_param,
|
||||||
|
void **_p_ifp)
|
||||||
|
{
|
||||||
|
struct route_node *rn;
|
||||||
|
struct zvni_from_svi_param *in_param =
|
||||||
|
(struct zvni_from_svi_param *)_in_param;
|
||||||
|
struct zebra_l2info_vlan *vl;
|
||||||
|
struct interface *tmp_if = NULL;
|
||||||
|
struct interface **p_ifp = (struct interface **)_p_ifp;
|
||||||
|
struct zebra_if *zif;
|
||||||
|
|
||||||
|
if (!in_param)
|
||||||
|
return ZNS_WALK_STOP;
|
||||||
|
|
||||||
|
/* TODO: Optimize with a hash. */
|
||||||
|
for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) {
|
||||||
|
tmp_if = (struct interface *)rn->info;
|
||||||
|
/* Check oper status of the SVI. */
|
||||||
|
if (!tmp_if || !if_is_operative(tmp_if))
|
||||||
|
continue;
|
||||||
|
zif = tmp_if->info;
|
||||||
|
if (!zif || zif->zif_type != ZEBRA_IF_VLAN
|
||||||
|
|| zif->link != in_param->br_if)
|
||||||
|
continue;
|
||||||
|
vl = (struct zebra_l2info_vlan *)&zif->l2info.vl;
|
||||||
|
|
||||||
|
if (vl->vid == in_param->vid) {
|
||||||
|
if (p_ifp)
|
||||||
|
*p_ifp = tmp_if;
|
||||||
|
return ZNS_WALK_STOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ZNS_WALK_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Map to SVI on bridge corresponding to specified VLAN. This can be one
|
/* Map to SVI on bridge corresponding to specified VLAN. This can be one
|
||||||
* of two cases:
|
* of two cases:
|
||||||
* (a) In the case of a VLAN-aware bridge, the SVI is a L3 VLAN interface
|
* (a) In the case of a VLAN-aware bridge, the SVI is a L3 VLAN interface
|
||||||
@ -3691,15 +3727,11 @@ static zebra_vni_t *zvni_from_svi(struct interface *ifp,
|
|||||||
*/
|
*/
|
||||||
static struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if)
|
static struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if)
|
||||||
{
|
{
|
||||||
struct zebra_ns *zns;
|
|
||||||
struct route_node *rn;
|
|
||||||
struct interface *tmp_if = NULL;
|
struct interface *tmp_if = NULL;
|
||||||
struct zebra_if *zif;
|
struct zebra_if *zif;
|
||||||
struct zebra_l2info_bridge *br;
|
struct zebra_l2info_bridge *br;
|
||||||
struct zebra_l2info_vlan *vl;
|
struct zvni_from_svi_param in_param;
|
||||||
uint8_t bridge_vlan_aware;
|
struct interface **p_ifp;
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
/* Defensive check, caller expected to invoke only with valid bridge. */
|
/* Defensive check, caller expected to invoke only with valid bridge. */
|
||||||
if (!br_if)
|
if (!br_if)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3708,33 +3740,19 @@ static struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if)
|
|||||||
zif = br_if->info;
|
zif = br_if->info;
|
||||||
assert(zif);
|
assert(zif);
|
||||||
br = &zif->l2info.br;
|
br = &zif->l2info.br;
|
||||||
bridge_vlan_aware = br->vlan_aware;
|
in_param.bridge_vlan_aware = br->vlan_aware;
|
||||||
|
|
||||||
/* Check oper status of the SVI. */
|
/* Check oper status of the SVI. */
|
||||||
if (!bridge_vlan_aware)
|
if (!in_param.bridge_vlan_aware)
|
||||||
return if_is_operative(br_if) ? br_if : NULL;
|
return if_is_operative(br_if) ? br_if : NULL;
|
||||||
|
|
||||||
|
in_param.vid = vid;
|
||||||
|
in_param.br_if = br_if;
|
||||||
|
in_param.zif = NULL;
|
||||||
|
p_ifp = &tmp_if;
|
||||||
/* Identify corresponding VLAN interface. */
|
/* Identify corresponding VLAN interface. */
|
||||||
/* TODO: Optimize with a hash. */
|
zebra_ns_list_walk(zvni_map_to_svi_zns, (void *)&in_param,
|
||||||
zns = zebra_ns_lookup(NS_DEFAULT);
|
(void **)p_ifp);
|
||||||
for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) {
|
return tmp_if;
|
||||||
tmp_if = (struct interface *)rn->info;
|
|
||||||
/* Check oper status of the SVI. */
|
|
||||||
if (!tmp_if || !if_is_operative(tmp_if))
|
|
||||||
continue;
|
|
||||||
zif = tmp_if->info;
|
|
||||||
if (!zif || zif->zif_type != ZEBRA_IF_VLAN
|
|
||||||
|| zif->link != br_if)
|
|
||||||
continue;
|
|
||||||
vl = &zif->l2info.vl;
|
|
||||||
|
|
||||||
if (vl->vid == vid) {
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found ? tmp_if : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map to MAC-VLAN interface corresponding to specified SVI interface.
|
/* Map to MAC-VLAN interface corresponding to specified SVI interface.
|
||||||
|
Loading…
Reference in New Issue
Block a user