]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: extract neighbor processing from process_remote_macip_del
authorPat Ruddy <pat@voltanet.io>
Fri, 24 Apr 2020 13:50:23 +0000 (14:50 +0100)
committerPat Ruddy <pat@voltanet.io>
Wed, 12 Aug 2020 11:39:34 +0000 (12:39 +0100)
extract the neighbor uninstall  part of process_remote_macip_add
into a new function zebra_evpn_neigh_remote_uninstall in
zebra_evpn_neigh.c.

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

index d00115c9b0a4ad472aa3e2f02d0b4a6bdc856925..fbf1c6f0c052f9a25a532fd7ca3af192a142d132 100644 (file)
@@ -574,9 +574,10 @@ bool zebra_evpn_neigh_is_bgp_seq_ok(zebra_evpn_t *zevpn, zebra_neigh_t *n,
 /*
  * Add neighbor entry.
  */
-zebra_neigh_t *zebra_evpn_neigh_add(zebra_evpn_t *zevpn, struct ipaddr *ip,
-                                   struct ethaddr *mac, zebra_mac_t *zmac,
-                                   uint32_t n_flags)
+static zebra_neigh_t *zebra_evpn_neigh_add(zebra_evpn_t *zevpn,
+                                          struct ipaddr *ip,
+                                          struct ethaddr *mac,
+                                          zebra_mac_t *zmac, uint32_t n_flags)
 {
        zebra_neigh_t tmp_n;
        zebra_neigh_t *n = NULL;
@@ -853,7 +854,7 @@ zebra_evpn_proc_sync_neigh_update(zebra_evpn_t *zevpn, zebra_neigh_t *n,
 /*
  * Uninstall remote neighbor from the kernel.
  */
-int zebra_evpn_neigh_uninstall(zebra_evpn_t *zevpn, zebra_neigh_t *n)
+static int zebra_evpn_neigh_uninstall(zebra_evpn_t *zevpn, zebra_neigh_t *n)
 {
        struct interface *vlan_if;
 
@@ -2348,3 +2349,41 @@ int zebra_evpn_neigh_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
 
        return 0;
 }
+
+void zebra_evpn_neigh_remote_uninstall(zebra_evpn_t *zevpn,
+                                      struct zebra_vrf *zvrf, zebra_neigh_t *n,
+                                      zebra_mac_t *mac, struct ipaddr *ipaddr)
+{
+       char buf1[INET6_ADDRSTRLEN];
+
+       if (zvrf->dad_freeze && CHECK_FLAG(n->flags, ZEBRA_NEIGH_DUPLICATE)
+           && CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)
+           && (memcmp(n->emac.octet, mac->macaddr.octet, ETH_ALEN) == 0)) {
+               struct interface *vlan_if;
+
+               vlan_if = zevpn_map_to_svi(zevpn);
+               if (IS_ZEBRA_DEBUG_VXLAN)
+                       zlog_debug(
+                               "%s: IP %s (flags 0x%x intf %s) is remote and duplicate, read kernel for local entry",
+                               __func__,
+                               ipaddr2str(ipaddr, buf1, sizeof(buf1)),
+                               n->flags, vlan_if ? vlan_if->name : "Unknown");
+               if (vlan_if)
+                       neigh_read_specific_ip(ipaddr, vlan_if);
+       }
+
+       /* When the MAC changes for an IP, it is possible the
+        * client may update the new MAC before trying to delete the
+        * "old" neighbor (as these are two different MACIP routes).
+        * Do the delete only if the MAC matches.
+        */
+       if (!memcmp(n->emac.octet, mac->macaddr.octet, ETH_ALEN)) {
+               if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) {
+                       zebra_evpn_sync_neigh_del(n);
+               } else if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) {
+                       zebra_evpn_neigh_uninstall(zevpn, n);
+                       zebra_evpn_neigh_del(zevpn, n);
+                       zebra_evpn_deref_ip2mac(zevpn, mac);
+               }
+       }
+}
index 3438afb336be711d4294520851e64e3573c66e55..b201742dcedbde8631474c713f842b15c9077880 100644 (file)
@@ -281,11 +281,10 @@ void process_neigh_remote_macip_add(zebra_evpn_t *zevpn, struct zebra_vrf *zvrf,
                                    uint32_t seq);
 int zebra_evpn_neigh_gw_macip_add(struct interface *ifp, zebra_evpn_t *zevpn,
                                  struct ipaddr *ip, zebra_mac_t *mac);
+void zebra_evpn_neigh_remote_uninstall(zebra_evpn_t *zevpn,
+                                      struct zebra_vrf *zvrf, zebra_neigh_t *n,
+                                      zebra_mac_t *mac, struct ipaddr *ipaddr);
 
-zebra_neigh_t *zebra_evpn_neigh_add(zebra_evpn_t *zevpn, struct ipaddr *ip,
-                                   struct ethaddr *mac, zebra_mac_t *zmac,
-                                   uint32_t n_flags);
-int zebra_evpn_neigh_uninstall(zebra_evpn_t *zevpn, zebra_neigh_t *n);
 void zebra_evpn_neigh_send_add_del_to_client(zebra_neigh_t *n,
                                             bool old_bgp_ready,
                                             bool new_bgp_ready);
index 7e1791e4d7f5ef06e2556bf2e44dd59a8b9ee2af..0e37b3a43f464a9a7f2cbaea35bb27a291d42b0b 100644 (file)
@@ -3432,41 +3432,9 @@ static void process_remote_macip_del(vni_t vni,
        }
 
        /* Uninstall remote neighbor or MAC. */
-       if (n) {
-               if (zvrf->dad_freeze &&
-                   CHECK_FLAG(n->flags, ZEBRA_NEIGH_DUPLICATE) &&
-                   CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE) &&
-                   (memcmp(n->emac.octet, macaddr->octet, ETH_ALEN) == 0)) {
-                       struct interface *vlan_if;
-
-                       vlan_if = zvni_map_to_svi(vxl->access_vlan,
-                                                 zif->brslave_info.br_if);
-                       if (IS_ZEBRA_DEBUG_VXLAN)
-                               zlog_debug(
-                                       "%s: IP %s (flags 0x%x intf %s) is remote and duplicate, read kernel for local entry",
-                                       __func__,
-                                       ipaddr2str(ipaddr, buf1, sizeof(buf1)),
-                                       n->flags,
-                                       vlan_if ? vlan_if->name : "Unknown");
-                       if (vlan_if)
-                               neigh_read_specific_ip(ipaddr, vlan_if);
-               }
-
-               /* When the MAC changes for an IP, it is possible the
-                * client may update the new MAC before trying to delete the
-                * "old" neighbor (as these are two different MACIP routes).
-                * Do the delete only if the MAC matches.
-                */
-               if (!memcmp(n->emac.octet, macaddr->octet, ETH_ALEN)) {
-                       if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) {
-                               zebra_evpn_sync_neigh_del(n);
-                       } else if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) {
-                               zebra_evpn_neigh_uninstall(zevpn, n);
-                               zebra_evpn_neigh_del(zevpn, n);
-                               zebra_evpn_deref_ip2mac(zevpn, mac);
-                       }
-               }
-       } else {
+       if (n)
+               zebra_evpn_neigh_remote_uninstall(zevpn, zvrf, n, mac, ipaddr);
+       else {
                /* DAD: when MAC is freeze state as remote learn event,
                 * remote mac-ip delete event is received will result in freeze
                 * entry removal, first fetch kernel for the same entry present