aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat.c
diff options
context:
space:
mode:
authorElias Rudberg <elias.rudberg@bahnhof.net>2020-07-02 21:21:34 +0200
committerOle Trøan <otroan@employees.org>2020-07-23 12:50:57 +0000
commitbf9a0c8097d47f052efea13a09d3a6c6fc68fb35 (patch)
tree968884118160c9fa831d7f501d861f9c8350fa56 /src/plugins/nat/nat.c
parent7c8644c368e19d8d34059ffa13e208f1534e23be (diff)
nat: fix port number selection
Change the port number selection for new NAT sessions so that it matches how the thread index is calculated from the port number for out2in packets. Before this change there was a problem when the largest port number in the range was used, that resulted in the wrong thread index being selected when out2in packets arrive for that session. Type: fix Signed-off-by: Elias Rudberg <elias.rudberg@bahnhof.net> Change-Id: I936c389eb0d5df6168e18e5e44754de1cdad6ad1 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat.c')
-rw-r--r--src/plugins/nat/nat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index c4c5dd87c86..fa62250cb1c 100644
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -2893,7 +2893,7 @@ nat_alloc_addr_and_port_default (snat_address_t * addresses,
{ \
portnum = (port_per_thread * \
snat_thread_index) + \
- snat_random_port(1, port_per_thread) + 1024; \
+ snat_random_port(0, port_per_thread - 1) + 1024; \
if (a->busy_##n##_port_refcounts[portnum]) \
continue; \
--a->busy_##n##_port_refcounts[portnum]; \
@@ -2930,7 +2930,7 @@ nat_alloc_addr_and_port_default (snat_address_t * addresses,
{ \
portnum = (port_per_thread * \
snat_thread_index) + \
- snat_random_port(1, port_per_thread) + 1024; \
+ snat_random_port(0, port_per_thread - 1) + 1024; \
if (a->busy_##n##_port_refcounts[portnum]) \
continue; \
++a->busy_##n##_port_refcounts[portnum]; \