]> git.puffer.fish Git - matthieu/frr.git/commitdiff
sharp: add check for num_nh > multipath
authorStephen Worley <sworley@cumulusnetworks.com>
Fri, 11 Sep 2020 21:59:30 +0000 (17:59 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Mon, 28 Sep 2020 16:41:00 +0000 (12:41 -0400)
Add a check for installing nexthop_group greater than multipath
number. Truncate if we hit it and log a warning to the user.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
sharpd/sharp_zebra.c

index 03def0d9bae6aa91ffe58e65af8ffbe2da4cd878..edbc7460e0956960f43d0a9563e2804204365592 100644 (file)
@@ -365,6 +365,13 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg)
        struct nexthop *nh;
 
        for (ALL_NEXTHOPS_PTR(nhg, nh)) {
+               if (nexthop_num >= MULTIPATH_NUM) {
+                       zlog_warn(
+                               "%s: number of nexthops greater than max multipath size, truncating",
+                               __func__);
+                       break;
+               }
+
                api_nh = &nh_array[nexthop_num];
 
                zapi_nexthop_from_nexthop(api_nh, nh);