From a90a7d4d60a1c603c04449bc17efa7cec099fb82 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 18 Nov 2024 18:51:31 +0100 Subject: [PATCH] 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. --- doc/configuration.txt | 2 +- include/haproxy/global-t.h | 2 +- src/cfgparse-global.c | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 22bc250ff..09762df88 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 40cfa4dde..0d6831586 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 77f2e0f61..13842bb19 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; }