summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-09-27 15:45:42 +0200
committerAnuradha Karuppiah <anuradhak@cumulusnetworks.com>2020-08-18 09:25:06 -0700
commita237058f59d46af115dafa82c5ca1026418e0518 (patch)
treec20ab49e417b03bba47bb047f97b38eb3d71ec36
parent9d277b8c5239963bc6037f014e6c5fda5fa1c646 (diff)
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>
-rw-r--r--zebra/zebra_evpn.c13
-rw-r--r--zebra/zebra_evpn.h8
-rw-r--r--zebra/zebra_vxlan.c76
3 files changed, 58 insertions, 39 deletions
diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c
index b704c32c5c..eb9f99f2dd 100644
--- a/zebra/zebra_evpn.c
+++ b/zebra/zebra_evpn.c
@@ -675,13 +675,6 @@ zebra_evpn_t *zebra_evpn_map_vlan(struct interface *ifp,
return zevpn;
}
-struct zevpn_from_svi_param {
- struct interface *br_if;
- struct zebra_if *zif;
- uint8_t bridge_vlan_aware;
- vlanid_t vid;
-};
-
static int zebra_evpn_from_svi_zns(struct zebra_ns *zns,
void *_in_param,
void **_p_zevpn)
@@ -693,8 +686,8 @@ static int zebra_evpn_from_svi_zns(struct zebra_ns *zns,
struct interface *tmp_if = NULL;
struct zebra_if *zif;
struct zebra_l2info_vxlan *vxl = NULL;
- struct zevpn_from_svi_param *in_param =
- (struct zevpn_from_svi_param *)_in_param;
+ struct zebra_from_svi_param *in_param =
+ (struct zebra_from_svi_param *)_in_param;
int found = 0;
if (!in_param)
@@ -745,7 +738,7 @@ zebra_evpn_t *zebra_evpn_from_svi(struct interface *ifp,
zebra_evpn_t *zevpn = NULL;
zebra_evpn_t **p_zevpn;
struct zebra_if *zif;
- struct zevpn_from_svi_param in_param;
+ struct zebra_from_svi_param in_param;
if (!br_if)
return NULL;
diff --git a/zebra/zebra_evpn.h b/zebra/zebra_evpn.h
index 3b6a5b21e8..7b08a3f485 100644
--- a/zebra/zebra_evpn.h
+++ b/zebra/zebra_evpn.h
@@ -123,6 +123,14 @@ struct zebra_evpn_t_ {
struct list *local_es_evi_list;
};
+/* for parsing evpn and vni contexts */
+struct zebra_from_svi_param {
+ struct interface *br_if;
+ struct zebra_if *zif;
+ uint8_t bridge_vlan_aware;
+ vlanid_t vid;
+};
+
struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
static inline struct interface *zevpn_map_to_svi(zebra_evpn_t *zevpn)
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 7079184a34..5a58794378 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -782,6 +782,42 @@ static void zl3vni_print_hash_detail(struct hash_bucket *bucket, void *data)
vty_out(vty, "\n");
}
+static int zvni_map_to_svi_ns(struct zebra_ns *zns,
+ void *_in_param,
+ void **_p_ifp)
+{
+ struct route_node *rn;
+ struct zebra_from_svi_param *in_param =
+ (struct zebra_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
* of two cases:
* (a) In the case of a VLAN-aware bridge, the SVI is a L3 VLAN interface
@@ -791,15 +827,11 @@ static void zl3vni_print_hash_detail(struct hash_bucket *bucket, void *data)
*/
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 zebra_if *zif;
struct zebra_l2info_bridge *br;
- struct zebra_l2info_vlan *vl;
- uint8_t bridge_vlan_aware;
- int found = 0;
-
+ struct zebra_from_svi_param in_param;
+ struct interface **p_ifp;
/* Defensive check, caller expected to invoke only with valid bridge. */
if (!br_if)
return NULL;
@@ -808,33 +840,19 @@ struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if)
zif = br_if->info;
assert(zif);
br = &zif->l2info.br;
- bridge_vlan_aware = br->vlan_aware;
-
+ in_param.bridge_vlan_aware = br->vlan_aware;
/* 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;
+ in_param.vid = vid;
+ in_param.br_if = br_if;
+ in_param.zif = NULL;
+ p_ifp = &tmp_if;
/* Identify corresponding VLAN interface. */
- /* TODO: Optimize with a hash. */
- zns = zebra_ns_lookup(NS_DEFAULT);
- 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 != br_if)
- continue;
- vl = &zif->l2info.vl;
-
- if (vl->vid == vid) {
- found = 1;
- break;
- }
- }
-
- return found ? tmp_if : NULL;
+ zebra_ns_list_walk(zvni_map_to_svi_ns, (void *)&in_param,
+ (void **)p_ifp);
+ return tmp_if;
}
static int zebra_evpn_vxlan_del(zebra_evpn_t *zevpn)