]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Split the restricted source port range per thread
authorNick Porter <nick@portercomputing.co.uk>
Wed, 6 Aug 2025 14:53:13 +0000 (15:53 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 7 Aug 2025 11:31:53 +0000 (12:31 +0100)
src/modules/rlm_radius/bio.c

index c9c6c4654e64dadd0eca8b2cad6de3dee21f46e8..29050b68a68384057bc8d8e59ec73c1e7d8a6654 100644 (file)
@@ -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: