]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: add HTX EOM on request end
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 30 Nov 2021 10:23:29 +0000 (11:23 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 7 Dec 2021 16:11:22 +0000 (17:11 +0100)
Set the HTX EOM flag on RX the app layer. This is required to notify
about the end of the request for the stream analyzers, else the request
channel never goes to MSG_DONE state.

include/haproxy/mux_quic-t.h
include/haproxy/quic_frame-t.h
src/h3.c
src/hq_interop.c
src/quic_frame.c
src/xprt_quic.c

index 1515a5bc5b53e484a7cabc47a157bc643e318267..2c5c5553806a94a894b110d4f18af22b9e71b2f8 100644 (file)
@@ -85,7 +85,7 @@ struct qcs {
 struct qcc_app_ops {
        int (*init)(struct qcc *qcc);
        int (*attach_ruqs)(struct qcs *qcs, void *ctx);
-       int (*decode_qcs)(struct qcs *qcs, void *ctx);
+       int (*decode_qcs)(struct qcs *qcs, int fin, void *ctx);
        size_t (*snd_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
        int (*finalize)(void *ctx);
 };
index fcc04fc0b2184465c50f2e85a163dd9908a378bd..1d5438c60a95d9e975fa2b1e2e683769bace54a3 100644 (file)
@@ -149,6 +149,7 @@ struct quic_stream {
        struct buffer *buf;
        struct eb64_node offset;
        uint64_t len;
+       int fin;
        const unsigned char *data;
 };
 
index 0ed1800270a77aca447387703a996c156ed866fe..970b95752d06b3178e93f4c2796c55018380e4bb 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -96,7 +96,7 @@ static inline size_t h3_decode_frm_header(uint64_t *ftype, uint64_t *flen,
 /* Decode <qcs> remotely initiated bidi-stream.
  * Returns <0 on error else 0.
  */
-static int h3_decode_qcs(struct qcs *qcs, void *ctx)
+static int h3_decode_qcs(struct qcs *qcs, int fin, void *ctx)
 {
        struct buffer *rxbuf = &qcs->rx.buf;
        struct h3 *h3 = ctx;
@@ -220,6 +220,9 @@ static int h3_decode_qcs(struct qcs *qcs, void *ctx)
                b_del(rxbuf, flen);
        }
 
+       if (fin && !b_data(rxbuf))
+               htx->flags |= HTX_FL_EOM;
+
        return 0;
 
  fail:
index dc1e1154e636a6598f1bcf64929e4273b650154e..9d0d566353190c8fb38c0d9e8d198978e30e87b8 100644 (file)
@@ -9,7 +9,7 @@
 #include <haproxy/mux_quic-t.h>
 #include <haproxy/stream.h>
 
-static int hq_interop_decode_qcs(struct qcs *qcs, void *ctx)
+static int hq_interop_decode_qcs(struct qcs *qcs, int fin, void *ctx)
 {
        struct buffer *rxbuf = &qcs->rx.buf;
        struct htx *htx;
@@ -54,6 +54,9 @@ static int hq_interop_decode_qcs(struct qcs *qcs, void *ctx)
        b_del(rxbuf, b_data(rxbuf));
        b_free(&htx_buf);
 
+       if (fin)
+               htx->flags |= HTX_FL_EOM;
+
        return 0;
 }
 
index dfb6103fc5781fc5ac518e1b633002684b656367..f938d40be9f2255a1d1910f89daff8e17010f5fa 100644 (file)
@@ -427,6 +427,8 @@ static int quic_parse_stream_frame(struct quic_frame *frm, struct quic_conn *qc,
        else if (!quic_dec_int(&stream->len, buf, end) || end - *buf < stream->len)
                return 0;
 
+       stream->fin = (frm->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT);
+
        stream->data = *buf;
        *buf += stream->len;
 
index 2e7cf5c5c0811f904f324f5da41ea195ba1e30b8..250c2b80a6b0654e570011e26c349c47feecb8a4 100644 (file)
@@ -2076,7 +2076,7 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
                    goto store_frm;
 
                ret = qc_strm_cpy(&strm->rx.buf, strm_frm);
-               if (ret && qc->qcc->app_ops->decode_qcs(strm, qc->qcc->ctx) < 0) {
+               if (ret && qc->qcc->app_ops->decode_qcs(strm, strm_frm->fin, qc->qcc->ctx) < 0) {
                        TRACE_PROTO("Decoding error", QUIC_EV_CONN_PSTRM);
                        return 0;
                }