]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
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 14:00:32 +0000 (15:00 +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.

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

index 016aab267f541d7e0b9d2dc68737940bea66e008..d8fb5aa7134a030bf6c31b158a2fc786a2f01620 100644 (file)
@@ -284,7 +284,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 8b6bd23442feb498d3bb031b37d6d2b80813122e..d75ae443ccb397523783801b4ccf93ac86b9c8d9 100644 (file)
@@ -93,10 +93,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
@@ -127,8 +127,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 4fc4e4018a749047b3774eadaccf376cfc49924a..0525967f5159962e40dd0447aa3b3a24e3d6a1de 100644 (file)
@@ -674,7 +674,7 @@ int appctx_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags)
 
        len = se_nego_ff(sdo, &BUF_NULL, count, nego_flags);
        if (sdo->iobuf.flags & IOBUF_FL_NO_FF) {
-               sc_ep_clr(sc, SE_FL_MAY_FASTFWD);
+               sc_ep_clr(sc, SE_FL_MAY_FASTFWD_PROD);
                applet_fl_clr(appctx, APPCTX_FL_FASTFWD);
                TRACE_DEVEL("Fast-forwarding not supported by opposite endpoint, disable it", APPLET_EV_RECV, appctx);
                goto end;
@@ -883,7 +883,7 @@ struct task *task_process_applet(struct task *t, void *context, unsigned int sta
 
        TRACE_POINT(APPLET_EV_PROCESS, app);
 
-       if (b_data(&app->outbuf) || se_fl_test(app->sedesc, SE_FL_MAY_FASTFWD))
+       if (b_data(&app->outbuf) || se_fl_test(app->sedesc, SE_FL_MAY_FASTFWD_PROD))
                applet_have_more_data(app);
 
        sc_applet_sync_recv(sc);
index 2120d877e144c2e698c283f5437ae0a8f44c1507..cd567b3c1e45d421c0e218dc7e009ce49a02b374 100644 (file)
@@ -1756,7 +1756,7 @@ static size_t http_cache_fastfwd(struct appctx *appctx, struct buffer *buf, size
        ret = ff_cache_dump_msg(appctx, buf, count);
 
        if (!appctx->to_forward) {
-               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD);
+               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
                applet_fl_clr(appctx, APPCTX_FL_FASTFWD);
                if (ctx->sent == first->len - sizeof(*cache_ptr)) {
                        applet_set_eoi(appctx);
@@ -1780,7 +1780,7 @@ static void http_cache_io_handler(struct appctx *appctx)
        if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL))
                goto exit;
 
-       if (applet_fl_test(appctx, APPCTX_FL_FASTFWD) && se_fl_test(appctx->sedesc, SE_FL_MAY_FASTFWD))
+       if (applet_fl_test(appctx, APPCTX_FL_FASTFWD) && se_fl_test(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD))
                goto exit;
 
        if (!appctx_get_buf(appctx, &appctx->outbuf)) {
@@ -1830,7 +1830,7 @@ static void http_cache_io_handler(struct appctx *appctx)
                        appctx->st0 = HTX_CACHE_EOM;
                else {
                        if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_APPLET)))
-                               se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD);
+                               se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
 
                        appctx->to_forward = cache_ptr->body_size;
                        len = first->len - sizeof(*cache_ptr) - ctx->sent;
@@ -1854,7 +1854,7 @@ static void http_cache_io_handler(struct appctx *appctx)
                 /* no more data are expected. */
                res_htx->flags |= HTX_FL_EOM;
                applet_set_eoi(appctx);
-               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD);
+               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
                applet_fl_clr(appctx, APPCTX_FL_FASTFWD);
                appctx->st0 = HTX_CACHE_END;
        }
index 028a7c084883278a7a01a3a40c1f2483385fab80..95e9412901454ac938fe5617fa9c0b875f2a976f 100644 (file)
@@ -1966,11 +1966,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;
        }
 
@@ -4345,7 +4345,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);
        }
@@ -4853,7 +4853,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 61e396b43fdfba97074e3a8215a17c47ceb87efb..7ee77d277d9aba84df3cfc2d1a40450558e3b884 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;
@@ -675,7 +675,7 @@ static int mux_pt_fastfwd(struct stconn *sc, unsigned int count, unsigned int fl
        try = se_nego_ff(sdo, &BUF_NULL, count, nego_flags);
        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;
        }
@@ -693,7 +693,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 1c2f750420c7a018f360b74721547e115b0c6ae6..fac49114caae909d13c684eb8c90c7446191afdf 100644 (file)
@@ -4473,7 +4473,7 @@ static size_t http_stats_fastfwd(struct appctx *appctx, struct buffer *buf, size
 
        ret = b_data(buf);
        if (stats_dump_stat_to_buffer(sc, buf, NULL)) {
-               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD);
+               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
                applet_fl_clr(appctx, APPCTX_FL_FASTFWD);
                appctx->st0 = STAT_HTTP_DONE;
        }
@@ -4499,7 +4499,7 @@ static void http_stats_io_handler(struct appctx *appctx)
        if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL))
                goto out;
 
-       if (applet_fl_test(appctx, APPCTX_FL_FASTFWD) && se_fl_test(appctx->sedesc, SE_FL_MAY_FASTFWD))
+       if (applet_fl_test(appctx, APPCTX_FL_FASTFWD) && se_fl_test(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD))
                goto out;
 
        if (!appctx_get_buf(appctx, &appctx->outbuf)) {
@@ -4523,7 +4523,7 @@ static void http_stats_io_handler(struct appctx *appctx)
                                appctx->st0 = STAT_HTTP_DONE;
                        else {
                                if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_APPLET)))
-                                       se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD);
+                                       se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
                                appctx->st0 = STAT_HTTP_DUMP;
                        }
                }
@@ -4563,7 +4563,7 @@ static void http_stats_io_handler(struct appctx *appctx)
                }
                res_htx->flags |= HTX_FL_EOM;
                applet_set_eoi(appctx);
-               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD);
+               se_fl_clr(appctx->sedesc, SE_FL_MAY_FASTFWD_PROD);
                applet_fl_clr(appctx, APPCTX_FL_FASTFWD);
                appctx->st0 = STAT_HTTP_END;
        }
index 8260cb039d5786df1b48154bb1de874551638a02..dec082f53748feff789b1c4f80929de74edd7ca0 100644 (file)
@@ -1268,7 +1268,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
@@ -1295,7 +1295,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;
        }
 
@@ -1908,7 +1908,7 @@ int sc_applet_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
@@ -1935,7 +1935,7 @@ int sc_applet_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;
        }