]> git.puffer.fish Git - mirror/frr.git/commitdiff
pbrd: nhg "add" edge case for last in table range 8675/head
authorWesley Coakley <wcoakley@nvidia.com>
Sat, 15 May 2021 06:41:28 +0000 (02:41 -0400)
committerWesley Coakley <wcoakley@nvidia.com>
Sun, 16 May 2021 21:33:27 +0000 (17:33 -0400)
When handling the addition of a nhg which would saturate the range of
tables PBR is configured to install into, handle this *before* a
possible call to pbr_nhgc_alloc during hash query

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
pbrd/pbr_nht.c

index 824623034d0e371695a44f33588f24730b11678b..e40ba22afffa2f16aab7c49d0ba4d53292f7f6eb 100644 (file)
@@ -238,16 +238,22 @@ void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,
        struct pbr_nexthop_cache pnhc_find = {};
        struct pbr_nexthop_cache *pnhc;
 
-       if (!pbr_nht_has_unallocated_table()) {
-               zlog_warn(
-                       "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
-                       __func__, nhgc->name);
-               return;
-       }
-
        /* find pnhgc by name */
        strlcpy(pnhgc_find.name, nhgc->name, sizeof(pnhgc_find.name));
-       pnhgc = hash_get(pbr_nhg_hash, &pnhgc_find, pbr_nhgc_alloc);
+       pnhgc = hash_lookup(pbr_nhg_hash, &pnhgc_find);
+
+       if (!pnhgc) {
+               /* Check if configured table range is exhausted */
+               if (!pbr_nht_has_unallocated_table()) {
+                       zlog_warn(
+                               "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+                               __func__, nhgc->name);
+                       return;
+               }
+
+               /* No nhgc but range not exhausted? Then alloc it */
+               pnhgc = hash_get(pbr_nhg_hash, &pnhgc_find, pbr_nhgc_alloc);
+       }
 
        /* create & insert new pnhc into pnhgc->nhh */
        pnhc_find.nexthop = *nhop;