From: Willy Tarreau Date: Mon, 18 Nov 2024 17:50:02 +0000 (+0100) Subject: MINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{frontend,backend} as sizes X-Git-Tag: v3.1-dev14~129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9f28b75848de07972ea9e6ee3b1ea3e07b95303;p=thirdparty%2Fhaproxy.git MINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{frontend,backend} as sizes Till now these values were 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 them so that units are supported. This requires to turn them to uint as well, which is OK. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 9f38da6151..22bc250ffa 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -4085,8 +4085,8 @@ tune.renice.startup See also: tune.renice.runtime -tune.rcvbuf.backend -tune.rcvbuf.frontend +tune.rcvbuf.backend +tune.rcvbuf.frontend For the kernel socket receive buffer size on non-connected sockets to this size. This can be used QUIC in listener mode and log-forward on the frontend. The default system buffers might sometimes be too small for sockets receiving @@ -4148,8 +4148,8 @@ tune.sched.low-latency { on | off } massive traffic, at the expense of a higher impact on this large traffic. For regular usage it is better to leave this off. The default value is off. -tune.sndbuf.backend -tune.sndbuf.frontend +tune.sndbuf.backend +tune.sndbuf.frontend For the kernel socket send buffer size on non-connected sockets to this size. This can be used for UNIX socket and UDP logging on the backend side, and for QUIC in listener mode on the frontend. The default system buffers might diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index 3cf3f09a75..40cfa4ddeb 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -174,10 +174,10 @@ struct global { uint client_rcvbuf; /* set client rcvbuf to this value if not null */ uint server_sndbuf; /* set server sndbuf to this value if not null */ uint server_rcvbuf; /* set server rcvbuf to this value if not null */ - int frontend_sndbuf; /* set frontend dgram sndbuf to this value if not null */ - int frontend_rcvbuf; /* set frontend dgram rcvbuf to this value if not null */ - int backend_sndbuf; /* set backend dgram sndbuf to this value if not null */ - int backend_rcvbuf; /* set backend dgram rcvbuf to this value if not null */ + uint frontend_sndbuf; /* set frontend dgram sndbuf to this value if not null */ + 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 */ 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 */ diff --git a/src/dgram.c b/src/dgram.c index c983c03b22..889253f622 100644 --- a/src/dgram.c +++ b/src/dgram.c @@ -37,8 +37,9 @@ static int dgram_parse_tune_bufs(char **args, int section_type, struct proxy *cu const struct proxy *defpx, const char *file, int line, char **err) { - int *valptr; - int val; + const char *res; + uint *valptr; + uint val; if (too_many_args(1, args, err, NULL)) return -1; @@ -56,7 +57,11 @@ static int dgram_parse_tune_bufs(char **args, int section_type, struct proxy *cu return 1; } - val = atoi(args[1]); + res = parse_size_err(args[1], &val); + if (res != NULL) { + memprintf(err, "parsing [%s:%d]: unexpected '%s' after size passed to '%s'", file, line, res, args[0]); + return -1; + } if (*(args[1]) == 0 || val <= 0) { memprintf(err, "parsing [%s:%d] : '%s' expects a strictly positive integer argument.\n", file, line, args[0]);