]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Remove afi field in nexthop hash entry
authorStephen Worley <sworley@cumulusnetworks.com>
Mon, 25 Feb 2019 22:59:28 +0000 (17:59 -0500)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:36 +0000 (11:13 -0400)
I do not believe we should be hashing based on AFI
in for our upper level nexthop group entries. These
should be ambiguous with regards to  address families since
an ipv4 or ipv6 address can have the same interface
nexthop. This can be seen in NEXTHOP_TYPE_IFINDEX.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zebra_nhg.c
zebra/zebra_nhg.h
zebra/zebra_rib.c
zebra/zebra_vty.c

index 1839133310ffdf60d447466571945db09aaa9a1f..172212c65268e89e7d35f94f4991f333f0defc1a 100644 (file)
@@ -45,7 +45,6 @@ static void *zebra_nhg_alloc(void *arg)
        nhe = XMALLOC(MTYPE_TMP, sizeof(struct nhg_hash_entry));
 
        nhe->vrf_id = copy->vrf_id;
-       nhe->afi = copy->afi;
        nhe->refcnt = 0;
        nhe->dplane_ref = zebra_router_get_next_sequence();
        nhe->nhg.nexthop = NULL;
@@ -68,6 +67,7 @@ static uint32_t zebra_nhg_hash_key_nexthop_group(struct nexthop_group *nhg)
         * resolved nexthops
         */
        for (nh = nhg->nexthop; nh; nh = nh->next) {
+               key = jhash_1word(nh->type, key);
                key = jhash_2words(nh->vrf_id, nh->nh_label_type, key);
                /* gate and blackhole are together in a union */
                key = jhash(&nh->gate, sizeof(nh->gate), key);
@@ -97,7 +97,7 @@ uint32_t zebra_nhg_hash_key(const void *arg)
        const struct nhg_hash_entry *nhe = arg;
        int key = 0x5a351234;
 
-       key = jhash_2words(nhe->vrf_id, nhe->afi, key);
+       key = jhash_1word(nhe->vrf_id, key);
 
        return jhash_1word(zebra_nhg_hash_key_nexthop_group(&nhe->nhg), key);
 }
@@ -127,9 +127,6 @@ bool zebra_nhg_hash_equal(const void *arg1, const void *arg2)
        if (nhe1->vrf_id != nhe2->vrf_id)
                return false;
 
-       if (nhe1->afi != nhe2->afi)
-               return false;
-
        /*
         * Again we are not interested in looking at any recursively
         * resolved nexthops.  Top level only
@@ -183,25 +180,22 @@ void zebra_nhg_find_id(uint32_t id, struct nexthop_group *nhg)
        zebra_nhg_lookup_get(zrouter.nhgs_id, &lookup);
 }
 
-void zebra_nhg_find(afi_t afi, struct nexthop_group *nhg,
-                   struct route_entry *re)
+void zebra_nhg_find(struct nexthop_group *nhg, struct route_entry *re)
 {
        struct nhg_hash_entry lookup;
 
        memset(&lookup, 0, sizeof(lookup));
        lookup.vrf_id = re->vrf_id;
-       lookup.afi = afi;
        lookup.nhg = *nhg;
 
        re->nhe = zebra_nhg_lookup_get(zrouter.nhgs, &lookup);
 }
 
-void zebra_nhg_release(afi_t afi, struct route_entry *re)
+void zebra_nhg_release(struct route_entry *re)
 {
        struct nhg_hash_entry lookup, *nhe;
 
        lookup.vrf_id = re->vrf_id;
-       lookup.afi = afi;
        lookup.nhg = *re->ng;
 
        nhe = hash_lookup(zrouter.nhgs, &lookup);
index e93b579560c42411569acf0c07160b0a921d0067..227e87256d3491bc79aa34f4f8a5028c8be1fcbc 100644 (file)
 #include "zebra/rib.h"
 #include "lib/nexthop_group.h"
 
-extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
-
 struct nhg_hash_entry {
        uint32_t id;
-       afi_t afi;
        vrf_id_t vrf_id;
 
        struct nexthop_group nhg;
@@ -63,8 +60,9 @@ extern uint32_t zebra_nhg_id_key(const void *arg);
 extern bool zebra_nhg_hash_equal(const void *arg1, const void *arg2);
 extern bool zebra_nhg_id_equal(const void *arg1, const void *arg2);
 
-extern void zebra_nhg_find(afi_t afi, struct nexthop_group *nhg,
-                          struct route_entry *re);
+extern void zebra_nhg_find(struct nexthop_group *nhg, struct route_entry *re);
 extern void zebra_nhg_find_id(uint32_t id, struct nexthop_group *nhg);
-void zebra_nhg_release(afi_t afi, struct route_entry *re);
+void zebra_nhg_release(struct route_entry *re);
+
+extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
 #endif
index d3c6f5ba113c5625a803f732aaeb35ed7f942a6a..c8684c1a93188538e896edfcc1fce28659ebc0cd 100644 (file)
@@ -2411,8 +2411,7 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)
        if (dest->selected_fib == re)
                dest->selected_fib = NULL;
 
-       info = srcdest_rnode_table_info(rn);
-       zebra_nhg_release(info->afi, re);
+       zebra_nhg_release(re);
 
        nexthops_free(re->ng->nexthop);
        nexthop_group_delete(&re->ng);
@@ -2659,7 +2658,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
        if (src_p)
                apply_mask_ipv6(src_p);
 
-       zebra_nhg_find(afi, re->ng, re);
+       zebra_nhg_find(re->ng, re);
        /* Set default distance by route type. */
        if (re->distance == 0)
                re->distance = route_distance(re->type);
index 32375e0a009102b18e2f714ea866ba2403b85bff..b0b888381c78434b3db9ae428e2c696140aa1ab9 100644 (file)
@@ -1103,7 +1103,7 @@ DEFUN (ip_nht_default_route,
 }
 
 static void show_nexthop_group_cmd_helper(struct vty *vty,
-                                         struct zebra_vrf *zvrf, afi_t afi)
+                                         struct zebra_vrf *zvrf)
 {
        struct list *list = hash_to_list(zrouter.nhgs);
        struct nhg_hash_entry *nhe;
@@ -1112,15 +1112,12 @@ static void show_nexthop_group_cmd_helper(struct vty *vty,
        for (ALL_LIST_ELEMENTS_RO(list, node, nhe)) {
                struct nexthop *nhop;
 
-               if (nhe->afi != afi)
-                       continue;
-
                if (nhe->vrf_id != zvrf->vrf->vrf_id)
                        continue;
 
                vty_out(vty,
-                       "Group: %u RefCnt: %u afi: %d Valid: %d Installed: %d\n",
-                       nhe->dplane_ref, nhe->refcnt, nhe->afi,
+                       "Group: %u ID: %u RefCnt: %d Valid: %d Installed: %d\n",
+                       nhe->dplane_ref, nhe->id, nhe->refcnt,
                        nhe->flags & NEXTHOP_GROUP_VALID,
                        nhe->flags & NEXTHOP_GROUP_INSTALLED);
 
@@ -1135,14 +1132,11 @@ static void show_nexthop_group_cmd_helper(struct vty *vty,
 
 DEFPY (show_nexthop_group,
        show_nexthop_group_cmd,
-       "show nexthop-group <ipv4$v4|ipv6$v6> [vrf <NAME$vrf_name|all$vrf_all>]",
+       "show nexthop-group [vrf <NAME$vrf_name|all$vrf_all>]",
        SHOW_STR
-       IP_STR
-       IP6_STR
        "Show Nexthop Groups\n"
        VRF_FULL_CMD_HELP_STR)
 {
-       afi_t afi = v4 ? AFI_IP : AFI_IP6;
        struct zebra_vrf *zvrf;
 
        if (vrf_all) {
@@ -1156,7 +1150,7 @@ DEFPY (show_nexthop_group,
                                continue;
 
                        vty_out(vty, "VRF: %s\n", vrf->name);
-                       show_nexthop_group_cmd_helper(vty, zvrf, afi);
+                       show_nexthop_group_cmd_helper(vty, zvrf);
                }
 
                return CMD_SUCCESS;
@@ -1172,7 +1166,7 @@ DEFPY (show_nexthop_group,
                return CMD_SUCCESS;
        }
 
-       show_nexthop_group_cmd_helper(vty, zvrf, afi);
+       show_nexthop_group_cmd_helper(vty, zvrf);
 
        return CMD_SUCCESS;
 }