From: Maxime Henrion Date: Fri, 8 May 2026 14:30:30 +0000 (-0400) Subject: MINOR: cli: improve forward compatibility for show fd X-Git-Tag: v3.4-dev12~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f9b8574d276b64ea952b97f3da7d5bb36f14cee;p=thirdparty%2Fhaproxy.git MINOR: cli: improve forward compatibility for show fd The "/" and "/" wildcard forms previously produced no output. This isn't a bug since they are new, but a script written for future versions (where the slash form will gain per-thread-group semantics) would not work the same on 3.4. Make them produce output by dropping the redundant ctx->fd = -1 wildcard sentinel; also tighten tgid validation to reject values <= 0. --- diff --git a/src/cli.c b/src/cli.c index 8e96b4cd3..8210985e4 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1879,28 +1879,26 @@ static int cli_parse_show_fd(char **args, char *payload, struct appctx *appctx, /* We allow the forms "/" and "/" where the missing * value is considered a wildcard. So the first form means * "show me all the fds belonging to ", while the second - * one means "show the fd for each thread group". + * one means "show the fd for each thread group". Note + * that the tgid is parsed but ignored for now - this code + * will require changes once we split fd tables. */ - if (c == args[2]) + if (c == args[2]) { ctx->tgid = -1; - else + } else { ctx->tgid = atoi(args[2]); - if (ctx->tgid > MAX_TGROUPS) - return cli_err(appctx, "Invalid TGID.\n"); + if (ctx->tgid <= 0 || ctx->tgid > MAX_TGROUPS) + return cli_err(appctx, "Invalid TGID.\n"); + } c++; - if (!*c) - ctx->fd = -1; - else + if (*c) { ctx->fd = atoi(c); + ctx->show_one = 1; + } } else { ctx->fd = atoi(args[2]); - } - - /* This will need to change when we implement split fd tables. We - * completely ignore the tgid for now. - */ - if (ctx->fd != -1) ctx->show_one = 1; + } } return 0;