]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse: parse tune.{rcvbuf,sndbuf}.{frontend,backend} as sizes
authorWilly Tarreau <w@1wt.eu>
Mon, 18 Nov 2024 17:50:02 +0000 (18:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 18 Nov 2024 17:50:02 +0000 (18:50 +0100)
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.

doc/configuration.txt
include/haproxy/global-t.h
src/dgram.c

index 9f38da615171420f4b2847211240104a8d3bc1c7..22bc250ffa3881065c512885625db450e2d6debd 100644 (file)
@@ -4085,8 +4085,8 @@ tune.renice.startup <number>
 
   See also: tune.renice.runtime
 
-tune.rcvbuf.backend <number>
-tune.rcvbuf.frontend <number>
+tune.rcvbuf.backend  <size>
+tune.rcvbuf.frontend <size>
   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 <number>
-tune.sndbuf.frontend <number>
+tune.sndbuf.backend  <size>
+tune.sndbuf.frontend <size>
   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
index 3cf3f09a7544af6de48677ee81ec0f5fb4ca1be9..40cfa4ddebc138bd446bad808d6a7aa34ef6c6eb 100644 (file)
@@ -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 */
index c983c03b2257a578ad94071af4f9896e3a61df02..889253f6227cab7ca8a0621c23b56691e8a2f632 100644 (file)
@@ -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]);