MINOR: stconn: Rename SE_FL_MAY_FASTFWD and reorder bitfield
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 14 Feb 2024 14:00:30 +0000 (15:00 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 14 Feb 2024 15:39:46 +0000 (16:39 +0100)
To fix a bug, a flag to announce the capabitlity to support the zero-copy
forwarding on the consumer side will be added on the SE descriptor. So the
old flag SE_FL_MAY_FASTFWD is renamed to indicate it concerns the producer
side. It is now SE_FL_MAY_FASTFWD_PROD. And to prepare addition of the new
flag, the bitfield is a bit reordered.

(cherry picked from commit 7598c0ba699cab31cf3df6eb59506c9b5d7edf7e)
[cf: some parts about applets were removed. A flag occurrence was missed in
     src/mux_pt.c in the original commit. This was fixed]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

include/haproxy/sc_strm.h
include/haproxy/stconn-t.h
src/cache.c
src/mux_h1.c
src/mux_pt.c
src/stats.c
src/stconn.c

index 0fbff37..41f07e9 100644 (file)
@@ -281,7 +281,7 @@ static inline int sc_is_recv_allowed(const struct stconn *sc)
        if (sc_ep_test(sc, SE_FL_HAVE_NO_DATA))
                return 0;
 
-       if (sc_ep_test(sc, SE_FL_MAY_FASTFWD) && (sc_opposite(sc)->sedesc->iobuf.flags & IOBUF_FL_FF_BLOCKED))
+       if (sc_ep_test(sc, SE_FL_MAY_FASTFWD_PROD) && (sc_opposite(sc)->sedesc->iobuf.flags & IOBUF_FL_FF_BLOCKED))
                return 0;
 
        return !(sc->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM));
index 380a388..525b5de 100644 (file)
@@ -86,10 +86,10 @@ enum se_flags {
        SE_FL_ERROR      = 0x00010000,  /* a fatal error was reported */
        /* Transient flags */
        SE_FL_ERR_PENDING= 0x00020000,  /* An error is pending, but there's still data to be read */
-       SE_FL_MAY_FASTFWD= 0x00040000,  /* The endpoint may fast-forward data to the other side */
-       SE_FL_RCV_MORE   = 0x00080000,  /* Endpoint may have more bytes to transfer */
-       SE_FL_WANT_ROOM  = 0x00100000,  /* More bytes to transfer, but not enough room */
-       SE_FL_EXP_NO_DATA= 0x00200000,  /* No data expected by the endpoint */
+       SE_FL_RCV_MORE   = 0x00040000,  /* Endpoint may have more bytes to transfer */
+       SE_FL_WANT_ROOM  = 0x00080000,  /* More bytes to transfer, but not enough room */
+       SE_FL_EXP_NO_DATA= 0x00100000,  /* No data expected by the endpoint */
+       SE_FL_MAY_FASTFWD_PROD = 0x00200000, /* The endpoint may produce data via zero-copy forwarding */
        SE_FL_ENDP_MASK  = 0x002ff000,  /* Mask for flags set by the endpoint */
 
        /* following flags are supposed to be set by the app layer and read by
@@ -120,8 +120,8 @@ static forceinline char *se_show_flags(char *buf, size_t len, const char *delim,
        _(SE_FL_T_MUX, _(SE_FL_T_APPLET, _(SE_FL_DETACHED, _(SE_FL_ORPHAN,
        _(SE_FL_SHRD, _(SE_FL_SHRR, _(SE_FL_SHWN, _(SE_FL_SHWS,
        _(SE_FL_NOT_FIRST, _(SE_FL_WEBSOCKET, _(SE_FL_EOI, _(SE_FL_EOS,
-       _(SE_FL_ERROR, _(SE_FL_ERR_PENDING, _(SE_FL_MAY_FASTFWD,
-       _(SE_FL_RCV_MORE, _(SE_FL_WANT_ROOM, _(SE_FL_EXP_NO_DATA,
+       _(SE_FL_ERROR, _(SE_FL_ERR_PENDING,  _(SE_FL_RCV_MORE,
+       _(SE_FL_WANT_ROOM, _(SE_FL_EXP_NO_DATA, _(SE_FL_MAY_FASTFWD_PROD,
        _(SE_FL_WAIT_FOR_HS, _(SE_FL_KILL_CONN, _(SE_FL_WAIT_DATA,
        _(SE_FL_WONT_CONSUME, _(SE_FL_HAVE_NO_DATA, _(SE_FL_APPLET_NEED_CONN))))))))))))))))))))))));
        /* epilogue */
index 3307348..9f12f10 100644 (file)
@@ -1711,6 +1711,7 @@ static void http_cache_io_handler(struct appctx *appctx)
                 /* no more data are expected. */
                res_htx->flags |= HTX_FL_EOM;
                se_fl_set(appctx->sedesc, SE_FL_EOI);
+
                appctx->st0 = HTX_CACHE_END;
        }
 
index c324c2f..81be253 100644 (file)
@@ -1921,11 +1921,11 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
            (!(h1m->flags & H1_MF_RESP) || !(h1s->flags & H1S_F_BODYLESS_RESP)) &&
            (h1m->state == H1_MSG_DATA || h1m->state == H1_MSG_TUNNEL)) {
                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);
+               se_fl_set(h1s->sd, SE_FL_MAY_FASTFWD_PROD);
        }
        else {
                TRACE_STATE("notify the mux can't use fast-forward anymore", H1_EV_RX_DATA|H1_EV_RX_BODY, h1c->conn, h1s);
-               se_fl_clr(h1s->sd, SE_FL_MAY_FASTFWD);
+               se_fl_clr(h1s->sd, SE_FL_MAY_FASTFWD_PROD);
                h1c->flags &= ~H1C_F_WANT_FASTFWD;
        }
 
@@ -4300,7 +4300,7 @@ static size_t h1_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in
        else
                TRACE_DEVEL("h1c ibuf not allocated", H1_EV_H1C_RECV|H1_EV_H1C_BLK, h1c->conn);
 
-       if ((flags & CO_RFL_BUF_FLUSH) && se_fl_test(h1s->sd, SE_FL_MAY_FASTFWD)) {
+       if ((flags & CO_RFL_BUF_FLUSH) && se_fl_test(h1s->sd, SE_FL_MAY_FASTFWD_PROD)) {
                h1c->flags |= H1C_F_WANT_FASTFWD;
                TRACE_STATE("Block xprt rcv_buf to flush stream's buffer (want_fastfwd)", H1_EV_STRM_RECV, h1c->conn, h1s);
        }
@@ -4757,7 +4757,7 @@ static int h1_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags)
 
        if (!(h1c->flags & H1C_F_WANT_FASTFWD)) {
                TRACE_STATE("notify the mux can't use fast-forward anymore", H1_EV_STRM_RECV, h1c->conn, h1s);
-               se_fl_clr(h1s->sd, SE_FL_MAY_FASTFWD);
+               se_fl_clr(h1s->sd, SE_FL_MAY_FASTFWD_PROD);
                if (!(h1c->wait_event.events & SUB_RETRY_RECV)) {
                        TRACE_STATE("restart receiving data, subscribing", H1_EV_STRM_RECV, h1c->conn, h1s);
                        h1c->conn->xprt->subscribe(h1c->conn, h1c->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
index 3284286..a4e4588 100644 (file)
@@ -325,7 +325,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)
-               se_fl_set(ctx->sd, SE_FL_MAY_FASTFWD);
+               se_fl_set(ctx->sd, SE_FL_MAY_FASTFWD_PROD);
 
        TRACE_LEAVE(PT_EV_CONN_NEW, conn);
        return 0;
@@ -656,7 +656,7 @@ 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);
+               se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD_PROD);
                goto end;
        }
 
@@ -671,7 +671,7 @@ static int mux_pt_fastfwd(struct stconn *sc, unsigned int count, unsigned int fl
        try = se_nego_ff(sdo, &BUF_NULL, count, conn->xprt->rcv_pipe && !!(flags & CO_RFL_MAY_SPLICE) && !(sdo->iobuf.flags & IOBUF_FL_NO_SPLICING));
        if (sdo->iobuf.flags & IOBUF_FL_NO_FF) {
                /* Fast forwarding is not supported by the consumer */
-               se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD);
+               se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD_PROD);
                TRACE_DEVEL("Fast-forwarding not supported by opposite endpoint, disable it", PT_EV_RX_DATA, conn, sc);
                goto end;
        }
@@ -689,7 +689,7 @@ static int mux_pt_fastfwd(struct stconn *sc, unsigned int count, unsigned int fl
                if (ret < 0) {
                        TRACE_ERROR("Error when trying to fast-forward data, disable it and abort",
                                    PT_EV_RX_DATA|PT_EV_STRM_ERR|PT_EV_CONN_ERR, conn, sc);
-                       se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD);
+                       se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD_PROD);
                        BUG_ON(sdo->iobuf.pipe->data);
                        put_pipe(sdo->iobuf.pipe);
                        sdo->iobuf.pipe = NULL;
index 95f40fe..0ed5758 100644 (file)
@@ -4476,7 +4476,6 @@ full:
        return 0;
 }
 
-
 /* This I/O handler runs as an applet embedded in a stream connector. It is
  * used to send HTTP stats over a TCP socket. The mechanism is very simple.
  * appctx->st0 contains the operation in progress (dump, done). The handler
index f6b3183..5d22f5c 100644 (file)
@@ -1271,7 +1271,7 @@ int sc_conn_recv(struct stconn *sc)
         * one without using the channel buffer.
         */
        if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD) &&
-           sc_ep_test(sc, SE_FL_MAY_FASTFWD) && ic->to_forward) {
+           sc_ep_test(sc, SE_FL_MAY_FASTFWD_PROD) && ic->to_forward) {
                if (channel_data(ic)) {
                        /* We're embarrassed, there are already data pending in
                         * the buffer and we don't want to have them at two
@@ -1298,7 +1298,7 @@ int sc_conn_recv(struct stconn *sc)
                if (sc_ep_test(sc, SE_FL_WANT_ROOM))
                        sc_need_room(sc, -1);
 
-               if (sc_ep_test(sc, SE_FL_MAY_FASTFWD) && ic->to_forward)
+               if (sc_ep_test(sc, SE_FL_MAY_FASTFWD_PROD) && ic->to_forward)
                        goto done_recv;
        }