From: Christopher Faulet Date: Wed, 14 Feb 2024 14:00:30 +0000 (+0100) Subject: MINOR: stconn: Rename SE_FL_MAY_FASTFWD and reorder bitfield X-Git-Tag: v3.0-dev4~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7598c0ba699cab31cf3df6eb59506c9b5d7edf7e;p=thirdparty%2Fhaproxy.git MINOR: stconn: Rename SE_FL_MAY_FASTFWD and reorder bitfield 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. --- diff --git a/include/haproxy/sc_strm.h b/include/haproxy/sc_strm.h index 016aab267f..d8fb5aa713 100644 --- a/include/haproxy/sc_strm.h +++ b/include/haproxy/sc_strm.h @@ -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)); diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index 8b6bd23442..d75ae443cc 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -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 */ diff --git a/src/applet.c b/src/applet.c index 4fc4e4018a..0525967f51 100644 --- a/src/applet.c +++ b/src/applet.c @@ -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); diff --git a/src/cache.c b/src/cache.c index 2120d877e1..cd567b3c1e 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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; } diff --git a/src/mux_h1.c b/src/mux_h1.c index 028a7c0848..95e9412901 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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); diff --git a/src/mux_pt.c b/src/mux_pt.c index 61e396b43f..7ee77d277d 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -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; diff --git a/src/stats.c b/src/stats.c index 1c2f750420..fac49114ca 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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; } diff --git a/src/stconn.c b/src/stconn.c index 8260cb039d..dec082f537 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -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; }