Skip to content

Commit

Permalink
zebra: Get link from the correct netns for vxlan
Browse files Browse the repository at this point in the history
If VRF backend is netns, bridges and SVIs are in the VRF's netns.
Get link information from there, rather than NS_DEFAULT.

Signed-off-by: Xiao Liang <[email protected]>
  • Loading branch information
leonshaw committed Jun 22, 2021
1 parent cd551a0 commit 1586ab1
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions zebra/zebra_vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 1586ab1

Please sign in to comment.