summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2018-01-05 05:03:35 -0800
committerOle Trøan <otroan@employees.org>2018-01-08 09:20:24 +0000
commit43ad007a0ce57ed54864ece41714440cf838f356 (patch)
treec665187dad7d864a4d6d9de6ccc59066fbc09314 /src
parent37aa1ffae6e5cc05f6e0c4e9c3da758bb864c9be (diff)
NAT: fixed get_worker_out2in bug (VPP-1116)
Change-Id: I5e080d69f28661cc0b1846885d5001526b54fbd9 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/nat/nat.c8
-rw-r--r--src/plugins/nat/nat64.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index e9b2c2c07ba..6ef87537d0b 100644
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -1582,7 +1582,7 @@ int snat_set_workers (uword * bitmap)
clib_bitmap_foreach (i, bitmap,
({
vec_add1(sm->workers, i);
- sm->per_thread_data[i].snat_thread_index = j;
+ sm->per_thread_data[sm->first_worker_index + i].snat_thread_index = j;
j++;
}));
@@ -2726,6 +2726,7 @@ snat_get_worker_out2in_cb (ip4_header_t * ip0, u32 rx_fib_index0)
snat_session_t *s;
int i;
u32 proto;
+ u32 next_worker_index = 0;
/* first try static mappings without port */
if (PREDICT_FALSE (pool_elts (sm->static_mappings)))
@@ -2841,7 +2842,10 @@ snat_get_worker_out2in_cb (ip4_header_t * ip0, u32 rx_fib_index0)
}
/* worker by outside port */
- return (u32) ((clib_net_to_host_u16 (port) - 1024) / sm->port_per_thread);
+ next_worker_index = sm->first_worker_index;
+ next_worker_index +=
+ sm->workers[(clib_net_to_host_u16 (port) - 1024) / sm->port_per_thread];
+ return next_worker_index;
}
static clib_error_t *
diff --git a/src/plugins/nat/nat64.c b/src/plugins/nat/nat64.c
index e60d9ec0219..571e0717826 100644
--- a/src/plugins/nat/nat64.c
+++ b/src/plugins/nat/nat64.c
@@ -202,7 +202,7 @@ nat64_get_worker_out2in (ip4_header_t * ip)
/* worker by outside port (TCP/UDP) */
port = clib_net_to_host_u16 (port);
if (port > 1024)
- return (u32) ((port - 1024) / sm->port_per_thread);
+ return nm->sm->first_worker_index + ((port - 1024) / sm->port_per_thread);
return vlib_get_thread_index ();
}
@@ -497,13 +497,17 @@ nat64_alloc_out_addr_and_port (u32 fib_index, snat_protocol_t proto,
snat_main_t *sm = nm->sm;
snat_session_key_t k;
u32 ai;
+ u32 worker_index = 0;
int rv;
k.protocol = proto;
+ if (sm->num_workers > 1)
+ worker_index = thread_index - sm->first_worker_index;
+
rv =
sm->alloc_addr_and_port (nm->addr_pool, fib_index, thread_index, &k, &ai,
- sm->port_per_thread, thread_index);
+ sm->port_per_thread, worker_index);
if (!rv)
{