]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes/applet: Simplify checks on options to disable zero-copy forwarding
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 14 Feb 2024 14:17:17 +0000 (15:17 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 14 Feb 2024 14:41:04 +0000 (15:41 +0100)
Global options to disable for zero-copy forwarding are now tested outside
callbacks responsible to perform the forwarding itself. It is cleaner this
way because we don't try at all zero-copy forwarding if at least one side
does not support it. It is equivalent to what was performed before, but it
is simplier this way.

src/cache.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c
src/mux_quic.c
src/stats.c

index cd567b3c1e45d421c0e218dc7e009ce49a02b374..6cbfe7a8212f25c95fa04e8d4c010ea6d4c12100 100644 (file)
@@ -1829,7 +1829,7 @@ static void http_cache_io_handler(struct appctx *appctx)
                if (find_http_meth(istptr(meth), istlen(meth)) == HTTP_METH_HEAD || ctx->send_notmodified)
                        appctx->st0 = HTX_CACHE_EOM;
                else {
-                       if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_APPLET)))
+                       if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_APPLET))
                                se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
 
                        appctx->to_forward = cache_ptr->body_size;
index a50c204fca985e11abe37c008aced37521d9ce3e..15faa4fc3571095ac7b7a78c2515893181bdd909 100644 (file)
@@ -1968,7 +1968,8 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
        /* Here h1s_sc(h1s) is always defined */
        if (!(h1c->flags & H1C_F_CANT_FASTFWD) &&
            (!(h1m->flags & H1_MF_RESP) || !(h1s->flags & H1S_F_BODYLESS_RESP)) &&
-           (h1m->state == H1_MSG_DATA || h1m->state == H1_MSG_TUNNEL)) {
+           (h1m->state == H1_MSG_DATA || h1m->state == H1_MSG_TUNNEL) &&
+           !(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_H1_RCV)) {
                TRACE_STATE("notify the mux can use fast-forward", H1_EV_RX_DATA|H1_EV_RX_BODY, h1c->conn, h1s);
                se_fl_set(h1s->sd, SE_FL_MAY_FASTFWD_PROD);
        }
@@ -4674,11 +4675,6 @@ static int h1_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags)
 
        TRACE_ENTER(H1_EV_STRM_RECV, h1c->conn, h1s, 0, (size_t[]){count});
 
-       if (global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_H1_RCV) {
-               h1c->flags = (h1c->flags & ~H1C_F_WANT_FASTFWD) | H1C_F_CANT_FASTFWD;
-               goto end;
-       }
-
        if (h1m->state != H1_MSG_DATA && h1m->state != H1_MSG_TUNNEL) {
                h1c->flags &= ~H1C_F_WANT_FASTFWD;
                TRACE_STATE("Cannot fast-forwad data now !(msg_data|msg_tunnel)", H1_EV_STRM_RECV, h1c->conn, h1s);
index 9ddd1b990bc1a3c50440be03d47ff415ef6a8163..1dd886c0de104ae99644f1a8634dbc74fe9d23bc 100644 (file)
@@ -7131,11 +7131,6 @@ static size_t h2_nego_ff(struct stconn *sc, struct buffer *input, size_t count,
 
        TRACE_ENTER(H2_EV_H2S_SEND|H2_EV_STRM_SEND, h2s->h2c->conn, h2s);
 
-       if (global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_H2_SND) {
-               h2s->sd->iobuf.flags |= IOBUF_FL_NO_FF;
-               goto end;
-       }
-
        /* If we were not just woken because we wanted to send but couldn't,
         * and there's somebody else that is waiting to send, do nothing,
         * we will subscribe later and be put at the end of the list
index 32800047b630c1cb712b16e27fa63db34ab25156..832d189803a042b27955130ac924e02324fef162 100644 (file)
@@ -324,7 +324,7 @@ static int mux_pt_init(struct connection *conn, struct proxy *prx, struct sessio
        }
        conn->ctx = ctx;
        se_fl_set(ctx->sd, SE_FL_RCV_MORE);
-       if (global.tune.options & GTUNE_USE_SPLICE)
+       if ((global.tune.options & GTUNE_USE_SPLICE) && !(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_PT))
                se_fl_set(ctx->sd, SE_FL_MAY_FASTFWD_PROD|SE_FL_MAY_FASTFWD_CONS);
 
        TRACE_LEAVE(PT_EV_CONN_NEW, conn);
@@ -391,6 +391,8 @@ static int mux_pt_attach(struct connection *conn, struct sedesc *sd, struct sess
                return -1;
        ctx->sd = sd;
        se_fl_set(ctx->sd, SE_FL_RCV_MORE);
+       if ((global.tune.options & GTUNE_USE_SPLICE) && !(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_PT))
+               se_fl_set(ctx->sd, SE_FL_MAY_FASTFWD_PROD|SE_FL_MAY_FASTFWD_CONS);
 
        TRACE_LEAVE(PT_EV_STRM_NEW, conn, sd->sc);
        return 0;
@@ -656,11 +658,6 @@ 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);
index e4940e3c27be7f04aca6a7654525489a0b25b8fd..af678b72ab0f18c91fbf6f0f61de0f32dc3897e2 100644 (file)
@@ -2941,11 +2941,6 @@ static size_t qmux_strm_nego_ff(struct stconn *sc, struct buffer *input,
        /* stream layer has been detached so no transfer must occur after. */
        BUG_ON_HOT(qcs->flags & QC_SF_DETACH);
 
-       if (global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_QUIC_SND) {
-               qcs->sd->iobuf.flags |= IOBUF_FL_NO_FF;
-               goto end;
-       }
-
        if (!qcs->qcc->app_ops->nego_ff || !qcs->qcc->app_ops->done_ff) {
                /* Fast forwarding is not supported by the QUIC application layer */
                qcs->sd->iobuf.flags |= IOBUF_FL_NO_FF;
index fac49114caae909d13c684eb8c90c7446191afdf..05b73d9b0f9b2139237c88d22015238faadba4c3 100644 (file)
@@ -4522,7 +4522,7 @@ static void http_stats_io_handler(struct appctx *appctx)
                        if (find_http_meth(istptr(meth), istlen(meth)) == HTTP_METH_HEAD)
                                appctx->st0 = STAT_HTTP_DONE;
                        else {
-                               if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_APPLET)))
+                               if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_APPLET))
                                        se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
                                appctx->st0 = STAT_HTTP_DUMP;
                        }