From: Philippe Guibert Date: Thu, 6 Feb 2020 08:33:21 +0000 (+0100) Subject: zebra: support for macvlan interfaces X-Git-Tag: frr-7.5~15^2~5 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=4acf820295fee9513e97302f70bfb0c0f602a40a;p=matthieu%2Ffrr.git zebra: support for macvlan interfaces mac vlan interfaces are supported in different network namespaces. Signed-off-by: Philippe Guibert --- diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index 0f5e77ac65..80124f92b3 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -806,16 +806,51 @@ zebra_evpn_t *zebra_evpn_from_svi(struct interface *ifp, return zevpn; } +static int zvni_map_to_macvlan_ns(struct ns *ns, + void *_in_param, + void **_p_ifp) +{ + struct zebra_ns *zns = ns->info; + struct zebra_from_svi_param *in_param = + (struct zebra_from_svi_param *)_in_param; + struct interface **p_ifp = (struct interface **)_p_ifp; + struct route_node *rn; + struct interface *tmp_if = NULL; + struct zebra_if *zif; + + if (!in_param) + return NS_WALK_STOP; + + /* Identify corresponding VLAN interface. */ + 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_MACVLAN) + continue; + + if (zif->link == in_param->svi_if) { + if (p_ifp) + *p_ifp = tmp_if; + return NS_WALK_STOP; + } + } + + return NS_WALK_CONTINUE; +} + /* Map to MAC-VLAN interface corresponding to specified SVI interface. */ struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if, struct interface *svi_if) { - struct zebra_ns *zns; - struct route_node *rn; struct interface *tmp_if = NULL; struct zebra_if *zif; - int found = 0; + struct interface **p_ifp; + struct zebra_from_svi_param in_param; /* Defensive check, caller expected to invoke only with valid bridge. */ if (!br_if) @@ -830,25 +865,17 @@ struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if, zif = br_if->info; assert(zif); - /* Identify corresponding VLAN interface. */ - 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_MACVLAN) - continue; - - if (zif->link == svi_if) { - found = 1; - break; - } - } + in_param.vid = 0; + in_param.br_if = br_if; + in_param.zif = NULL; + in_param.svi_if = svi_if; + p_ifp = &tmp_if; - return found ? tmp_if : NULL; + /* Identify corresponding VLAN interface. */ + ns_walk_func(zvni_map_to_macvlan_ns, + (void *)&in_param, + (void **)p_ifp); + return tmp_if; } /* diff --git a/zebra/zebra_evpn.h b/zebra/zebra_evpn.h index 7b08a3f485..27392ec85c 100644 --- a/zebra/zebra_evpn.h +++ b/zebra/zebra_evpn.h @@ -126,6 +126,7 @@ struct zebra_evpn_t_ { /* for parsing evpn and vni contexts */ struct zebra_from_svi_param { struct interface *br_if; + struct interface *svi_if; struct zebra_if *zif; uint8_t bridge_vlan_aware; vlanid_t vid;