aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/session/session.c6
-rw-r--r--src/vnet/session/session.h4
-rw-r--r--src/vnet/session/transport.c7
3 files changed, 16 insertions, 1 deletions
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 1f73eefd773..23c58ef2d89 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -2171,6 +2171,8 @@ session_main_init (vlib_main_t * vm)
smm->use_private_rx_mqs = 0;
smm->no_adaptive = 0;
smm->last_transport_proto_type = TRANSPORT_PROTO_HTTP;
+ smm->port_allocator_min_src_port = 1024;
+ smm->port_allocator_max_src_port = 65535;
return 0;
}
@@ -2268,6 +2270,10 @@ session_config_fn (vlib_main_t * vm, unformat_input_t * input)
else if (unformat (input, "local-endpoints-table-buckets %d",
&smm->local_endpoints_table_buckets))
;
+ else if (unformat (input, "min-src-port %d", &tmp))
+ smm->port_allocator_min_src_port = tmp;
+ else if (unformat (input, "max-src-port %d", &tmp))
+ smm->port_allocator_max_src_port = tmp;
else if (unformat (input, "enable"))
smm->session_enable_asap = 1;
else if (unformat (input, "use-app-socket-api"))
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 4de7bb252f0..ebaad5a93a7 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -267,6 +267,10 @@ typedef struct session_main_
u32 local_endpoints_table_memory;
u32 local_endpoints_table_buckets;
+ /** Transport source port allocation range */
+ u16 port_allocator_min_src_port;
+ u16 port_allocator_max_src_port;
+
/** Preallocate session config parameter */
u32 preallocated_sessions;
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index bfd85eb0e05..0012ba288bf 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -35,6 +35,8 @@ typedef struct transport_main_
local_endpoint_t *local_endpoints;
u32 *lcl_endpts_freelist;
u32 port_allocator_seed;
+ u16 port_allocator_min_src_port;
+ u16 port_allocator_max_src_port;
u8 lcl_endpts_cleanup_pending;
clib_spinlock_t local_endpoints_lock;
} transport_main_t;
@@ -597,8 +599,9 @@ int
transport_alloc_local_port (u8 proto, ip46_address_t *lcl_addr,
transport_endpoint_cfg_t *rmt)
{
- u16 min = 1024, max = 65535; /* XXX configurable ? */
transport_main_t *tm = &tp_main;
+ u16 min = tm->port_allocator_min_src_port;
+ u16 max = tm->port_allocator_max_src_port;
int tries, limit;
limit = max - min;
@@ -971,6 +974,8 @@ transport_init (void)
/* Initialize [port-allocator] random number seed */
tm->port_allocator_seed = (u32) clib_cpu_time_now ();
+ tm->port_allocator_min_src_port = smm->port_allocator_min_src_port;
+ tm->port_allocator_max_src_port = smm->port_allocator_max_src_port;
clib_bihash_init_24_8 (&tm->local_endpoints_table, "local endpoints table",
smm->local_endpoints_table_buckets,