summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44-ed
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/nat44-ed')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.c49
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.h17
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_api.c5
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_handoff.c30
4 files changed, 49 insertions, 52 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.c b/src/plugins/nat/nat44-ed/nat44_ed.c
index 007296e065f..c01a2454e0f 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed.c
@@ -176,13 +176,6 @@ static void nat44_ed_db_init (u32 translations, u32 translation_buckets);
static void nat44_ed_db_free ();
-static u32
-nat44_ed_get_worker_out2in_cb (vlib_buffer_t * b, ip4_header_t * ip,
- u32 rx_fib_index, u8 is_output);
-
-static u32 nat44_ed_get_worker_in2out_cb (vlib_buffer_t *b, ip4_header_t *ip,
- u32 rx_fib_index, u8 is_output);
-
u32 nat_calc_bihash_buckets (u32 n_elts);
u8 *
@@ -723,8 +716,8 @@ snat_add_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,
- sm->worker_in2out_cb (0, &ip, m->fib_index, 0));
+ vec_add1 (m->workers, nat44_ed_get_in2out_worker_index (
+ 0, &ip, m->fib_index, 0));
tsm = vec_elt_at_index (sm->per_thread_data, m->workers[0]);
}
else
@@ -971,7 +964,8 @@ nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port,
.src_address = locals[i].addr,
};
bitmap = clib_bitmap_set (
- bitmap, sm->worker_in2out_cb (0, &ip, m->fib_index, 0), 1);
+ bitmap,
+ nat44_ed_get_in2out_worker_index (0, &ip, m->fib_index, 0), 1);
}
}
@@ -1051,7 +1045,7 @@ nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port,
};
tsm = vec_elt_at_index (
sm->per_thread_data,
- sm->worker_in2out_cb (0, &ip, m->fib_index, 0));
+ nat44_ed_get_in2out_worker_index (0, &ip, m->fib_index, 0));
}
else
tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
@@ -1164,9 +1158,9 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port,
ip4_header_t ip = {
.src_address = local->addr,
};
- tsm =
- vec_elt_at_index (sm->per_thread_data,
- sm->worker_in2out_cb (0, &ip, m->fib_index, 0));
+ tsm = vec_elt_at_index (
+ sm->per_thread_data,
+ nat44_ed_get_in2out_worker_index (0, &ip, m->fib_index, 0));
}
else
tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
@@ -1197,7 +1191,8 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port,
ip4_header_t ip;
ip.src_address.as_u32 = local->addr.as_u32,
bitmap = clib_bitmap_set (
- bitmap, sm->worker_in2out_cb (0, &ip, local->fib_index, 0), 1);
+ bitmap,
+ nat44_ed_get_in2out_worker_index (0, &ip, local->fib_index, 0), 1);
}
}
@@ -2140,9 +2135,6 @@ nat44_plugin_enable (nat44_config_t c)
sm->outside_fib_index = fib_table_find_or_create_and_lock (
FIB_PROTOCOL_IP4, c.outside_vrf, sm->fib_src_hi);
- sm->worker_in2out_cb = nat44_ed_get_worker_in2out_cb;
- sm->worker_out2in_cb = nat44_ed_get_worker_out2in_cb;
-
nat44_ed_db_init (sm->max_translations_per_thread, sm->translation_buckets);
nat_affinity_enable ();
@@ -2423,8 +2415,8 @@ snat_static_mapping_match (vlib_main_t *vm, snat_main_t *sm,
.src_address = local->addr,
};
- if (sm->worker_in2out_cb (0, &ip, m->fib_index, 0) ==
- thread_index)
+ if (nat44_ed_get_in2out_worker_index (0, &ip, m->fib_index,
+ 0) == thread_index)
{
vec_add1 (tmp, i);
}
@@ -2499,9 +2491,9 @@ end:
return 0;
}
-static u32
-nat44_ed_get_worker_in2out_cb (vlib_buffer_t *b, ip4_header_t *ip,
- u32 rx_fib_index, u8 is_output)
+u32
+nat44_ed_get_in2out_worker_index (vlib_buffer_t *b, ip4_header_t *ip,
+ u32 rx_fib_index, u8 is_output)
{
snat_main_t *sm = &snat_main;
u32 next_worker_index = sm->first_worker_index;
@@ -2602,9 +2594,9 @@ out:
return next_worker_index;
}
-static u32
-nat44_ed_get_worker_out2in_cb (vlib_buffer_t * b, ip4_header_t * ip,
- u32 rx_fib_index, u8 is_output)
+u32
+nat44_ed_get_out2in_worker_index (vlib_buffer_t *b, ip4_header_t *ip,
+ u32 rx_fib_index, u8 is_output)
{
snat_main_t *sm = &snat_main;
clib_bihash_kv_8_8_t kv, value;
@@ -3162,8 +3154,9 @@ nat44_del_ed_session (snat_main_t * sm, ip4_address_t * addr, u16 port,
ip.dst_address.as_u32 = ip.src_address.as_u32 = addr->as_u32;
if (sm->num_workers > 1)
- tsm = vec_elt_at_index (sm->per_thread_data,
- sm->worker_in2out_cb (0, &ip, fib_index, 0));
+ tsm = vec_elt_at_index (
+ sm->per_thread_data,
+ nat44_ed_get_in2out_worker_index (0, &ip, fib_index, 0));
else
tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.h b/src/plugins/nat/nat44-ed/nat44_ed.h
index 66276285584..c9ae089210d 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.h
+++ b/src/plugins/nat/nat44-ed/nat44_ed.h
@@ -489,17 +489,12 @@ typedef struct
struct snat_main_s;
-/* Return worker thread index for given packet */
-typedef u32 (snat_get_worker_in2out_function_t) (vlib_buffer_t *b,
- ip4_header_t *ip,
- u32 rx_fib_index,
- u8 is_output);
-
-typedef u32 (snat_get_worker_out2in_function_t) (vlib_buffer_t * b,
- ip4_header_t * ip,
- u32 rx_fib_index,
- u8 is_output);
+u32 nat44_ed_get_in2out_worker_index (vlib_buffer_t *b, ip4_header_t *ip,
+ u32 rx_fib_index, u8 is_output);
+u32 nat44_ed_get_out2in_worker_index (vlib_buffer_t *b, ip4_header_t *ip,
+ u32 rx_fib_index, u8 is_output);
+/* Return worker thread index for given packet */
/* NAT address and port allocation function */
typedef int (nat_alloc_out_addr_and_port_function_t) (snat_address_t *
addresses,
@@ -517,8 +512,6 @@ typedef struct snat_main_s
u32 num_workers;
u32 first_worker_index;
u32 *workers;
- snat_get_worker_in2out_function_t *worker_in2out_cb;
- snat_get_worker_out2in_function_t *worker_out2in_cb;
u16 port_per_thread;
/* Per thread data */
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c
index 3089f68950f..22737ad7e56 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_api.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c
@@ -1529,8 +1529,9 @@ vl_api_nat44_user_session_dump_t_handler (vl_api_nat44_user_session_dump_t *
ip.src_address.as_u32 = ukey.addr.as_u32;
ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
if (sm->num_workers > 1)
- tsm = vec_elt_at_index (sm->per_thread_data,
- sm->worker_in2out_cb (0, &ip, ukey.fib_index, 0));
+ tsm = vec_elt_at_index (
+ sm->per_thread_data,
+ nat44_ed_get_in2out_worker_index (0, &ip, ukey.fib_index, 0));
else
tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_handoff.c b/src/plugins/nat/nat44-ed/nat44_ed_handoff.c
index e286df93a6e..597a08c77b4 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_handoff.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_handoff.c
@@ -157,17 +157,25 @@ nat44_worker_handoff_fn_inline (vlib_main_t * vm,
if (is_in2out)
{
- ti[0] = sm->worker_in2out_cb (b[0], ip0, rx_fib_index0, is_output);
- ti[1] = sm->worker_in2out_cb (b[1], ip1, rx_fib_index1, is_output);
- ti[2] = sm->worker_in2out_cb (b[2], ip2, rx_fib_index2, is_output);
- ti[3] = sm->worker_in2out_cb (b[3], ip3, rx_fib_index3, is_output);
+ ti[0] = nat44_ed_get_in2out_worker_index (b[0], ip0, rx_fib_index0,
+ is_output);
+ ti[1] = nat44_ed_get_in2out_worker_index (b[1], ip1, rx_fib_index1,
+ is_output);
+ ti[2] = nat44_ed_get_in2out_worker_index (b[2], ip2, rx_fib_index2,
+ is_output);
+ ti[3] = nat44_ed_get_in2out_worker_index (b[3], ip3, rx_fib_index3,
+ is_output);
}
else
{
- ti[0] = sm->worker_out2in_cb (b[0], ip0, rx_fib_index0, is_output);
- ti[1] = sm->worker_out2in_cb (b[1], ip1, rx_fib_index1, is_output);
- ti[2] = sm->worker_out2in_cb (b[2], ip2, rx_fib_index2, is_output);
- ti[3] = sm->worker_out2in_cb (b[3], ip3, rx_fib_index3, is_output);
+ ti[0] = nat44_ed_get_out2in_worker_index (b[0], ip0, rx_fib_index0,
+ is_output);
+ ti[1] = nat44_ed_get_out2in_worker_index (b[1], ip1, rx_fib_index1,
+ is_output);
+ ti[2] = nat44_ed_get_out2in_worker_index (b[2], ip2, rx_fib_index2,
+ is_output);
+ ti[3] = nat44_ed_get_out2in_worker_index (b[3], ip3, rx_fib_index3,
+ is_output);
}
if (ti[0] == thread_index)
@@ -218,11 +226,13 @@ nat44_worker_handoff_fn_inline (vlib_main_t * vm,
if (is_in2out)
{
- ti[0] = sm->worker_in2out_cb (b[0], ip0, rx_fib_index0, is_output);
+ ti[0] = nat44_ed_get_in2out_worker_index (b[0], ip0, rx_fib_index0,
+ is_output);
}
else
{
- ti[0] = sm->worker_out2in_cb (b[0], ip0, rx_fib_index0, is_output);
+ ti[0] = nat44_ed_get_out2in_worker_index (b[0], ip0, rx_fib_index0,
+ is_output);
}
if (ti[0] == thread_index)