aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat
diff options
context:
space:
mode:
authorVladimir Ratnikov <vratnikov@netgate.com>2020-05-21 13:52:51 -0400
committerOle Trøan <otroan@employees.org>2020-05-22 08:02:12 +0000
commitf3b327673ccb1c0e70d30cfdd017b893b7b20b94 (patch)
tree64be6855afd88a513b1ac24c42d9af91ff91a795 /src/plugins/nat
parentb8749ff775ab2536134672fec57003f0eb488aa5 (diff)
nat: fix dslite session port allocation
Fix allocation of port per dslite session. After each session is created per protocol, when new one should be created with new port, instead it's trying to create with the same port and while(1) loop is executed forever and VPP does not response Type: fix Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com> Change-Id: Ic91b8b07253498ef9846ca60bcd4c4c76a5fac91
Diffstat (limited to 'src/plugins/nat')
-rw-r--r--src/plugins/nat/lib/alloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/nat/lib/alloc.c b/src/plugins/nat/lib/alloc.c
index ed4ba060b0b..3196718e06a 100644
--- a/src/plugins/nat/lib/alloc.c
+++ b/src/plugins/nat/lib/alloc.c
@@ -102,9 +102,9 @@ nat_add_del_ip4_pool_addrs (nat_ip4_pool_t * pool,
}
static_always_inline u16
-nat_random_port (u32 random_seed, u16 min, u16 max)
+nat_random_port (u32 * random_seed, u16 min, u16 max)
{
- return min + random_u32 (&random_seed) /
+ return min + random_u32 (random_seed) /
(random_u32_max () / (max - min + 1) + 1);
}
@@ -136,7 +136,7 @@ nat_alloc_ip4_addr_and_port_cb_default (nat_ip4_pool_t * pool,
{ \
portnum = (port_per_thread * \
nat_thread_index) + \
- nat_random_port(pool->random_seed, 1, port_per_thread) + 1024; \
+ nat_random_port(&pool->random_seed, 1, port_per_thread) + 1024; \
if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \
continue; \
clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \
@@ -171,7 +171,7 @@ nat_alloc_ip4_addr_and_port_cb_default (nat_ip4_pool_t * pool,
{ \
portnum = (port_per_thread * \
nat_thread_index) + \
- nat_random_port(pool->random_seed, 1, port_per_thread) + 1024; \
+ nat_random_port(&pool->random_seed, 1, port_per_thread) + 1024; \
if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \
continue; \
clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \