]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Fix splicing for messages with unknown length
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 26 Nov 2021 16:26:19 +0000 (17:26 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Dec 2021 10:47:08 +0000 (11:47 +0100)
Splicing was disabled fo Messages with an unknown length (no C-L or T-E
header) with no valid reason. So now, it is possible to use the kernel
splicing for such messages.

This patch should be backported as far as 2.4.

src/mux_h1.c

index dac124b5c1c9f9718ee990644c801480727664c2..6cb7ec83bccbc6f46c6279dae8aa94e31daad9fb 100644 (file)
@@ -1721,8 +1721,7 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
        }
 
        /* Here h1s->cs is always defined */
-       if (!(h1m->flags & H1_MF_CHNK) &&
-           ((h1m->state == H1_MSG_DATA && h1m->curr_len) || (h1m->state == H1_MSG_TUNNEL))) {
+       if (!(h1m->flags & H1_MF_CHNK) && (h1m->state == H1_MSG_DATA || (h1m->state == H1_MSG_TUNNEL))) {
                TRACE_STATE("notify the mux can use splicing", H1_EV_RX_DATA|H1_EV_RX_BODY, h1c->conn, h1s);
                h1s->cs->flags |= CS_FL_MAY_SPLICE;
        }
@@ -3576,11 +3575,11 @@ static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int c
                goto end;
        }
 
-       if (h1m->state == H1_MSG_DATA && count > h1m->curr_len)
+       if (h1m->state == H1_MSG_DATA && (h1m->flags & H1_MF_CLEN) && count > h1m->curr_len)
                count = h1m->curr_len;
        ret = cs->conn->xprt->rcv_pipe(cs->conn, cs->conn->xprt_ctx, pipe, count);
        if (ret >= 0) {
-               if (h1m->state == H1_MSG_DATA) {
+               if (h1m->state == H1_MSG_DATA && (h1m->flags & H1_MF_CLEN)) {
                        if (ret > h1m->curr_len) {
                                h1s->flags |= H1S_F_PARSING_ERROR;
                                h1c->flags |= H1C_F_ST_ERROR;
@@ -3636,7 +3635,7 @@ static int h1_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
        }
 
        ret = cs->conn->xprt->snd_pipe(cs->conn, cs->conn->xprt_ctx, pipe);
-       if (h1m->state == H1_MSG_DATA) {
+       if (h1m->state == H1_MSG_DATA && (h1m->flags & H1_MF_CLEN)) {
                if (ret > h1m->curr_len) {
                        h1s->flags |= H1S_F_PROCESSING_ERROR;
                        h1c->flags |= H1C_F_ST_ERROR;