summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44-ei
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-03-15 19:52:57 +0100
committerKlement Sekera <ksekera@cisco.com>2021-03-15 22:07:43 +0100
commit3a5bd85476311d4ad2b0cbbca3f98d53f13a3afb (patch)
tree2a17c25f10fe3227b12460f3bf82743856d18d47 /src/plugins/nat/nat44-ei
parent7db75dd0d32d92674bbb7aa1b23341e8a349e05a (diff)
nat: get rid of worker selection callbacks
Make code easier to read and debug. Type: improvement Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: Ib52a4cdd3bcdcc475053aa32af3964c00859e1cd
Diffstat (limited to 'src/plugins/nat/nat44-ei')
-rw-r--r--src/plugins/nat/nat44-ei/nat44_ei.c10
-rw-r--r--src/plugins/nat/nat44-ei/nat44_ei.h12
-rw-r--r--src/plugins/nat/nat44-ei/nat44_ei_api.c5
-rw-r--r--src/plugins/nat/nat44-ei/nat44_ei_handoff.c30
4 files changed, 28 insertions, 29 deletions
diff --git a/src/plugins/nat/nat44-ei/nat44_ei.c b/src/plugins/nat/nat44-ei/nat44_ei.c
index 67757015b1d..d7e74bbc725 100644
--- a/src/plugins/nat/nat44-ei/nat44_ei.c
+++ b/src/plugins/nat/nat44-ei/nat44_ei.c
@@ -322,8 +322,6 @@ nat44_ei_init (vlib_main_t *vm)
nm->fq_out2in_index = ~0;
nm->fq_in2out_index = ~0;
nm->fq_in2out_output_index = ~0;
- nm->worker_in2out_cb = nat44_ei_get_in2out_worker_index;
- nm->worker_out2in_cb = nat44_ei_get_out2in_worker_index;
nm->log_level = NAT_LOG_ERROR;
@@ -1751,8 +1749,9 @@ nat44_ei_del_session (nat44_ei_main_t *nm, ip4_address_t *addr, u16 port,
ip.dst_address.as_u32 = ip.src_address.as_u32 = addr->as_u32;
if (nm->num_workers > 1)
- tnm = vec_elt_at_index (nm->per_thread_data,
- nm->worker_in2out_cb (&ip, fib_index, 0));
+ tnm =
+ vec_elt_at_index (nm->per_thread_data,
+ nat44_ei_get_in2out_worker_index (&ip, fib_index, 0));
else
tnm = vec_elt_at_index (nm->per_thread_data, nm->num_workers);
@@ -2036,7 +2035,8 @@ nat44_ei_add_del_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr,
ip4_header_t ip = {
.src_address = m->local_addr,
};
- vec_add1 (m->workers, nm->worker_in2out_cb (&ip, m->fib_index, 0));
+ vec_add1 (m->workers,
+ nat44_ei_get_in2out_worker_index (&ip, m->fib_index, 0));
tnm = vec_elt_at_index (nm->per_thread_data, m->workers[0]);
}
else
diff --git a/src/plugins/nat/nat44-ei/nat44_ei.h b/src/plugins/nat/nat44-ei/nat44_ei.h
index 7bc1b304fb3..29c92e96cbd 100644
--- a/src/plugins/nat/nat44-ei/nat44_ei.h
+++ b/src/plugins/nat/nat44-ei/nat44_ei.h
@@ -301,16 +301,6 @@ typedef struct
} nat44_ei_main_per_thread_data_t;
-/* Return worker thread index for given packet */
-typedef u32 (nat44_ei_get_worker_in2out_function_t) (ip4_header_t *ip,
- u32 rx_fib_index,
- u8 is_output);
-
-typedef u32 (nat44_ei_get_worker_out2in_function_t) (vlib_buffer_t *b,
- ip4_header_t *ip,
- u32 rx_fib_index,
- u8 is_output);
-
typedef struct
{
u32 cached_sw_if_index;
@@ -366,8 +356,6 @@ typedef struct nat44_ei_main_s
u32 num_workers;
u32 first_worker_index;
u32 *workers;
- nat44_ei_get_worker_in2out_function_t *worker_in2out_cb;
- nat44_ei_get_worker_out2in_function_t *worker_out2in_cb;
u16 port_per_thread;
/* Main lookup tables */
diff --git a/src/plugins/nat/nat44-ei/nat44_ei_api.c b/src/plugins/nat/nat44-ei/nat44_ei_api.c
index 74e077485cc..5ec07b0511f 100644
--- a/src/plugins/nat/nat44-ei/nat44_ei_api.c
+++ b/src/plugins/nat/nat44-ei/nat44_ei_api.c
@@ -1066,8 +1066,9 @@ vl_api_nat44_ei_user_session_dump_t_handler (
ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
key.key = ukey.as_u64;
if (nm->num_workers > 1)
- tnm = vec_elt_at_index (nm->per_thread_data,
- nm->worker_in2out_cb (&ip, ukey.fib_index, 0));
+ tnm = vec_elt_at_index (
+ nm->per_thread_data,
+ nat44_ei_get_in2out_worker_index (&ip, ukey.fib_index, 0));
else
tnm = vec_elt_at_index (nm->per_thread_data, nm->num_workers);
diff --git a/src/plugins/nat/nat44-ei/nat44_ei_handoff.c b/src/plugins/nat/nat44-ei/nat44_ei_handoff.c
index 6b8db37d414..6b172dceeb3 100644
--- a/src/plugins/nat/nat44-ei/nat44_ei_handoff.c
+++ b/src/plugins/nat/nat44-ei/nat44_ei_handoff.c
@@ -153,17 +153,25 @@ nat44_ei_worker_handoff_fn_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
if (is_in2out)
{
- ti[0] = nm->worker_in2out_cb (ip0, rx_fib_index0, is_output);
- ti[1] = nm->worker_in2out_cb (ip1, rx_fib_index1, is_output);
- ti[2] = nm->worker_in2out_cb (ip2, rx_fib_index2, is_output);
- ti[3] = nm->worker_in2out_cb (ip3, rx_fib_index3, is_output);
+ ti[0] =
+ nat44_ei_get_in2out_worker_index (ip0, rx_fib_index0, is_output);
+ ti[1] =
+ nat44_ei_get_in2out_worker_index (ip1, rx_fib_index1, is_output);
+ ti[2] =
+ nat44_ei_get_in2out_worker_index (ip2, rx_fib_index2, is_output);
+ ti[3] =
+ nat44_ei_get_in2out_worker_index (ip3, rx_fib_index3, is_output);
}
else
{
- ti[0] = nm->worker_out2in_cb (b[0], ip0, rx_fib_index0, is_output);
- ti[1] = nm->worker_out2in_cb (b[1], ip1, rx_fib_index1, is_output);
- ti[2] = nm->worker_out2in_cb (b[2], ip2, rx_fib_index2, is_output);
- ti[3] = nm->worker_out2in_cb (b[3], ip3, rx_fib_index3, is_output);
+ ti[0] = nat44_ei_get_out2in_worker_index (b[0], ip0, rx_fib_index0,
+ is_output);
+ ti[1] = nat44_ei_get_out2in_worker_index (b[1], ip1, rx_fib_index1,
+ is_output);
+ ti[2] = nat44_ei_get_out2in_worker_index (b[2], ip2, rx_fib_index2,
+ is_output);
+ ti[3] = nat44_ei_get_out2in_worker_index (b[3], ip3, rx_fib_index3,
+ is_output);
}
if (ti[0] == thread_index)
@@ -213,11 +221,13 @@ nat44_ei_worker_handoff_fn_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
if (is_in2out)
{
- ti[0] = nm->worker_in2out_cb (ip0, rx_fib_index0, is_output);
+ ti[0] =
+ nat44_ei_get_in2out_worker_index (ip0, rx_fib_index0, is_output);
}
else
{
- ti[0] = nm->worker_out2in_cb (b[0], ip0, rx_fib_index0, is_output);
+ ti[0] = nat44_ei_get_out2in_worker_index (b[0], ip0, rx_fib_index0,
+ is_output);
}
if (ti[0] == thread_index)