From: Willy Tarreau Date: Mon, 18 Nov 2024 17:51:31 +0000 (+0100) Subject: MINOR: cfgparse: parse tune.pipesize as a size X-Git-Tag: v3.1-dev14~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a90a7d4d60a1c603c04449bc17efa7cec099fb82;p=thirdparty%2Fhaproxy.git MINOR: cfgparse: parse tune.pipesize as a size Till now this value was parsed as raw integer using atol() and would silently ignore any trailing suffix, causing unexpected behaviors when set, e.g. to "512k". Let's make use of parse_size_err() on it so that units are supported. This requires to turn it to uint as well, which was verified to be OK. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 22bc250ffa..09762df884 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -3899,7 +3899,7 @@ tune.peers.max-updates-at-once Conversely low values may also incur higher CPU overhead, and take longer to complete. The default value is 200 and it is suggested not to change it. -tune.pipesize +tune.pipesize Sets the kernel pipe buffer size to this size (in bytes). By default, pipes are the default size for the system. But sometimes when using TCP splicing, it can improve performance to increase pipe sizes, especially if it is diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index 40cfa4ddeb..0d68315867 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -178,7 +178,7 @@ struct global { uint frontend_rcvbuf; /* set frontend dgram rcvbuf to this value if not null */ uint backend_sndbuf; /* set backend dgram sndbuf to this value if not null */ uint backend_rcvbuf; /* set backend dgram rcvbuf to this value if not null */ - int pipesize; /* pipe size in bytes, system defaults if zero */ + uint pipesize; /* pipe size in bytes, system defaults if zero */ int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */ int requri_len; /* max len of request URI, use REQURI_LEN if zero */ int cookie_len; /* max length of cookie captures */ diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 77f2e0f613..13842bb199 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1308,7 +1308,9 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, memprintf(err, "'%s' expects an integer argument.", args[0]); return -1; } - global.tune.pipesize = atol(args[1]); + res = parse_size_err(args[1], &global.tune.pipesize); + if (res != NULL) + goto size_err; return 0; }