]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: support for macvlan interfaces 5077/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 6 Feb 2020 08:33:21 +0000 (09:33 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 18 May 2020 12:11:03 +0000 (14:11 +0200)
mac vlan interfaces are supported in different network namespaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/zebra_vxlan.c

index 244b398e47abe8fdb323a08905d76473f7e1268b..998c03565685b1e1bd2363bb054cce07926ad0a2 100644 (file)
@@ -3530,6 +3530,7 @@ static int zvni_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr)
 
 struct zvni_from_svi_param {
        struct interface *br_if;
+       struct interface *svi_if;
        struct zebra_if *zif;
        uint8_t bridge_vlan_aware;
        vlanid_t vid;
@@ -3795,16 +3796,51 @@ static struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if)
        return tmp_if;
 }
 
+static int zvni_map_to_macvlan_ns(struct ns *ns,
+                                 void *_in_param,
+                                 void **_p_ifp)
+{
+       struct zebra_ns *zns = ns->info;
+       struct zvni_from_svi_param *in_param =
+               (struct zvni_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.
  */
 static struct interface *zvni_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 zvni_from_svi_param in_param;
 
        /* Defensive check, caller expected to invoke only with valid bridge. */
        if (!br_if)
@@ -3819,28 +3855,19 @@ static struct interface *zvni_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;
 }
 
-
 /*
  * Install remote MAC into the forwarding plane.
  */