On 23 Sep 2025, at 13:36, Aleksandr Smirnov wrote:
> The upper range of IDs (base + n_ids) should not exceed max uint32.
> In that case id_pool_create() automatically reduces n_ids to max uint32 -
> base.
>
> Signed-off-by: Aleksandr Smirnov <[email protected]>
> ---
> lib/id-pool.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/id-pool.c b/lib/id-pool.c
> index 69910ad08..3e7188d27 100644
> --- a/lib/id-pool.c
> +++ b/lib/id-pool.c
> @@ -43,6 +43,9 @@ id_pool_create(uint32_t base, uint32_t n_ids)
> struct id_pool *pool;
>
> pool = xmalloc(sizeof *pool);
> +
> + n_ids = MIN(UINT32_MAX - base, n_ids);
> +
Maybe we should just ovs_assert() on this? In addition, I would move the
check/assert to id_pool_init().
> id_pool_init(pool, base, n_ids);
>
> return pool;
> --
> 2.49.0
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev