From: Christopher Faulet Date: Mon, 20 Feb 2023 13:06:52 +0000 (+0100) Subject: BUG/MINOR: haproxy: Fix option to disable the fast-forward X-Git-Tag: v2.8-dev5~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f7c82bfdf95ad40ce019d5b80e290a4f864caa9;p=thirdparty%2Fhaproxy.git BUG/MINOR: haproxy: Fix option to disable the fast-forward The option was renamed to only permit to disable the fast-forward. First there is no reason to enable it because it is the default behavior. Then it introduced a bug because there is no way to be sure the command line has precedence over the configuration this way. So, the option is now named "tune.disable-fast-forward" and does not support any argument. And of course, the commande line option "-dF" has now precedence over the configuration. No backport needed. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 3b1e29a25c..b13b97ced8 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -1123,7 +1123,7 @@ The following keywords are supported in the "global" section : - tune.buffers.reserve - tune.bufsize - tune.comp.maxlevel - - tune.fast-forward + - tune.disable-fast-forward - tune.fd.edge-triggered - tune.h2.header-table-size - tune.h2.initial-window-size @@ -2832,23 +2832,22 @@ tune.comp.maxlevel Each session using compression initializes the compression algorithm with this value. The default value is 1. +tune.disable-fast-forward [ EXPERIMENTAL ] + Disables the data fast-forwarding. It is a mechanism to optimize the data + forwarding by passing data directly from a side to the other one without + waking the stream up. Thanks to this directive, it is possible to disable + this optimization. Note it also disable any kernel tcp splicing. This command + is not meant for regular use, it will generally only be suggested by + developers along complex debugging sessions. For this reason it is internally + marked as experimental, meaning that "expose-experimental-directives" must + appear on a line before this directive. + tune.fail-alloc If compiled with DEBUG_FAIL_ALLOC or started with "-dMfail", gives the percentage of chances an allocation attempt fails. Must be between 0 (no failure) and 100 (no success). This is useful to debug and make sure memory failures are handled gracefully. -tune.fast-forward { on | off } [ EXPERIMENTAL ] - - Enabled ('on') or disables ('off') the data fast-forwarding. It is a - mechanism to optimize the data forwarding by passing data directly from a - side to the other one without waking the stream up. Thanks to this directive, - it is possible to disable this optimization. Note it also disable any kernel - tcp splicing. This command is not meant for regular use, it will generally - only be suggested by developers along complex debugging sessions. For this - reason it is internally marked as experimental, meaning that - "expose-experimental-directives" must appear on a line before this directive. - tune.fd.edge-triggered { on | off } [ EXPERIMENTAL ] Enables ('on') or disables ('off') the edge-triggered polling mode for FDs that support it. This is currently only support with epoll. It may noticeably diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index c0ccc812e0..b7b00bab03 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -80,7 +80,7 @@ #define GTUNE_QUICK_EXIT (1<<23) #define GTUNE_QUIC_SOCK_PER_CONN (1<<24) #define GTUNE_NO_QUIC (1<<25) -#define GTUNE_NO_FAST_FWD (1<<26) +#define GTUNE_USE_FAST_FWD (1<<26) /* SSL server verify mode */ enum { diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 542ddd0d18..e46672e159 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -493,7 +493,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm) goto out; } } - else if (strcmp(args[0], "tune.fast-forward") == 0) { + else if (strcmp(args[0], "tune.disable-fast-forward") == 0) { if (!experimental_directives_allowed) { ha_alert("parsing [%s:%d] : '%s' directive is experimental, must be allowed via a global 'expose-experimental-directives'", file, linenum, args[0]); @@ -502,24 +502,9 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm) } mark_tainted(TAINTED_CONFIG_EXP_KW_DECLARED); - if (alertif_too_many_args(1, file, linenum, args, &err_code)) - goto out; - if (*(args[1]) == 0) { - ha_alert("parsing [%s:%d] : '%s' expects either 'on' or 'off' as argument.", - file, linenum, args[0]); - err_code |= ERR_ALERT | ERR_FATAL; - goto out; - } - if (strcmp(args[1], "on") == 0) - global.tune.options &= ~GTUNE_NO_FAST_FWD; - else if (strcmp(args[1], "off") == 0) - global.tune.options |= GTUNE_NO_FAST_FWD; - else { - ha_alert("parsing [%s:%d] : '%s' expects either 'on' or 'off' but got '%s'.", - file, linenum, args[0], args[1]); - err_code |= ERR_ALERT | ERR_FATAL; + if (alertif_too_many_args(0, file, linenum, args, &err_code)) goto out; - } + global.tune.options &= GTUNE_USE_FAST_FWD; } else if (strcmp(args[0], "cluster-secret") == 0) { if (alertif_too_many_args(1, file, linenum, args, &err_code)) diff --git a/src/haproxy.c b/src/haproxy.c index 804e092d29..3025d5afe6 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1598,6 +1598,8 @@ static void init_args(int argc, char **argv) #endif global.tune.options |= GTUNE_STRICT_LIMITS; + global.tune.options |= GTUNE_USE_FAST_FWD; /* Use fast-forward by default */ + /* keep a copy of original arguments for the master process */ old_argv = copy_argv(argc, argv); if (!old_argv) { @@ -1649,7 +1651,7 @@ static void init_args(int argc, char **argv) global.tune.options &= ~GTUNE_USE_REUSEPORT; #endif else if (*flag == 'd' && flag[1] == 'F') - global.tune.options |= GTUNE_NO_FAST_FWD; + global.tune.options &= ~GTUNE_USE_FAST_FWD; else if (*flag == 'd' && flag[1] == 'V') global.ssl_server_verify = SSL_SERVER_VERIFY_NONE; else if (*flag == 'V') diff --git a/src/http_ana.c b/src/http_ana.c index e5b8567069..cb7cb27b63 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -941,7 +941,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit) } else { c_adv(req, htx->data - co_data(req)); - if (!(global.tune.options & GTUNE_NO_FAST_FWD) && (msg->flags & HTTP_MSGF_XFER_LEN)) + if ((global.tune.options & GTUNE_USE_FAST_FWD) && (msg->flags & HTTP_MSGF_XFER_LEN)) channel_htx_forward_forever(req, htx); } @@ -2044,7 +2044,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit } else { c_adv(res, htx->data - co_data(res)); - if (!(global.tune.options & GTUNE_NO_FAST_FWD) && (msg->flags & HTTP_MSGF_XFER_LEN)) + if ((global.tune.options & GTUNE_USE_FAST_FWD) && (msg->flags & HTTP_MSGF_XFER_LEN)) channel_htx_forward_forever(res, htx); } diff --git a/src/stream.c b/src/stream.c index 3a9784ef53..8f58e0d67b 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2258,7 +2258,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) * to the consumer. */ co_set_data(req, htx->data); - if (!(global.tune.options & GTUNE_NO_FAST_FWD) && !(req->flags & (CF_SHUTR|CF_SHUTW_NOW))) + if ((global.tune.options & GTUNE_USE_FAST_FWD) && !(req->flags & (CF_SHUTR|CF_SHUTW_NOW))) channel_htx_forward_forever(req, htx); } else { @@ -2266,7 +2266,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) * to the consumer (which might possibly not be connected yet). */ c_adv(req, ci_data(req)); - if (!(global.tune.options & GTUNE_NO_FAST_FWD) && !(req->flags & (CF_SHUTR|CF_SHUTW_NOW))) + if ((global.tune.options & GTUNE_USE_FAST_FWD) && !(req->flags & (CF_SHUTR|CF_SHUTW_NOW))) channel_forward_forever(req); } } @@ -2429,7 +2429,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) * to the consumer. */ co_set_data(res, htx->data); - if (!(global.tune.options & GTUNE_NO_FAST_FWD) && !(res->flags & (CF_SHUTR|CF_SHUTW_NOW))) + if ((global.tune.options & GTUNE_USE_FAST_FWD) && !(res->flags & (CF_SHUTR|CF_SHUTW_NOW))) channel_htx_forward_forever(res, htx); } else { @@ -2437,7 +2437,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) * to the consumer. */ c_adv(res, ci_data(res)); - if (!(global.tune.options & GTUNE_NO_FAST_FWD) && !(res->flags & (CF_SHUTR|CF_SHUTW_NOW))) + if ((global.tune.options & GTUNE_USE_FAST_FWD) && !(res->flags & (CF_SHUTR|CF_SHUTW_NOW))) channel_forward_forever(res); }