]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic/h3: define stream close callback
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 Jan 2023 11:12:11 +0000 (12:12 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 Jan 2023 14:56:25 +0000 (15:56 +0100)
Define a new qcc_app_ops callback named close(). This will be used to
notify app-layer about the closure of a stream by the remote peer. Its
main usage is to ensure that the closure is allowed by the application
protocol specification.

For the moment, close is not implemented by H3 layer. However, this
function will be mandatory to properly reject a STOP_SENDING on the
control stream and preventing a later crash. As such, this commit must
be backported with the next one on 2.6.

This is related to github issue #2006.

include/haproxy/mux_quic-t.h
src/h3.c

index 4ce088e61a1ae1cba87971c2cd57461e1f1ce4d7..2141506feb07e8a0e9937741bb1cd1297eafec51 100644 (file)
@@ -185,12 +185,19 @@ struct qcs {
        int start; /* base timestamp for http-request timeout */
 };
 
+/* Used as qcc_app_ops.close callback argument. */
+enum qcc_app_ops_close_side {
+       QCC_APP_OPS_CLOSE_SIDE_RD, /* Read channel closed (RESET_STREAM received). */
+       QCC_APP_OPS_CLOSE_SIDE_WR /* Write channel closed (STOP_SENDING received). */
+};
+
 /* QUIC application layer operations */
 struct qcc_app_ops {
        int (*init)(struct qcc *qcc);
        int (*attach)(struct qcs *qcs, void *conn_ctx);
        ssize_t (*decode_qcs)(struct qcs *qcs, struct buffer *b, int fin);
        size_t (*snd_buf)(struct qcs *qcs, struct htx *htx, size_t count);
+       int (*close)(struct qcs *qcs, enum qcc_app_ops_close_side side);
        void (*detach)(struct qcs *qcs);
        int (*finalize)(void *ctx);
        void (*shutdown)(void *ctx);                    /* Close a connection. */
index 14637e5bea5b2c9a560a3c89db57c8e4cf22d89a..e802d299cc8199453909b1e7e8d690f1e983563b 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -1601,6 +1601,24 @@ static size_t h3_snd_buf(struct qcs *qcs, struct htx *htx, size_t count)
        return total;
 }
 
+/* Notify about a closure on <qcs> stream requested by the remote peer.
+ *
+ * Stream channel <side> is explained relative to our endpoint : WR for
+ * STOP_SENDING or RD for RESET_STREAM reception. Callback decode_qcs() is used
+ * instead for closure performed using a STREAM frame with FIN bit.
+ *
+ * The main objective of this function is to check if closure is valid
+ * according to HTTP/3 specification.
+ *
+ * Returns 0 on success else non-zero. A CONNECTION_CLOSE is generated on
+ * error.
+ */
+static int h3_close(struct qcs *qcs, enum qcc_app_ops_close_side side)
+{
+       /* TODO */
+       return 0;
+}
+
 static int h3_attach(struct qcs *qcs, void *conn_ctx)
 {
        struct h3s *h3s;
@@ -1795,6 +1813,7 @@ const struct qcc_app_ops h3_ops = {
        .attach      = h3_attach,
        .decode_qcs  = h3_decode_qcs,
        .snd_buf     = h3_snd_buf,
+       .close       = h3_close,
        .detach      = h3_detach,
        .finalize    = h3_finalize,
        .shutdown    = h3_shutdown,