diff --git a/doc/configuration.txt b/doc/configuration.txt index 5cfdb2ee3..9f38da615 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -4101,8 +4101,8 @@ tune.rcvbuf.frontend counter parts, as well as "tune.sndbuf.backend" and "tune.sndbuf.frontend" for the send setting. -tune.rcvbuf.client -tune.rcvbuf.server +tune.rcvbuf.client +tune.rcvbuf.server Forces the kernel socket receive buffer size on the client or the server side to the specified value in bytes. This value applies to all TCP/HTTP frontends and backends. It should normally never be set, and the default size (0) lets @@ -4164,8 +4164,8 @@ tune.sndbuf.frontend "tune.sndbuf.server" for their connected socket counter parts, as well as "tune.rcvbuf.backend" and "tune.rcvbuf.frontend" for the receive setting. -tune.sndbuf.client -tune.sndbuf.server +tune.sndbuf.client +tune.sndbuf.server Forces the kernel socket send buffer size on the client or the server side to the specified value in bytes. This value applies to all TCP/HTTP frontends and backends. It should normally never be set, and the default size (0) lets diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index 4e41860ef..3cf3f09a7 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -170,10 +170,10 @@ struct global { int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */ int reserved_bufs; /* how many buffers can only be allocated for response */ int buf_limit; /* if not null, how many total buffers may only be allocated */ - int client_sndbuf; /* set client sndbuf to this value if not null */ - int client_rcvbuf; /* set client rcvbuf to this value if not null */ - int server_sndbuf; /* set server sndbuf to this value if not null */ - int server_rcvbuf; /* set server rcvbuf to this value if not null */ + uint client_sndbuf; /* set client sndbuf to this value if not null */ + 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 */ diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 93ed45217..77f2e0f61 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1121,6 +1121,7 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, struct proxy *curpx, const struct proxy *defpx, const char *file, int line, char **err) { + const char *res; if (too_many_args(1, args, err, NULL)) return -1; @@ -1212,8 +1213,6 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, } else if (strcmp(args[0], "tune.idletimer") == 0) { unsigned int idle; - const char *res; - if (*(args[1]) == 0) { memprintf(err, "'%s' expects a timer value between 0 and 65535 ms.", args[0]); @@ -1253,7 +1252,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.client_rcvbuf = atol(args[1]); + res = parse_size_err(args[1], &global.tune.client_rcvbuf); + if (res != NULL) + goto size_err; return 0; } @@ -1266,7 +1267,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.server_rcvbuf = atol(args[1]); + res = parse_size_err(args[1], &global.tune.server_rcvbuf); + if (res != NULL) + goto size_err; return 0; } @@ -1279,7 +1282,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.client_sndbuf = atol(args[1]); + res = parse_size_err(args[1], &global.tune.client_sndbuf); + if (res != NULL) + goto size_err; return 0; } @@ -1292,7 +1297,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.server_sndbuf = atol(args[1]); + res = parse_size_err(args[1], &global.tune.server_sndbuf); + if (res != NULL) + goto size_err; return 0; } @@ -1366,6 +1373,11 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, } return 0; + + size_err: + memprintf(err, "unexpected '%s' after size passed to '%s'", res, args[0]); + return -1; + } static int cfg_parse_global_tune_forward_opts(char **args, int section_type,