From: Nick Porter Date: Wed, 6 Aug 2025 14:53:13 +0000 (+0100) Subject: Split the restricted source port range per thread X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c31ae8786e1e563d8938070178ce1545f261783;p=thirdparty%2Ffreeradius-server.git Split the restricted source port range per thread --- diff --git a/src/modules/rlm_radius/bio.c b/src/modules/rlm_radius/bio.c index c9c6c4654e..29050b68a6 100644 --- a/src/modules/rlm_radius/bio.c +++ b/src/modules/rlm_radius/bio.c @@ -2634,6 +2634,15 @@ static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx) case RLM_RADIUS_MODE_XLAT_PROXY: fr_rb_expire_inline_talloc_init(&thread->bio.expires, home_server_t, expire, home_server_cmp, home_server_free, inst->home_server_lifetime); + /* + * Assign each thread a portion of the available source port range. + */ + if (thread->ctx.fd_config.src_port_start) { + uint16_t range = inst->fd_config.src_port_end - inst->fd_config.src_port_start + 1; + uint16_t block = range / main_config->max_workers; + thread->ctx.fd_config.src_port_start = inst->fd_config.src_port_start + (block * fr_schedule_worker_id()); + thread->ctx.fd_config.src_port_end = inst->fd_config.src_port_start + (block * (fr_schedule_worker_id() +1)) - 1; + } FALL_THROUGH; default: