summaryrefslogtreecommitdiff
path: root/zebra/zebra_vxlan_if.c
diff options
context:
space:
mode:
authorSharath Ramamurthy <sramamurthy@nvidia.com>2021-07-27 14:54:40 +0530
committerStephen Worley <sworley@nvidia.com>2023-02-13 18:12:04 -0500
commitefde4f25612fb3a690ed1e0ce789a490f949bb2e (patch)
tree50630ce82382f9009ec471472a2ec2d244c103ab /zebra/zebra_vxlan_if.c
parent239b26f932e5b78828dce8f7fe628c12b7ddbd9f (diff)
zebra: Refactoring changes for zebra_evpn_map_vlan zebra_evpn_from_svi and zl3vni_from_svi
Today to find the vni for a given (vlan, bridge) we walk over all interfaces and filter the vxlan device associated with the bridge. With multiple vlan aware bridge changes, we can derive the vni directly by looking up the hash table i.e. the vlan_table of the associated (vlan, bridge) which would give the vni. During vrf_terminate() call zebra_l2_bridge_if_cleanup if the interface that we are removing is of type bridge. In this case, we walk over all the vlan<->access_bd association and clean them up. zebra_evpn_t is modified to record (vlan, bridge) details and the corresponding vty is modified to print the same. zevpn_bridge_if_set and zl3vni_bridge_if_set is used to set/unset the association. Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
Diffstat (limited to 'zebra/zebra_vxlan_if.c')
-rw-r--r--zebra/zebra_vxlan_if.c81
1 files changed, 35 insertions, 46 deletions
diff --git a/zebra/zebra_vxlan_if.c b/zebra/zebra_vxlan_if.c
index 1491b8bc5a..d4a05fcc0b 100644
--- a/zebra/zebra_vxlan_if.c
+++ b/zebra/zebra_vxlan_if.c
@@ -87,22 +87,6 @@ static int zebra_vxlan_if_vni_walk_callback(struct hash_bucket *bucket,
return ret;
}
-static int zebra_vxlan_if_vni_access_vlan_find(struct zebra_if *zif,
- struct zebra_vxlan_vni *vni,
- void *ctxt)
-{
- int ret = HASHWALK_CONTINUE;
- struct zebra_vxlan_if_vlan_ctx *ctx;
-
- ctx = (struct zebra_vxlan_if_vlan_ctx *)ctxt;
-
- if (vni->access_vlan == ctx->vid) {
- ctx->vni = vni;
- ret = HASHWALK_ABORT;
- }
- return ret;
-}
-
static void zebra_vxlan_if_vni_iterate_callback(struct hash_bucket *bucket,
void *ctxt)
{
@@ -122,6 +106,7 @@ static int zebra_vxlan_if_del_vni(struct interface *ifp,
struct zebra_if *zif;
struct zebra_evpn *zevpn;
struct zebra_l3vni *zl3vni;
+ struct interface *br_if;
/* Check if EVPN is enabled. */
if (!is_evpn_enabled())
@@ -144,6 +129,9 @@ static int zebra_vxlan_if_del_vni(struct interface *ifp,
/* remove the association with vxlan_if */
memset(&zl3vni->local_vtep_ip, 0, sizeof(struct in_addr));
zl3vni->vxlan_if = NULL;
+ zl3vni->vid = 0;
+ br_if = zif->brslave_info.br_if;
+ zl3vni_bridge_if_set(zl3vni, br_if, false /* unset */);
} else {
/* process if-del for l2-vni*/
@@ -195,6 +183,7 @@ static int zebra_vxlan_if_update_vni(struct interface *ifp,
struct zebra_evpn *zevpn;
struct zebra_l3vni *zl3vni;
struct interface *vlan_if;
+ struct interface *br_if;
/* Check if EVPN is enabled. */
if (!is_evpn_enabled())
@@ -263,6 +252,12 @@ static int zebra_vxlan_if_update_vni(struct interface *ifp,
/* Update local tunnel IP. */
zl3vni->local_vtep_ip = vxl->vtep_ip;
+ zl3vni->vid = (zl3vni->vid != vnip->access_vlan)
+ ? vnip->access_vlan
+ : zl3vni->vid;
+ br_if = zif->brslave_info.br_if;
+ zl3vni_bridge_if_set(zl3vni, br_if, true /* set */);
+
/* if we have a valid new master, process l3-vni oper up */
if (chgflags & ZEBRA_VXLIF_MASTER_CHANGE) {
if (if_is_operative(ifp) && is_l3vni_oper_up(zl3vni))
@@ -321,8 +316,13 @@ static int zebra_vxlan_if_update_vni(struct interface *ifp,
zebra_evpn_es_set_base_evpn(zevpn);
}
zevpn_vxlan_if_set(zevpn, ifp, true /* set */);
- vlan_if = zvni_map_to_svi(vnip->access_vlan,
- zif->brslave_info.br_if);
+ zevpn->vid = (zevpn->vid != vnip->access_vlan)
+ ? vnip->access_vlan
+ : zevpn->vid;
+ br_if = zif->brslave_info.br_if;
+ zevpn_bridge_if_set(zevpn, br_if, true /* set */);
+
+ vlan_if = zvni_map_to_svi(vnip->access_vlan, br_if);
if (vlan_if)
zevpn->svi_if = vlan_if;
@@ -375,6 +375,7 @@ static int zebra_vxlan_if_add_vni(struct interface *ifp,
struct zebra_l2info_vxlan *vxl;
struct zebra_evpn *zevpn;
struct zebra_l3vni *zl3vni;
+ struct interface *br_if;
/* Check if EVPN is enabled. */
if (!is_evpn_enabled())
@@ -406,6 +407,10 @@ static int zebra_vxlan_if_add_vni(struct interface *ifp,
zl3vni->mac_vlan_if = zl3vni_map_to_mac_vlan_if(zl3vni);
+ zl3vni->vid = vnip->access_vlan;
+ br_if = zif->brslave_info.br_if;
+ zl3vni_bridge_if_set(zl3vni, br_if, true /* set */);
+
if (is_l3vni_oper_up(zl3vni))
zebra_vxlan_process_l3vni_oper_up(zl3vni);
} else {
@@ -431,9 +436,11 @@ static int zebra_vxlan_if_add_vni(struct interface *ifp,
zebra_evpn_es_set_base_evpn(zevpn);
}
zevpn_vxlan_if_set(zevpn, ifp, true /* set */);
- vlan_if = zvni_map_to_svi(vnip->access_vlan,
- zif->brslave_info.br_if);
+ br_if = zif->brslave_info.br_if;
+ zevpn_bridge_if_set(zevpn, br_if, true /* set */);
+ vlan_if = zvni_map_to_svi(vnip->access_vlan, br_if);
if (vlan_if) {
+ zevpn->vid = vnip->access_vlan;
zevpn->svi_if = vlan_if;
zevpn->vrf_id = vlan_if->vrf->vrf_id;
zl3vni = zl3vni_from_vrf(vlan_if->vrf->vrf_id);
@@ -727,27 +734,17 @@ void zebra_vxlan_if_vni_walk(struct zebra_if *zif,
hash_walk(vni_info->vni_table, zebra_vxlan_if_vni_walk_callback, &ctx);
}
-struct zebra_vxlan_vni *zebra_vxlan_if_access_vlan_find(struct zebra_if *zif,
- uint8_t vlan_aware,
- vlanid_t vid)
+vni_t zebra_vxlan_if_access_vlan_vni_find(struct zebra_if *zif, vlanid_t vid,
+ struct interface *br_if)
{
struct zebra_vxlan_vni *vni = NULL;
- struct zebra_vxlan_if_vlan_ctx ctx;
- if (IS_ZEBRA_VXLAN_IF_VNI(zif)) {
- vni = zebra_vxlan_if_vni_find(zif, 0);
- if (vlan_aware && vni->access_vlan != vid)
- vni = NULL;
- return vni;
- }
-
- ctx.vid = vid;
- ctx.vni = NULL;
- zebra_vxlan_if_vni_walk(zif, zebra_vxlan_if_vni_access_vlan_find,
- (void *)&ctx);
- vni = ctx.vni;
+ /* Expected to be called only for vlan-unware bridges */
+ assert(!IS_ZEBRA_IF_BRIDGE_VLAN_AWARE((struct zebra_if *)br_if->info));
+ vni = zebra_vxlan_if_vni_find(zif, 0);
+ assert(vni);
- return vni;
+ return vni->vni;
}
int zebra_vxlan_if_vni_table_add_update(struct interface *ifp,
@@ -991,10 +988,6 @@ int zebra_vxlan_if_vni_del(struct interface *ifp, vni_t vni)
struct zebra_vxlan_vni vni_tmp;
struct zebra_vxlan_vni_info *vni_info;
- /* Check if EVPN is enabled. */
- if (!is_evpn_enabled())
- return 0;
-
zif = ifp->info;
assert(zif);
@@ -1022,10 +1015,6 @@ int zebra_vxlan_if_del(struct interface *ifp)
struct zebra_if *zif;
struct zebra_vxlan_vni_info *vni_info;
- /* Check if EVPN is enabled. */
- if (!is_evpn_enabled())
- return 0;
-
zif = ifp->info;
assert(zif);
@@ -1098,7 +1087,7 @@ int zebra_vxlan_if_vni_add(struct interface *ifp, struct zebra_vxlan_vni *vni)
/* This should be called in SVD context only */
assert(IS_ZEBRA_VXLAN_IF_SVD(zif));
- /* First inser into the table */
+ /* First insert into the table */
vni_info = VNI_INFO_FROM_ZEBRA_IF(zif);
hash_get(vni_info->vni_table, (void *)vni, zebra_vxlan_vni_alloc);