new = XCALLOC(MTYPE_PBR_NHG, sizeof(*new));
strcpy(new->name, pnhgc->name);
- new->table_id = pbr_nht_get_next_tableid();
+ new->table_id = pbr_nht_get_next_tableid(false);
DEBUGD(&pbr_dbg_nht, "%s: NHT: %s assigned Table ID: %u",
__PRETTY_FUNCTION__, new->name, new->table_id);
pnhgc = pbr_nht_add_group(name);
+ if (!pnhgc)
+ return;
+
DEBUGD(&pbr_dbg_nht, "%s: Added nexthop-group %s", __PRETTY_FUNCTION__,
name);
struct pbr_nexthop_cache pnhc_find = {};
struct pbr_nexthop_cache *pnhc;
+ if (!pbr_nht_get_next_tableid(true)) {
+ zlog_warn(
+ "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+ __PRETTY_FUNCTION__, 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);
/* 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);
/* delete pnhc from pnhgc->nhh */
pnhc_find.nexthop = (struct nexthop *)nhop;
memset(&find, 0, sizeof(find));
pbr_nht_nexthop_make_name(pbrms->parent->name, PBR_NHC_NAMELEN,
pbrms->seqno, find.name);
+
+ if (!pbr_nht_get_next_tableid(true)) {
+ zlog_warn(
+ "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+ __PRETTY_FUNCTION__, find.name);
+ return;
+ }
+
if (!pbrms->internal_nhg_name)
pbrms->internal_nhg_name = XSTRDUP(MTYPE_TMP, find.name);
struct pbr_nexthop_group_cache *pnhgc;
struct pbr_nexthop_group_cache lookup;
+ if (!pbr_nht_get_next_tableid(true)) {
+ zlog_warn(
+ "%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'",
+ __PRETTY_FUNCTION__, name);
+ return NULL;
+ }
+
nhgc = nhgc_find(name);
if (!nhgc) {
- zlog_warn("%s: Could not find group %s to add",
- __PRETTY_FUNCTION__, name);
+ DEBUGD(&pbr_dbg_nht, "%s: Could not find nhgc with name: %s\n",
+ __PRETTY_FUNCTION__, name);
return NULL;
}
return !strcmp(nhgc1->name, nhgc2->name);
}
-
-uint32_t pbr_nht_get_next_tableid(void)
+uint32_t pbr_nht_get_next_tableid(bool peek)
{
uint32_t i;
bool found = false;
}
if (found) {
- nhg_tableid[i] = true;
+ nhg_tableid[i] = !peek;
return i;
} else
return 0;