]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: extract local mac del from zebra_vxlan.c
authorPat Ruddy <pat@voltanet.io>
Wed, 22 Apr 2020 15:12:08 +0000 (16:12 +0100)
committerPat Ruddy <pat@voltanet.io>
Wed, 12 Aug 2020 11:39:34 +0000 (12:39 +0100)
extract generic local mac add code from zebra_vxlan_local_mac_del
into a new function zebra_evpn_del_local_mac in zebra_evpn_mac.c

Signed-off-by: Pat Ruddy <pat@voltanet.io>
zebra/zebra_evpn_mac.c
zebra/zebra_evpn_mac.h
zebra/zebra_evpn_neigh.h
zebra/zebra_vxlan.c

index de0f2b80d76a584d0eefce60fbc47bab876a98bc..d02fd7a898e13d5b19c07936885c08528a15512f 100644 (file)
@@ -2117,3 +2117,82 @@ int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf, zebra_evpn_t *zevpn,
 
        return 0;
 }
+
+int zebra_evpn_del_local_mac(zebra_evpn_t *zevpn, struct ethaddr *macaddr,
+                            struct interface *ifp)
+{
+       zebra_mac_t *mac;
+       char buf[ETHER_ADDR_STRLEN];
+       bool old_bgp_ready;
+       bool new_bgp_ready;
+       /* If entry doesn't exist, nothing to do. */
+       mac = zebra_evpn_mac_lookup(zevpn, macaddr);
+       if (!mac)
+               return 0;
+
+       /* Is it a local entry? */
+       if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL))
+               return 0;
+
+       if (IS_ZEBRA_DEBUG_VXLAN)
+               zlog_debug(
+                       "DEL MAC %s intf %s(%u) VID %u -> VNI %u seq %u flags 0x%x nbr count %u",
+                       prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name,
+                       ifp->ifindex, mac->fwd_info.local.vid, zevpn->vni,
+                       mac->loc_seq, mac->flags, listcount(mac->neigh_list));
+
+       old_bgp_ready = zebra_evpn_mac_is_ready_for_bgp(mac->flags);
+       if (zebra_evpn_mac_is_static(mac)) {
+               /* this is a synced entry and can only be removed when the
+                * es-peers stop advertising it.
+                */
+               memset(&mac->fwd_info, 0, sizeof(mac->fwd_info));
+
+               if (IS_ZEBRA_DEBUG_EVPN_MH_MAC)
+                       zlog_debug(
+                               "re-add sync-mac vni %u mac %s es %s seq %d f 0x%x",
+                               zevpn->vni,
+                               prefix_mac2str(macaddr, buf, sizeof(buf)),
+                               mac->es ? mac->es->esi_str : "-", mac->loc_seq,
+                               mac->flags);
+
+               /* inform-bgp about change in local-activity if any */
+               if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE)) {
+                       SET_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE);
+                       new_bgp_ready =
+                               zebra_evpn_mac_is_ready_for_bgp(mac->flags);
+                       zebra_evpn_mac_send_add_del_to_client(
+                               mac, old_bgp_ready, new_bgp_ready);
+               }
+
+               /* re-install the entry in the kernel */
+               zebra_evpn_sync_mac_dp_install(mac, false /* set_inactive */,
+                                              false /* force_clear_static */,
+                                              __func__);
+
+               return 0;
+       }
+
+       /* Update all the neigh entries associated with this mac */
+       zebra_evpn_process_neigh_on_local_mac_del(zevpn, mac);
+
+       /* Remove MAC from BGP. */
+       zebra_evpn_mac_send_del_to_client(zevpn->vni, macaddr, mac->flags,
+                                         false /* force */);
+
+       zebra_evpn_es_mac_deref_entry(mac);
+
+       /*
+        * If there are no neigh associated with the mac delete the mac
+        * else mark it as AUTO for forward reference
+        */
+       if (!listcount(mac->neigh_list)) {
+               zebra_evpn_mac_del(zevpn, mac);
+       } else {
+               UNSET_FLAG(mac->flags, ZEBRA_MAC_ALL_LOCAL_FLAGS);
+               UNSET_FLAG(mac->flags, ZEBRA_MAC_STICKY);
+               SET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
+       }
+
+       return 0;
+}
index 1ecd4aaf87ffbbfad3f0b0ab9c5d10086c36429c..b6ee9d8f307cdf0592e064f197d7c7af5c6ddd49 100644 (file)
@@ -250,6 +250,9 @@ int zebra_evpn_add_update_local_mac(struct zebra_vrf *zvrf, zebra_evpn_t *zevpn,
                                    struct ethaddr *macaddr, vlanid_t vid,
                                    bool sticky, bool local_inactive,
                                    bool dp_static);
+int zebra_evpn_del_local_mac(zebra_evpn_t *zevpn, struct ethaddr *macaddr,
+                            struct interface *ifp);
+
 #ifdef __cplusplus
 }
 #endif
index 97fc2ec9f3bf2f10848892ab669c9cfb8bd086f5..d1fac43a582ee8ae85acd2b181f5e87635e61231 100644 (file)
@@ -155,6 +155,8 @@ void zebra_evpn_process_neigh_on_local_mac_change(zebra_evpn_t *zevpn,
 void zebra_evpn_process_neigh_on_remote_mac_del(zebra_evpn_t *zevpn,
                                                zebra_mac_t *zmac);
 
+void zebra_evpn_process_neigh_on_local_mac_del(zebra_evpn_t *zevpn,
+                                              zebra_mac_t *zmac);
 #ifdef __cplusplus
 }
 #endif
index 22194ee6127e9fd6bed41275ffe6002746f88f32..4b69ac244779672a2d55439c48e64085b0cf8981 100644 (file)
@@ -1860,8 +1860,8 @@ void zebra_evpn_process_neigh_on_local_mac_change(zebra_evpn_t *zevpn,
  * Process all neighbors associated with a local MAC upon the MAC being
  * deleted.
  */
-static void zevpn_process_neigh_on_local_mac_del(zebra_evpn_t *zevpn,
-                                               zebra_mac_t *zmac)
+void zebra_evpn_process_neigh_on_local_mac_del(zebra_evpn_t *zevpn,
+                                              zebra_mac_t *zmac)
 {
        zebra_neigh_t *n = NULL;
        struct listnode *node = NULL;
@@ -7898,10 +7898,6 @@ int zebra_vxlan_local_mac_del(struct interface *ifp, struct interface *br_if,
                              struct ethaddr *macaddr, vlanid_t vid)
 {
        zebra_evpn_t *zevpn;
-       zebra_mac_t *mac;
-       char buf[ETHER_ADDR_STRLEN];
-       bool old_bgp_ready;
-       bool new_bgp_ready;
 
        /* We are interested in MACs only on ports or (port, VLAN) that
         * map to a VNI.
@@ -7916,76 +7912,7 @@ int zebra_vxlan_local_mac_del(struct interface *ifp, struct interface *br_if,
                return -1;
        }
 
-       /* If entry doesn't exist, nothing to do. */
-       mac = zebra_evpn_mac_lookup(zevpn, macaddr);
-       if (!mac)
-               return 0;
-
-       /* Is it a local entry? */
-       if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL))
-               return 0;
-
-       if (IS_ZEBRA_DEBUG_VXLAN)
-               zlog_debug("DEL MAC %s intf %s(%u) VID %u -> VNI %u seq %u flags 0x%x nbr count %u",
-                          prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name,
-                          ifp->ifindex, vid, zevpn->vni, mac->loc_seq,
-                          mac->flags, listcount(mac->neigh_list));
-
-       old_bgp_ready = zebra_evpn_mac_is_ready_for_bgp(mac->flags);
-       if (zebra_evpn_mac_is_static(mac)) {
-               /* this is a synced entry and can only be removed when the
-                * es-peers stop advertising it.
-                */
-               memset(&mac->fwd_info, 0, sizeof(mac->fwd_info));
-
-               if (IS_ZEBRA_DEBUG_EVPN_MH_MAC)
-                       zlog_debug("re-add sync-mac vni %u mac %s es %s seq %d f 0x%x",
-                                       zevpn->vni,
-                                       prefix_mac2str(macaddr,
-                                               buf, sizeof(buf)),
-                                       mac->es ? mac->es->esi_str : "-",
-                                       mac->loc_seq,
-                                       mac->flags);
-
-               /* inform-bgp about change in local-activity if any */
-               if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE)) {
-                       SET_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE);
-                       new_bgp_ready =
-                               zebra_evpn_mac_is_ready_for_bgp(mac->flags);
-                       zebra_evpn_mac_send_add_del_to_client(
-                               mac, old_bgp_ready, new_bgp_ready);
-               }
-
-               /* re-install the entry in the kernel */
-               zebra_evpn_sync_mac_dp_install(mac, false /* set_inactive */,
-                                              false /* force_clear_static */,
-                                              __func__);
-
-               return 0;
-       }
-
-       /* Update all the neigh entries associated with this mac */
-       zevpn_process_neigh_on_local_mac_del(zevpn, mac);
-
-       /* Remove MAC from BGP. */
-       zebra_evpn_mac_send_del_to_client(zevpn->vni, macaddr, mac->flags,
-                                         false /* force */);
-
-       zebra_evpn_es_mac_deref_entry(mac);
-
-       /*
-        * If there are no neigh associated with the mac delete the mac
-        * else mark it as AUTO for forward reference
-        */
-       if (!listcount(mac->neigh_list)) {
-               zebra_evpn_mac_del(zevpn, mac);
-       } else {
-               UNSET_FLAG(mac->flags, ZEBRA_MAC_ALL_LOCAL_FLAGS);
-               UNSET_FLAG(mac->flags, ZEBRA_MAC_STICKY);
-               SET_FLAG(mac->flags, ZEBRA_MAC_AUTO);
-       }
-
-       return 0;
+       return zebra_evpn_del_local_mac(zevpn, macaddr, ifp);
 }
 
 /*