diff options
author | Elias Rudberg <elias.rudberg@bahnhof.net> | 2021-01-26 13:56:45 +0100 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-02-05 11:54:14 +0000 |
commit | e345ee5cb94cb28cac4ba62af67c2c540916a429 (patch) | |
tree | f5653c0f78888281710869907b049720853d8ede /src/plugins/nat/nat.c | |
parent | 839dcc0fb7313638d9b8f52a9db81350dddfe461 (diff) |
nat: configurable handoff frame queue size
Make number of worker handoff frame queue elements configurable as
a set nat frame-queue-nelts command. The default value is 64 which
is the same value that was previously hard-coded. The idea is that
allowing larger values can be useful in some cases, to avoid
congestion drops. Also add nat_set_fq_options API support and a
corresponding test case.
Type: improvement
Change-Id: I5c321eb2d7997f76fac2703d9c4a5b2516375db3
Signed-off-by: Elias Rudberg <elias.rudberg@bahnhof.net>
Diffstat (limited to 'src/plugins/nat/nat.c')
-rw-r--r-- | src/plugins/nat/nat.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c index 57d3b2bfdd1..11664aba0b6 100644 --- a/src/plugins/nat/nat.c +++ b/src/plugins/nat/nat.c @@ -1839,13 +1839,15 @@ snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del) feature_name = is_inside ? "nat44-in2out" : "nat44-out2in"; } + ASSERT (sm->frame_queue_nelts > 0); + if (sm->fq_in2out_index == ~0 && sm->num_workers > 1) - sm->fq_in2out_index = - vlib_frame_queue_main_init (sm->in2out_node_index, NAT_FQ_NELTS); + sm->fq_in2out_index = vlib_frame_queue_main_init (sm->in2out_node_index, + sm->frame_queue_nelts); if (sm->fq_out2in_index == ~0 && sm->num_workers > 1) - sm->fq_out2in_index = - vlib_frame_queue_main_init (sm->out2in_node_index, NAT_FQ_NELTS); + sm->fq_out2in_index = vlib_frame_queue_main_init (sm->out2in_node_index, + sm->frame_queue_nelts); if (sm->endpoint_dependent) update_per_vrf_sessions_vec (fib_index, is_del); @@ -2280,6 +2282,15 @@ snat_set_workers (uword * bitmap) return 0; } +int +snat_set_frame_queue_nelts (u32 frame_queue_nelts) +{ + fail_if_enabled (); + snat_main_t *sm = &snat_main; + sm->frame_queue_nelts = frame_queue_nelts; + return 0; +} + static void snat_update_outside_fib (ip4_main_t * im, uword opaque, u32 sw_if_index, u32 new_fib_index, @@ -2710,6 +2721,9 @@ nat44_ed_plugin_enable (nat44_config_t c) vlib_zero_simple_counter (&sm->total_sessions, 0); vlib_zero_simple_counter (&sm->user_limit_reached, 0); + if (!sm->frame_queue_nelts) + sm->frame_queue_nelts = NAT_FQ_NELTS_DEFAULT; + sm->enabled = 1; sm->rconfig = c; |