]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: add ns_id attribute to mac structure
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 9 Oct 2019 09:34:46 +0000 (11:34 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 21 Sep 2020 07:17:10 +0000 (09:17 +0200)
this information is necessary for local information, because the
interface associated to the mac address is stored with its ifindex, and
the ifindex may not be enough to get to the right interface when it
comes with multiple network namespaces.

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

index eb4e4f9a571069fc5f8a4e86d3bb390e224ec396..75031ddba61789c3df462a8eda1936e56e2265ab 100644 (file)
@@ -249,7 +249,7 @@ static void zebra_evpn_mac_get_access_info(zebra_mac_t *mac,
                struct zebra_ns *zns;
 
                *vid = mac->fwd_info.local.vid;
-               zns = zebra_ns_lookup(NS_DEFAULT);
+               zns = zebra_ns_lookup(mac->fwd_info.local.ns_id);
                *ifpP = if_lookup_by_index_per_ns(zns,
                                                  mac->fwd_info.local.ifindex);
        }
@@ -1610,6 +1610,12 @@ static bool zebra_evpn_local_mac_update_fwd_info(zebra_mac_t *mac,
 {
        struct zebra_if *zif = ifp->info;
        bool es_change;
+       ns_id_t local_ns_id = NS_DEFAULT;
+       struct zebra_vrf *zvrf;
+
+       zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+       if (zvrf && zvrf->zns)
+               local_ns_id = zvrf->zns->ns_id;
 
        memset(&mac->fwd_info, 0, sizeof(mac->fwd_info));
 
@@ -1618,6 +1624,7 @@ static bool zebra_evpn_local_mac_update_fwd_info(zebra_mac_t *mac,
        if (!mac->es) {
                /* if es is set fwd_info is not-relevant/taped-out */
                mac->fwd_info.local.ifindex = ifp->ifindex;
+               mac->fwd_info.local.ns_id = local_ns_id;
                mac->fwd_info.local.vid = vid;
        }
 
@@ -2206,6 +2213,12 @@ int zebra_evpn_mac_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
 {
        char buf[ETHER_ADDR_STRLEN];
        zebra_mac_t *mac;
+       ns_id_t local_ns_id = NS_DEFAULT;
+       struct zebra_vrf *zvrf;
+
+       zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
+       if (zvrf && zvrf->zns)
+               local_ns_id = zvrf->zns->ns_id;
 
        mac = zebra_evpn_mac_lookup(zevpn, macaddr);
        if (!mac) {
@@ -2225,6 +2238,7 @@ int zebra_evpn_mac_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
        SET_FLAG(mac->flags, ZEBRA_MAC_DEF_GW);
        memset(&mac->fwd_info, 0, sizeof(mac->fwd_info));
        mac->fwd_info.local.ifindex = ifp->ifindex;
+       mac->fwd_info.local.ns_id = local_ns_id;
        mac->fwd_info.local.vid = vlan_id;
 
        *macp = mac;
index 39aaf1fb308098a130370b469b357aa28cb7da05..f9ca81445f6c7a622e4687f79554900581291634 100644 (file)
@@ -91,6 +91,7 @@ struct zebra_mac_t_ {
        union {
                struct {
                        ifindex_t ifindex;
+                       ns_id_t ns_id;
                        vlanid_t vid;
                } local;