diff --git a/doc/configuration.txt b/doc/configuration.txt index 670b2e80e..b3bf728c5 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -1211,6 +1211,7 @@ The following keywords are supported in the "global" section : - tune.pipesize - tune.pool-high-fd-ratio - tune.pool-low-fd-ratio + - tune.pt.zero-copy-forwarding - tune.quic.frontend.conn-tx-buffers.limit - tune.quic.frontend.max-idle-timeout - tune.quic.frontend.max-streams-bidi @@ -2921,6 +2922,8 @@ tune.disable-zero-copy-forwarding Thanks to this directive, it is possible to disable this optimization. Note it also disable any kernel tcp splicing. + See also: tune.pt.zero-copy-forwarding + tune.events.max-events-at-once Sets the number of events that may be processed at once by an asynchronous task handler (from event_hdl API). should be included between 1 @@ -3347,6 +3350,14 @@ tune.pool-low-fd-ratio use before we stop putting connection into the idle pool for reuse. The default is 20. +tune.pt.zero-copy-forwarding { on | off } + Enables ('on') of disabled ('off') the zero-copy forwarding of data for the + pass-through multiplexer. To be used, the kernel splicing must also be + configured. It is enabled by default. + + See also: tune.disable-zero-copy-forwarding, option splice-auto, + option splice-request and option splice-response + tune.quic.frontend.conn-tx-buffers.limit This settings defines the maximum number of buffers allocated for a QUIC connection on data emission. By default, it is set to 30. QUIC buffers are diff --git a/src/mux_pt.c b/src/mux_pt.c index 11f470585..32842861e 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -654,6 +655,11 @@ static int mux_pt_fastfwd(struct stconn *sc, unsigned int count, unsigned int fl TRACE_ENTER(PT_EV_RX_DATA, conn, sc, 0, (size_t[]){count}); + if (global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_PT) { + se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD); + goto end; + } + se_fl_clr(ctx->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); conn->flags &= ~CO_FL_WAIT_ROOM; sdo = mux_pt_opposite_sd(ctx); @@ -810,6 +816,35 @@ static int mux_pt_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *out } } +/* config parser for global "tune.pt.zero-copy-forwarding" */ +static int cfg_parse_pt_zero_copy_fwd(char **args, int section_type, struct proxy *curpx, + const struct proxy *defpx, const char *file, int line, + char **err) +{ + if (too_many_args(1, args, err, NULL)) + return -1; + + if (strcmp(args[1], "on") == 0) + global.tune.no_zero_copy_fwd &= ~NO_ZERO_COPY_FWD_PT; + else if (strcmp(args[1], "off") == 0) + global.tune.no_zero_copy_fwd |= NO_ZERO_COPY_FWD_PT; + else { + memprintf(err, "'%s' expects 'on' or 'off'.", args[0]); + return -1; + } + return 0; +} + + +/* config keyword parsers */ +static struct cfg_kw_list cfg_kws = {ILH, { + { CFG_GLOBAL, "tune.pt.zero-copy-forwarding", cfg_parse_pt_zero_copy_fwd }, + { 0, NULL, NULL } +}}; + +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + + /* The mux operations */ const struct mux_ops mux_tcp_ops = { .init = mux_pt_init,