]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3/qpack: use qcs as type in decode callbacks
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 May 2022 12:25:53 +0000 (14:25 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 25 May 2022 13:41:25 +0000 (15:41 +0200)
Replace h3_uqs type by qcs in stream callbacks. This change is done in
the context of unification between bidi and uni-streams. h3_uqs type
will be unneeded when this is achieved.

include/haproxy/h3.h
include/haproxy/qpack-dec.h
src/h3.c
src/qpack-dec.c

index ad9540266cb4bb2b1b1d25d0b91147515e5fa245..5524d79cf2b4b8fb74867a822d4b1318835a84c2 100644 (file)
@@ -89,7 +89,7 @@ struct h3_uqs {
        /* Underlying incoming QUIC uni-stream */
        struct qcs *qcs;
        /* Callback to tx/rx bytes */
-       int (*cb)(struct h3_uqs *h3_uqs, void *ctx);
+       int (*cb)(struct qcs *qcs, void *ctx);
        struct wait_event wait_event;
 };
 
index 7dcfe1d117d6e91174e516d4d8a127a9e875df18..b847c802747b189998ab89cb11736a3d202fef36 100644 (file)
@@ -21,7 +21,8 @@
 #ifndef _HAPROXY_QPACK_DEC_H
 #define _HAPROXY_QPACK_DEC_H
 
-struct h3_uqs;
+#include <haproxy/mux_quic-t.h>
+
 struct http_hdr;
 
 /* Internal QPACK processing errors.
@@ -44,7 +45,7 @@ struct qpack_dec {
 
 int qpack_decode_fs(const unsigned char *buf, uint64_t len, struct buffer *tmp,
                     struct http_hdr *list);
-int qpack_decode_enc(struct h3_uqs *h3_uqs, void *ctx);
-int qpack_decode_dec(struct h3_uqs *h3_uqs, void *ctx);
+int qpack_decode_enc(struct qcs *qcs, void *ctx);
+int qpack_decode_dec(struct qcs *qcs, void *ctx);
 
 #endif /* _HAPROXY_QPACK_DEC_H */
index 317e6661181da0912d9a68dd9d27ffca09a817a9..13dbc70353d1e87cb33879382e2f4a234c0392f9 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -398,12 +398,12 @@ static int h3_parse_settings_frm(struct h3c *h3c, const struct ncbuf *rxbuf, siz
  * there is not enough received data.
  * Returns 0 if something wrong happened, 1 if not.
  */
-static int h3_control_recv(struct h3_uqs *h3_uqs, void *ctx)
+static int h3_control_recv(struct qcs *qcs, void *ctx)
 {
-       struct ncbuf *rxbuf = &h3_uqs->qcs->rx.ncbuf;
+       struct ncbuf *rxbuf = &qcs->rx.ncbuf;
        struct h3c *h3c = ctx;
 
-       h3_debug_printf(stderr, "%s STREAM ID: %lu\n", __func__,  h3_uqs->qcs->id);
+       h3_debug_printf(stderr, "%s STREAM ID: %lu\n", __func__,  qcs->id);
        if (!ncb_data(rxbuf, 0))
                return 1;
 
@@ -423,7 +423,7 @@ static int h3_control_recv(struct h3_uqs *h3_uqs, void *ctx)
                if (flen > b_data(&b))
                        break;
 
-               qcs_consume(h3_uqs->qcs, hlen);
+               qcs_consume(qcs, hlen);
                /* From here, a frame must not be truncated */
                switch (ftype) {
                case H3_FT_CANCEL_PUSH:
@@ -447,16 +447,9 @@ static int h3_control_recv(struct h3_uqs *h3_uqs, void *ctx)
                        h3c->err = H3_FRAME_UNEXPECTED;
                        return 0;
                }
-               qcs_consume(h3_uqs->qcs, flen);
+               qcs_consume(qcs, flen);
        }
 
-       /* Handle the case where remaining data are present in the buffer. This
-        * can happen if there is an incomplete frame. In this case, subscribe
-        * on the lower layer to restart receive operation.
-        */
-       if (ncb_data(rxbuf, 0))
-               qcs_subscribe(h3_uqs->qcs, SUB_RETRY_RECV, &h3_uqs->wait_event);
-
        return 1;
 }
 
@@ -471,15 +464,14 @@ static struct buffer *mux_get_buf(struct qcs *qcs)
        return &qcs->tx.buf;
 }
 
-/* Function used to emit stream data from <h3_uqs> control uni-stream */
-static int h3_control_send(struct h3_uqs *h3_uqs, void *ctx)
+/* Function used to emit stream data from <qcs> control uni-stream */
+static int h3_control_send(struct qcs *qcs, void *ctx)
 {
        int ret;
        struct h3c *h3c = ctx;
        unsigned char data[(2 + 3) * 2 * QUIC_VARINT_MAX_SIZE]; /* enough for 3 settings */
        struct buffer pos, *res;
        size_t frm_len;
-       struct qcs *qcs = h3_uqs->qcs;
 
        BUG_ON_HOT(h3c->flags & H3_CF_SETTINGS_SENT);
 
@@ -870,7 +862,7 @@ static int h3_finalize(void *ctx)
        if (!h3c->lctrl.qcs)
                return 0;
 
-       h3_control_send(&h3c->lctrl, h3c);
+       h3_control_send(h3c->lctrl.qcs, h3c);
 
        return 1;
 }
@@ -881,7 +873,7 @@ static struct task *h3_uqs_task(struct task *t, void *ctx, unsigned int state)
        struct h3_uqs *h3_uqs = ctx;
        struct h3c *h3c = h3_uqs->qcs->qcc->ctx;
 
-       h3_uqs->cb(h3_uqs, h3c);
+       h3_uqs->cb(h3_uqs->qcs, h3c);
        return NULL;
 }
 
@@ -909,13 +901,13 @@ static struct task *h3_uqs_send_task(struct task *t, void *ctx, unsigned int sta
        struct h3_uqs *h3_uqs = ctx;
        struct h3c *h3c = h3_uqs->qcs->qcc->ctx;
 
-       h3_uqs->cb(h3_uqs, h3c);
+       h3_uqs->cb(h3_uqs->qcs, h3c);
        return NULL;
 }
 
 /* Initialize <h3_uqs> uni-stream with <t> as tasklet */
 static int h3_uqs_init(struct h3_uqs *h3_uqs, struct h3c *h3c,
-                       int (*cb)(struct h3_uqs *h3_uqs, void *ctx),
+                       int (*cb)(struct qcs *qcs, void *ctx),
                        struct task *(*t)(struct task *, void *, unsigned int))
 {
        h3_uqs->qcs = NULL;
index 30ab6a71fbe538adca190bf5d4c371dab5a98a8f..c5e42a0f5da4591f4a076fd2a35cd77489607022 100644 (file)
@@ -94,13 +94,13 @@ static uint64_t qpack_get_varint(const unsigned char **buf, uint64_t *len_in, in
 }
 
 /* Decode an encoder stream */
-int qpack_decode_enc(struct h3_uqs *h3_uqs, void *ctx)
+int qpack_decode_enc(struct qcs *qcs, void *ctx)
 {
        size_t len;
        struct ncbuf *rxbuf;
        unsigned char inst;
 
-       rxbuf = &h3_uqs->qcs->rx.ncbuf;
+       rxbuf = &qcs->rx.ncbuf;
        len = ncb_data(rxbuf, 0);
        qpack_debug_hexdump(stderr, "[QPACK-DEC-ENC] ", ncb_head(rxbuf), 0, len);
 
@@ -127,13 +127,13 @@ int qpack_decode_enc(struct h3_uqs *h3_uqs, void *ctx)
 }
 
 /* Decode an decoder stream */
-int qpack_decode_dec(struct h3_uqs *h3_uqs, void *ctx)
+int qpack_decode_dec(struct qcs *qcs, void *ctx)
 {
        size_t len;
        struct ncbuf *rxbuf;
        unsigned char inst;
 
-       rxbuf = &h3_uqs->qcs->rx.ncbuf;
+       rxbuf = &qcs->rx.ncbuf;
        len = ncb_data(rxbuf, 0);
        qpack_debug_hexdump(stderr, "[QPACK-DEC-DEC] ", ncb_head(rxbuf), 0, len);