]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Limit pim's ecmp to what zebra tells us is the multipath
authorDonald Sharp <sharpd@nvidia.com>
Wed, 22 Jun 2022 12:12:04 +0000 (08:12 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 23 Jun 2022 17:29:19 +0000 (13:29 -0400)
Zebra can be setup to use a value that is less than MULTIPATH_NUM.
When pimd connects to zebra, zebra will inform pim about the MULTIPATH_NUM
used.  Let's use that value for figuring out our multipath value.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
pimd/pim_instance.h
pimd/pim_nht.c
pimd/pim_rpf.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
pimd/pimd.c

index b19e8208ba6d68abf1357318758f351ded18bb22..23b9df4aff13a75d9dc13f317ff714d9695439ed 100644 (file)
@@ -88,6 +88,7 @@ struct pim_router {
        uint32_t register_suppress_time;
        int packet_process;
        uint32_t register_probe_time;
+       uint16_t multipath;
 
        /*
         * What is the default vrf that we work in
index 22716c2a9201909968f15ec069071e9ffe06d46f..564d16a60b70ab3c77acd84662d346d97998861c 100644 (file)
@@ -304,15 +304,15 @@ bool pim_nht_bsr_rpf_check(struct pim_instance *pim, struct in_addr bsr_addr,
                 * "check cache or get immediate result." But until that can
                 * be worked in, here's a copy of the code below :(
                 */
-               struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
+               struct pim_zlookup_nexthop nexthop_tab[router->multipath];
                ifindex_t i;
                struct interface *ifp = NULL;
                int num_ifindex;
 
                memset(nexthop_tab, 0, sizeof(nexthop_tab));
-               num_ifindex = zclient_lookup_nexthop(pim, nexthop_tab,
-                                                    MULTIPATH_NUM, bsr_addr,
-                                                    PIM_NEXTHOP_LOOKUP_MAX);
+               num_ifindex = zclient_lookup_nexthop(
+                       pim, nexthop_tab, router->multipath, bsr_addr,
+                       PIM_NEXTHOP_LOOKUP_MAX);
 
                if (num_ifindex <= 0)
                        return false;
@@ -501,8 +501,8 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,
                                   struct prefix *src, struct prefix *grp,
                                   int neighbor_needed)
 {
-       struct pim_neighbor *nbrs[MULTIPATH_NUM], *nbr = NULL;
-       struct interface *ifps[MULTIPATH_NUM];
+       struct pim_neighbor *nbrs[router->multipath], *nbr = NULL;
+       struct interface *ifps[router->multipath];
        struct nexthop *nh_node = NULL;
        ifindex_t first_ifindex;
        struct interface *ifp = NULL;
@@ -888,11 +888,11 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,
                            struct prefix *grp, int neighbor_needed)
 {
        struct pim_nexthop_cache *pnc;
-       struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
-       struct pim_neighbor *nbrs[MULTIPATH_NUM], *nbr = NULL;
+       struct pim_zlookup_nexthop nexthop_tab[router->multipath];
+       struct pim_neighbor *nbrs[router->multipath], *nbr = NULL;
        struct pim_rpf rpf;
        int num_ifindex;
-       struct interface *ifps[MULTIPATH_NUM], *ifp;
+       struct interface *ifps[router->multipath], *ifp;
        int first_ifindex;
        int found = 0;
        uint8_t i = 0;
@@ -915,9 +915,10 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,
        }
 
        memset(nexthop_tab, 0,
-              sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM);
-       num_ifindex = zclient_lookup_nexthop(pim, nexthop_tab, MULTIPATH_NUM,
-                                            src_addr, PIM_NEXTHOP_LOOKUP_MAX);
+              sizeof(struct pim_zlookup_nexthop) * router->multipath);
+       num_ifindex =
+               zclient_lookup_nexthop(pim, nexthop_tab, router->multipath,
+                                      src_addr, PIM_NEXTHOP_LOOKUP_MAX);
        if (num_ifindex < 1) {
                if (PIM_DEBUG_PIM_NHT)
                        zlog_warn(
index c470bcd4d7ffd415a69639b780f75c46d4be0c22..bd4dd31a2c58a499cea56bdddba16c62ec8687b4 100644 (file)
@@ -54,7 +54,7 @@ void pim_rpf_set_refresh_time(struct pim_instance *pim)
 bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
                        pim_addr addr, int neighbor_needed)
 {
-       struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM];
+       struct pim_zlookup_nexthop nexthop_tab[router->multipath];
        struct pim_neighbor *nbr = NULL;
        int num_ifindex;
        struct interface *ifp = NULL;
@@ -92,9 +92,10 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
        }
 
        memset(nexthop_tab, 0,
-              sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM);
-       num_ifindex = zclient_lookup_nexthop(pim, nexthop_tab, MULTIPATH_NUM,
-                                            addr, PIM_NEXTHOP_LOOKUP_MAX);
+              sizeof(struct pim_zlookup_nexthop) * router->multipath);
+       num_ifindex =
+               zclient_lookup_nexthop(pim, nexthop_tab, router->multipath,
+                                      addr, PIM_NEXTHOP_LOOKUP_MAX);
        if (num_ifindex < 1) {
                zlog_warn(
                        "%s %s: could not find nexthop ifindex for address %pPAs",
index 4135ae040867d410216864080598b5cdc16a23da..7f217d9c2eb5465e9adfd380dded6f49fa172c50 100644 (file)
@@ -452,6 +452,7 @@ static void pim_zebra_connected(struct zclient *zclient)
 static void pim_zebra_capabilities(struct zclient_capabilities *cap)
 {
        router->mlag_role = cap->role;
+       router->multipath = cap->ecmp;
 }
 
 static zclient_handler *const pim_handlers[] = {
index a3978bd0d24586726b85fb59e9252b478181dc07..28777e49471babc73471994255d2210dedf7e756 100644 (file)
@@ -211,7 +211,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,
        metric = stream_getl(s);
        nexthop_num = stream_getc(s);
 
-       if (nexthop_num < 1) {
+       if (nexthop_num < 1 || nexthop_num > router->multipath) {
                if (PIM_DEBUG_PIM_NHT_DETAIL)
                        zlog_debug("%s: socket %d bad nexthop_num=%d", __func__,
                                   zlookup->sock, nexthop_num);
index 58e874fd11905e8e7e11e89a9a27bc5942189d09..a3be3f66e104e067c76b348a443210a0cba85a92 100644 (file)
@@ -100,6 +100,7 @@ void pim_router_init(void)
        router->debugs = 0;
        router->master = frr_init();
        router->t_periodic = PIM_DEFAULT_T_PERIODIC;
+       router->multipath = MULTIPATH_NUM;
 
        /*
          RFC 4601: 4.6.3.  Assert Metrics