From f23ef77ac13faaac6588817336756da863320ec7 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Thu, 7 Aug 2025 10:16:09 -0400 Subject: [PATCH] check corner cases we can't starve threads of ports :( --- src/modules/rlm_radius/rlm_radius.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/rlm_radius/rlm_radius.c b/src/modules/rlm_radius/rlm_radius.c index 6c92b7fc00..d687ad0671 100644 --- a/src/modules/rlm_radius/rlm_radius.c +++ b/src/modules/rlm_radius/rlm_radius.c @@ -713,15 +713,26 @@ check_others: return -1; } -#ifdef REUSE_CONN /* * If there is a limited source port range, then set the reuse port flag. This lets us * bind multiple sockets to the same port before we connect() them. */ if ((inst->fd_config.src_port_start > 0) && (inst->fd_config.src_port_end > 0)) { + if (inst->fd_config.src_port_end <= inst->fd_config.src_port_start) { + cf_log_perr(conf, "src_port_start must be smaller than src_port_end"); + return -1; + } + + if ((inst->fd_config.src_port_end - inst->fd_config.src_port_start) < (int) main_config->max_workers) { + cf_log_perr(conf, "src_port_start / end range is not enough for %u worker threads", + main_config->max_workers); + return -1; + } + +#ifdef REUSE_CONN inst->fd_config.reuse_port = 1; - } #endif + } } if (fr_bio_fd_check_config(&inst->fd_config) < 0) { -- 2.47.2