summaryrefslogtreecommitdiffstats
path: root/pbrd
diff options
context:
space:
mode:
authorWesley Coakley <wcoakley@nvidia.com>2021-05-15 08:41:28 +0200
committerWesley Coakley <wcoakley@nvidia.com>2021-05-16 23:33:27 +0200
commit64f37745da704e1ae1b9ac51ef39d2fa6f00baae (patch)
tree2b78be0f474a7f7a4ea18f6aecedcbfff3568bb9 /pbrd
parentpbrd: use sparse table for allocated NHG table IDs (diff)
downloadfrr-64f37745da704e1ae1b9ac51ef39d2fa6f00baae.tar.xz
frr-64f37745da704e1ae1b9ac51ef39d2fa6f00baae.zip
pbrd: nhg "add" edge case for last in table range
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>
Diffstat (limited to 'pbrd')
-rw-r--r--pbrd/pbr_nht.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c
index 824623034..e40ba22af 100644
--- a/pbrd/pbr_nht.c
+++ b/pbrd/pbr_nht.c
@@ -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;