]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Use neigh_list instead of neigh_refcnt for zebra_mac and zebra_neigh binding
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Wed, 9 Aug 2017 21:28:39 +0000 (14:28 -0700)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 17 Aug 2017 01:56:15 +0000 (18:56 -0700)
Ticket: CM-17500
Review: CCR-6584
Testing: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
zebra/zebra_vxlan.c
zebra/zebra_vxlan_private.h

index 676cf8334e1a9e62ba132c45767891ab2272dc5e..80a2ea1309fcbadef9484987d4c419fca092ebec 100644 (file)
@@ -384,8 +384,8 @@ static void zvni_print_mac(zebra_mac_t *mac, void *ctxt)
        } else if (CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO)) {
                vty_out(vty, " Auto Mac ");
        }
-       vty_out(vty, " ARP ref: %u\n", mac->neigh_refcnt);
 
+       vty_out(vty, "\n");
        /* print all the associated neigh */
        vty_out(vty, " Neighbors:\n");
        if (!listcount(mac->neigh_list))
@@ -1355,9 +1355,6 @@ static int zvni_gw_macip_add(struct interface *ifp, zebra_vni_t *zvni,
        memcpy(&n->emac, macaddr, ETH_ALEN);
        n->ifindex = ifp->ifindex;
 
-       /* We have a neigh associated to mac increment the refcnt*/
-       mac->neigh_refcnt++;
-
        if (IS_ZEBRA_DEBUG_VXLAN)
                zlog_debug(
                        "%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s add to BGP",
@@ -1943,10 +1940,8 @@ static void zvni_install_mac_hash(struct hash_backet *backet, void *ctxt)
 static void zvni_deref_ip2mac(zebra_vni_t *zvni, zebra_mac_t *mac,
                              int uninstall)
 {
-       if (mac->neigh_refcnt)
-               mac->neigh_refcnt--;
-
-       if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO) || mac->neigh_refcnt > 0)
+       if (!CHECK_FLAG(mac->flags, ZEBRA_MAC_AUTO) ||
+           !list_isempty(mac->neigh_list))
                return;
 
        if (uninstall)
@@ -3132,7 +3127,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, int sock, u_short length,
                                zvni_process_neigh_on_remote_mac_del(zvrf, zvni,
                                                                     mac);
 
-                               if (!mac->neigh_refcnt) {
+                               if (list_isempty(mac->neigh_list)) {
                                        zvni_mac_uninstall(zvni, mac, 0);
                                        zvni_mac_del(zvni, mac);
                                } else
@@ -3323,16 +3318,16 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, int sock, u_short length,
                                        return -1;
                                }
 
-                               /* New neighbor referring to this MAC. */
-                               mac->neigh_refcnt++;
                        } else if (memcmp(&n->emac, &macaddr, sizeof(macaddr))
                                   != 0) {
-                               /* MAC change, update ref counts for old and new
-                                * MAC. */
+                               /* MAC change, update neigh list for old and new
+                                * mac */
                                old_mac = zvni_mac_lookup(zvni, &n->emac);
-                               if (old_mac)
+                               if (old_mac) {
+                                       listnode_delete(old_mac->neigh_list, n);
                                        zvni_deref_ip2mac(zvni, old_mac, 1);
-                               mac->neigh_refcnt++;
+                               }
+                               listnode_add_sort(mac->neigh_list, n);
                                memcpy(&n->emac, &macaddr, ETH_ALEN);
                        }
 
index 8539311eabd9babb430f28b41a216719efd1a779..fa7d0e94578f14e57e4ed171db6bcef987142fbc 100644 (file)
@@ -114,8 +114,6 @@ struct zebra_mac_t_ {
                struct in_addr r_vtep_ip;
        } fwd_info;
 
-       u_int32_t neigh_refcnt;
-
        /* List of neigh associated with this mac */
        struct list *neigh_list;
 };