diff options
| author | Wesley Coakley <wcoakley@nvidia.com> | 2021-05-14 22:53:56 -0400 |
|---|---|---|
| committer | Wesley Coakley <wcoakley@nvidia.com> | 2021-05-16 17:33:03 -0400 |
| commit | 389571aaf4666129c0f68a1d111b4db5d1f1650c (patch) | |
| tree | 6433404b758a7db69de7cae7b26170bd2c71fc93 /pbrd/pbr_nht.h | |
| parent | a63273a5b48bcae375af39928bafafadc6a31e0c (diff) | |
pbrd: use sparse table for allocated NHG table IDs
Represent installed ("allocated") NHG tables with a hash keyed by table
ID. Replaces a pre-allocated array of booleans that implemented this
functionality before.
+ PBR table range > 65535 is fixed (was OOB access before :))
+ Pre-compute next available ID to save time when only checking
if all tables are allocated
Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
Diffstat (limited to 'pbrd/pbr_nht.h')
| -rw-r--r-- | pbrd/pbr_nht.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pbrd/pbr_nht.h b/pbrd/pbr_nht.h index 6346795215..8d9edc6332 100644 --- a/pbrd/pbr_nht.h +++ b/pbrd/pbr_nht.h @@ -64,13 +64,26 @@ extern void pbr_nht_write_table_range(struct vty *vty); extern void pbr_nht_set_tableid_range(uint32_t low, uint32_t high); /* - * Get the next tableid to use for installation. - * - * peek - * If set to true, retrieves the next ID without marking it used. The next - * call will return the same ID. + * Find and reserve the next available table for installation; + * Sequential calls to this function will reserve sequential table numbers + * until the configured range is exhausted; calls made after exhaustion always + * return 0 + */ +extern uint32_t +pbr_nht_reserve_next_table_id(struct pbr_nexthop_group_cache *nhgc); +/* + * Get the next tableid to use for installation to kernel + */ +extern uint32_t pbr_nht_find_next_unallocated_table_id(void); +/* + * Calculate where the next table representing a nhg will go in kernel + */ +extern void pbr_nht_update_next_unallocated_table_id(void); +/* + * Indicate if there are free spots to install a table to kernel within the + * configured PBR table range */ -extern uint32_t pbr_nht_get_next_tableid(bool peek); +extern bool pbr_nht_has_unallocated_table(void); /* * Get the next rule number to use for installation */ |
