diff options
author | Nathan Skrzypczak <nathan.skrzypczak@gmail.com> | 2023-10-03 13:54:15 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-10-03 16:28:36 +0000 |
commit | e111bbd121b7c2ca4e2a002fd8ed4ffcea5222ff (patch) | |
tree | 4c188b2b7a124d4fb92da4609cbd85e897977070 /src/vnet/session/transport.c | |
parent | bc37878ecbad0a3a24801f1ad5af04a209b4c201 (diff) |
session: make port range configurable
Type: feature
This patch makes the port range used by the transport layer
configurable in the manner of sysctl's ip_local_port_range.
Change-Id: Ie17f776538311b29d1dca64643a3a0bd74cb90a6
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vnet/session/transport.c')
-rw-r--r-- | src/vnet/session/transport.c | 7 |
1 files changed, 6 insertions, 1 deletions
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, |