summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorDamjan Marion <dmarion@me.com>2022-09-14 17:40:24 +0200
committerDave Wallace <dwallacelf@gmail.com>2022-10-12 16:55:52 +0000
commit42ed836fbdaa703f743098e93565ce0f2fa49977 (patch)
tree74cfb5e79a9088221fe88ecbac72dbdd14079eb6 /src/vnet/ip
parentdd298e804a25dbebc9e284b3b2d0dfd9bf674ad8 (diff)
ip: simpler and faster ip4_full_reass_drop_all
Type: improvement Change-Id: I4a75583ce718ba6466cd09ca8373fd43988ef62a Signed-off-by: Damjan Marion <dmarion@me.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/reass/ip4_full_reass.c60
1 files changed, 19 insertions, 41 deletions
diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c
index fca96aff0d6..b009a6c4338 100644
--- a/src/vnet/ip/reass/ip4_full_reass.c
+++ b/src/vnet/ip/reass/ip4_full_reass.c
@@ -427,8 +427,7 @@ ip4_full_reass_free (ip4_full_reass_main_t * rm,
* with local variables would cause either buffer leak or corruption */
always_inline void
ip4_full_reass_drop_all (vlib_main_t *vm, vlib_node_runtime_t *node,
- ip4_full_reass_t *reass, u32 *n_left_to_next,
- u32 **to_next)
+ ip4_full_reass_t *reass)
{
u32 range_bi = reass->first_bi;
vlib_buffer_t *range_b;
@@ -452,40 +451,23 @@ ip4_full_reass_drop_all (vlib_main_t *vm, vlib_node_runtime_t *node,
if (~0 != reass->error_next_index &&
reass->error_next_index < node->n_next_nodes)
{
- u32 next_index;
-
- next_index = reass->error_next_index;
- u32 bi = ~0;
+ u32 n_free = vec_len (to_free);
/* record number of packets sent to custom app */
vlib_node_increment_counter (vm, node->node_index,
- IP4_ERROR_REASS_TO_CUSTOM_APP,
- vec_len (to_free));
-
- while (vec_len (to_free) > 0)
- {
- vlib_get_next_frame (vm, node, next_index, *to_next,
- (*n_left_to_next));
+ IP4_ERROR_REASS_TO_CUSTOM_APP, n_free);
- while (vec_len (to_free) > 0 && (*n_left_to_next) > 0)
- {
- bi = vec_pop (to_free);
+ if (node->flags & VLIB_NODE_FLAG_TRACE)
+ for (u32 i = 0; i < n_free; i++)
+ {
+ vlib_buffer_t *b = vlib_get_buffer (vm, to_free[i]);
+ if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
+ ip4_full_reass_add_trace (vm, node, reass, to_free[i],
+ RANGE_DISCARD, 0, ~0);
+ }
- if (~0 != bi)
- {
- vlib_buffer_t *b = vlib_get_buffer (vm, bi);
- if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
- {
- ip4_full_reass_add_trace (vm, node, reass, bi,
- RANGE_DISCARD, 0, ~0);
- }
- *to_next[0] = bi;
- (*to_next) += 1;
- (*n_left_to_next) -= 1;
- }
- }
- vlib_put_next_frame (vm, node, next_index, (*n_left_to_next));
- }
+ vlib_buffer_enqueue_to_single_next (vm, node, to_free,
+ reass->error_next_index, n_free);
}
else
{
@@ -564,8 +546,7 @@ always_inline ip4_full_reass_t *
ip4_full_reass_find_or_create (vlib_main_t *vm, vlib_node_runtime_t *node,
ip4_full_reass_main_t *rm,
ip4_full_reass_per_thread_t *rt,
- ip4_full_reass_kv_t *kv, u8 *do_handoff,
- u32 *n_left_to_next, u32 **to_next)
+ ip4_full_reass_kv_t *kv, u8 *do_handoff)
{
ip4_full_reass_t *reass;
f64 now;
@@ -590,7 +571,7 @@ again:
{
vlib_node_increment_counter (vm, node->node_index,
IP4_ERROR_REASS_TIMEOUT, 1);
- ip4_full_reass_drop_all (vm, node, reass, n_left_to_next, to_next);
+ ip4_full_reass_drop_all (vm, node, reass);
ip4_full_reass_free (rm, rt, reass);
reass = NULL;
}
@@ -1257,8 +1238,8 @@ ip4_full_reass_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
};
u8 do_handoff = 0;
- ip4_full_reass_t *reass = ip4_full_reass_find_or_create (
- vm, node, rm, rt, &kv, &do_handoff, &n_left_to_next, &to_next);
+ ip4_full_reass_t *reass =
+ ip4_full_reass_find_or_create (vm, node, rm, rt, &kv, &do_handoff);
if (reass)
{
@@ -1316,8 +1297,7 @@ ip4_full_reass_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
{
vlib_node_increment_counter (vm, node->node_index, counter,
1);
- ip4_full_reass_drop_all (vm, node, reass, &n_left_to_next,
- &to_next);
+ ip4_full_reass_drop_all (vm, node, reass);
ip4_full_reass_free (rm, rt, reass);
goto next_packet;
}
@@ -1686,7 +1666,6 @@ ip4_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
uword thread_index = 0;
int index;
const uword nthreads = vlib_num_workers () + 1;
- u32 n_left_to_next, *to_next;
for (thread_index = 0; thread_index < nthreads; ++thread_index)
{
@@ -1732,8 +1711,7 @@ ip4_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
vec_foreach (i, pool_indexes_to_free)
{
ip4_full_reass_t *reass = pool_elt_at_index (rt->pool, i[0]);
- ip4_full_reass_drop_all (vm, node, reass, &n_left_to_next,
- &to_next);
+ ip4_full_reass_drop_all (vm, node, reass);
ip4_full_reass_free (rm, rt, reass);
}