]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: remove FDB entries before de-activating a L2-NHG
authorAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Fri, 8 May 2020 23:28:15 +0000 (16:28 -0700)
committerAnuradha Karuppiah <anuradhak@nvidia.com>
Tue, 1 Dec 2020 17:44:37 +0000 (09:44 -0800)
NHG is activated i.e. programmed in the dataplane only if there
are active-VTEPs associated with it. When a NHG is de-activated
all the remote-mac entries associated with it need to be removed
before the NHG is removed.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
zebra/zebra_evpn_mac.c
zebra/zebra_evpn_mac.h
zebra/zebra_evpn_mh.c

index 29efa1700e41bcfe80be61b124bb3a15cf5b3c1a..2acbd858b7d85d3b62f1656bc25c7ff3a2d7d059 100644 (file)
@@ -155,7 +155,8 @@ int zebra_evpn_rem_mac_install(zebra_evpn_t *zevpn, zebra_mac_t *mac,
 /*
  * Uninstall remote MAC from the forwarding plane.
  */
-int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevpn, zebra_mac_t *mac)
+int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevpn, zebra_mac_t *mac,
+                                bool force)
 {
        const struct zebra_if *zif, *br_zif;
        const struct zebra_l2info_vxlan *vxl;
@@ -167,6 +168,10 @@ int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevpn, zebra_mac_t *mac)
        if (!(mac->flags & ZEBRA_MAC_REMOTE))
                return 0;
 
+       /* If the MAC was not installed there is no need to uninstall it */
+       if (!force && mac->es && !(mac->es->flags & ZEBRA_EVPNES_NHG_ACTIVE))
+               return -1;
+
        if (!zevpn->vxlan_if) {
                if (IS_ZEBRA_DEBUG_VXLAN)
                        zlog_debug(
@@ -216,7 +221,7 @@ void zebra_evpn_deref_ip2mac(zebra_evpn_t *zevpn, zebra_mac_t *mac)
         */
        if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)
            && remote_neigh_count(mac) == 0) {
-               zebra_evpn_rem_mac_uninstall(zevpn, mac);
+               zebra_evpn_rem_mac_uninstall(zevpn, mac, false /*force*/);
                zebra_evpn_es_mac_deref_entry(mac);
                UNSET_FLAG(mac->flags, ZEBRA_MAC_REMOTE);
        }
@@ -1076,7 +1081,8 @@ static void zebra_evpn_mac_del_hash_entry(struct hash_bucket *bucket, void *arg)
                                        __func__);
 
                        if (mac->flags & ZEBRA_MAC_REMOTE)
-                               zebra_evpn_rem_mac_uninstall(wctx->zevpn, mac);
+                               zebra_evpn_rem_mac_uninstall(wctx->zevpn, mac,
+                                                            false /*force*/);
                }
 
                zebra_evpn_mac_del(wctx->zevpn, mac);
@@ -1694,7 +1700,7 @@ void zebra_evpn_rem_mac_del(zebra_evpn_t *zevpn, zebra_mac_t *mac)
         * go away, we need to uninstall the MAC.
         */
        if (remote_neigh_count(mac) == 0) {
-               zebra_evpn_rem_mac_uninstall(zevpn, mac);
+               zebra_evpn_rem_mac_uninstall(zevpn, mac, false /*force*/);
                zebra_evpn_es_mac_deref_entry(mac);
                UNSET_FLAG(mac->flags, ZEBRA_MAC_REMOTE);
        }
index 596fd0faad0a723288fe5d39679a212457d50ccc..b837259228eea45e8577a7e4aacc0d377cd2310d 100644 (file)
@@ -204,7 +204,8 @@ static inline void zebra_evpn_mac_clear_sync_info(zebra_mac_t *mac)
 struct hash *zebra_mac_db_create(const char *desc);
 uint32_t num_valid_macs(zebra_evpn_t *zevi);
 uint32_t num_dup_detected_macs(zebra_evpn_t *zevi);
-int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevi, zebra_mac_t *mac);
+int zebra_evpn_rem_mac_uninstall(zebra_evpn_t *zevi, zebra_mac_t *mac,
+                                bool force);
 int zebra_evpn_rem_mac_install(zebra_evpn_t *zevi, zebra_mac_t *mac,
                               bool was_static);
 void zebra_evpn_deref_ip2mac(zebra_evpn_t *zevi, zebra_mac_t *mac);
index 4ecff1aee3f6fd4c35e492dafefd73b00692c795..342cf4ff1dabc8a35f8d9018acba5308565a535f 100644 (file)
@@ -989,6 +989,25 @@ static void zebra_evpn_nhid_free(uint32_t nh_id)
        bf_release_index(zmh_info->nh_id_bitmap, id);
 }
 
+/* update remote macs associated with the ES */
+static void zebra_evpn_nhg_mac_update(struct zebra_evpn_es *es)
+{
+       zebra_mac_t *mac;
+       struct listnode *node;
+
+       for (ALL_LIST_ELEMENTS_RO(es->mac_list, node, mac)) {
+               if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE))
+                       continue;
+
+               if (es->flags & ZEBRA_EVPNES_NHG_ACTIVE)
+                       zebra_evpn_rem_mac_install(mac->zevpn, mac,
+                                                  false /*was_static*/);
+               else
+                       zebra_evpn_rem_mac_uninstall(mac->zevpn, mac,
+                                                    true /*force*/);
+       }
+}
+
 /* The MAC ECMP group is activated on the first VTEP */
 static void zebra_evpn_nhg_update(struct zebra_evpn_es *es)
 {
@@ -1028,7 +1047,6 @@ static void zebra_evpn_nhg_update(struct zebra_evpn_es *es)
                                   es->nhg_id, nh_str);
                }
 
-               es->flags |= ZEBRA_EVPNES_NHG_ACTIVE;
                kernel_upd_mac_nhg(es->nhg_id, nh_cnt, nh_ids);
                if (!(es->flags & ZEBRA_EVPNES_NHG_ACTIVE)) {
                        es->flags |= ZEBRA_EVPNES_NHG_ACTIVE;
@@ -1036,6 +1054,7 @@ static void zebra_evpn_nhg_update(struct zebra_evpn_es *es)
                        if ((es->flags & ZEBRA_EVPNES_LOCAL))
                                zebra_evpn_es_br_port_dplane_update(es,
                                                                    __func__);
+                       zebra_evpn_nhg_mac_update(es);
                }
        } else {
                if (es->flags & ZEBRA_EVPNES_NHG_ACTIVE) {
@@ -1047,11 +1066,11 @@ static void zebra_evpn_nhg_update(struct zebra_evpn_es *es)
                        if ((es->flags & ZEBRA_EVPNES_LOCAL))
                                zebra_evpn_es_br_port_dplane_update(es,
                                                                    __func__);
+                       zebra_evpn_nhg_mac_update(es);
                        kernel_del_mac_nhg(es->nhg_id);
                }
        }
 
-       /* XXX - update remote macs associated with the ES */
 }
 
 static void zebra_evpn_nh_add(struct zebra_evpn_es_vtep *es_vtep)