]> git.puffer.fish Git - mirror/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)
committerAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Tue, 18 Aug 2020 16:25:06 +0000 (09:25 -0700)
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 b9cc02a2762e57c9013d1f4c193f2cf725878142..6fc141efbbdc9c0ede451346f658f9c7395cbec0 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;
        }
 
@@ -2204,6 +2211,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) {
@@ -2223,6 +2236,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;