From beafecfc2e183d8b4036894e345847ad1ab351a9 Mon Sep 17 00:00:00 2001 From: Vijayabhaskar Katamreddy Date: Thu, 19 May 2022 17:07:22 +0000 Subject: ip: reassembly - fixing stepping index in a better way Type: fix pool_is_free_index() check is performed only for the first element Signed-off-by: Vijayabhaskar Katamreddy Change-Id: Icadc715a9b54761ec69805a134a69a262137536d --- src/vnet/ip/reass/ip4_full_reass.c | 16 ++++++++-------- src/vppinfra/pool.h | 15 +++++---------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c index 1ac22615a60..becfc460450 100644 --- a/src/vnet/ip/reass/ip4_full_reass.c +++ b/src/vnet/ip/reass/ip4_full_reass.c @@ -1724,14 +1724,14 @@ ip4_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node, rt->last_id = end; } - pool_foreach_stepping_index ( - index, beg, end, rt->pool, ({ - reass = pool_elt_at_index (rt->pool, index); - if (now > reass->last_heard + rm->timeout) - { - vec_add1 (pool_indexes_to_free, index); - } - })); + pool_foreach_stepping_index (index, beg, end, rt->pool) + { + reass = pool_elt_at_index (rt->pool, index); + if (now > reass->last_heard + rm->timeout) + { + vec_add1 (pool_indexes_to_free, index); + } + } if (vec_len (pool_indexes_to_free)) vlib_node_increment_counter (vm, node->node_index, diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h index dd581efeeab..ef816096ff0 100644 --- a/src/vppinfra/pool.h +++ b/src/vppinfra/pool.h @@ -561,16 +561,11 @@ do { \ i = pool_get_next_index (v, i)) /* Iterate pool by index from s to e */ -#define pool_foreach_stepping_index(i, s, e, v, body) \ - for ((i) = (s); (i) < (e); (i) = pool_get_next_index (v, i)) \ - { \ - if (!pool_is_free_index ((v), (i))) \ - do \ - { \ - body; \ - } \ - while (0); \ - } +#define pool_foreach_stepping_index(i, s, e, v) \ + for ((i) = \ + (pool_is_free_index ((v), (s)) ? pool_get_next_index ((v), (s)) : \ + (s)); \ + (i) < (e); (i) = pool_get_next_index ((v), (i))) /** * @brief Remove all elements from a pool in a safe way -- cgit 1.2.3-korg