diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 09eb78917ce8..873e4e4626ee 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -1780,7 +1780,7 @@ static zebra_l3vni_t *zl3vni_from_svi(struct interface *ifp, vlanid_t vid = 0; uint8_t bridge_vlan_aware = 0; zebra_l3vni_t *zl3vni = NULL; - struct zebra_ns *zns = NULL; + struct zebra_vrf *zvrf = NULL; struct route_node *rn = NULL; struct zebra_if *zif = NULL; struct interface *tmp_if = NULL; @@ -1790,6 +1790,10 @@ static zebra_l3vni_t *zl3vni_from_svi(struct interface *ifp, if (!br_if) return NULL; + zvrf = vrf_info_lookup(br_if->vrf_id); + if (!zvrf || !zvrf->zns) + return NULL; + /* Make sure the linked interface is a bridge. */ if (!IS_ZEBRA_IF_BRIDGE(br_if)) return NULL; @@ -1813,8 +1817,7 @@ static zebra_l3vni_t *zl3vni_from_svi(struct interface *ifp, /* See if this interface (or interface plus VLAN Id) maps to a VxLAN */ /* TODO: Optimize with a hash. */ - zns = zebra_ns_lookup(NS_DEFAULT); - for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) { + for (rn = route_top(zvrf->zns->if_table); rn; rn = route_next(rn)) { tmp_if = (struct interface *)rn->info; if (!tmp_if) continue; @@ -2017,7 +2020,6 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, vni_t vni, return -1; } } else { - struct zebra_ns *zns; struct route_node *rn; struct interface *ifp; struct zebra_if *zif; @@ -2030,8 +2032,8 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, vni_t vni, vni); /* Find VxLAN interface for this VNI. */ - zns = zebra_ns_lookup(NS_DEFAULT); - for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) { + for (rn = route_top(zvrf->zns->if_table); rn; + rn = route_next(rn)) { ifp = (struct interface *)rn->info; if (!ifp) continue; @@ -4405,8 +4407,7 @@ int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p, /* * for a MACVLAN interface the link represents the svi_if */ - svi_if = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), - ifp_zif->link_ifindex); + svi_if = ifp_zif->link; if (!svi_if) { zlog_debug("MACVLAN %s(%u) without link information", ifp->name, ifp->ifindex); @@ -4422,9 +4423,7 @@ int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p, svi_if_zif = svi_if->info; if (svi_if_zif) { - svi_if_link = if_lookup_by_index_per_ns( - zebra_ns_lookup(NS_DEFAULT), - svi_if_zif->link_ifindex); + svi_if_link = svi_if_zif->link; zevpn = zebra_evpn_from_svi(svi_if, svi_if_link); } @@ -4443,9 +4442,7 @@ int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p, svi_if_zif = ifp->info; if (svi_if_zif) { - svi_if_link = if_lookup_by_index_per_ns( - zebra_ns_lookup(NS_DEFAULT), - svi_if_zif->link_ifindex); + svi_if_link = svi_if_zif->link; if (svi_if_link) zevpn = zebra_evpn_from_svi(ifp, svi_if_link); } @@ -4628,8 +4625,7 @@ void zebra_vxlan_macvlan_down(struct interface *ifp) link_zif = link_ifp->info; assert(link_zif); - link_if = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), - link_zif->link_ifindex); + link_if = link_zif->link; zl3vni = zl3vni_from_svi(link_ifp, link_if); if (zl3vni) { @@ -4658,8 +4654,7 @@ void zebra_vxlan_macvlan_up(struct interface *ifp) link_zif = link_ifp->info; assert(link_zif); - link_if = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), - link_zif->link_ifindex); + link_if = link_zif->link; zl3vni = zl3vni_from_svi(link_ifp, link_if); if (zl3vni) { /* associate with macvlan (VRR) interface */