]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h3: define snd_buf callback and divert mux ops
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 24 Aug 2021 14:33:53 +0000 (16:33 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Sep 2021 13:27:25 +0000 (15:27 +0200)
include/haproxy/h3.h
include/haproxy/mux_quic.h
src/h3.c
src/mux_quic.c

index 67ead4c86cf9384bc94440b65f8954853b6a8f0a..4c329b8ab51ca1ce0bd59646f0ab6acd73c60eba 100644 (file)
@@ -93,5 +93,7 @@ struct h3_uqs {
 
 extern const struct qcc_app_ops h3_ops;
 
+size_t h3_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
+
 #endif /* USE_QUIC */
 #endif /* _HAPROXY_H3_T_H */
index 7d7b7cc0f1193cd132518afc20a895d20060dc1e..4e9bb4c92ab681ceb12e8c204458ca2d2e679a3d 100644 (file)
@@ -122,5 +122,7 @@ static inline void *qcs_new(struct qcc *qcc, uint64_t id)
                return bidi_qcs_new(qcc, id);
 }
 
+size_t qc_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
+
 #endif /* USE_QUIC */
 #endif /* _HAPROXY_MUX_QUIC_H */
index f961ab1f090153a877e1ed768c967069a8a212e6..194d57f2f48a56300b3e2a4e331190656151817d 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -433,7 +433,54 @@ static struct buffer *get_mux_next_tx_buf(struct qcs *qcs)
                ABORT_NOW();
 
        return buf;
+}
+
+size_t h3_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
+{
+       size_t total = 0;
+       struct qcs *qcs = cs->ctx;
+       struct htx *htx;
+       enum htx_blk_type btype;
+       struct htx_blk *blk;
+       uint32_t bsize;
+       int32_t idx;
+       int ret;
+
+       htx = htx_from_buf(buf);
+
+       while (count && !htx_is_empty(htx)) {
+               idx = htx_get_head(htx);
+               blk = htx_get_blk(htx, idx);
+               btype = htx_get_blk_type(blk);
+               bsize = htx_get_blksz(blk);
+
+               /* Not implemented : QUIC on backend side */
+               BUG_ON(btype == HTX_BLK_REQ_SL);
+
+               switch (btype) {
+               case HTX_BLK_RES_SL:
+                       /* TODO HEADERS h3 frame */
 
+               case HTX_BLK_DATA:
+                       /* TODO DATA h3 frame */
+
+               case HTX_BLK_TLR:
+               case HTX_BLK_EOT:
+                       /* TODO trailers */
+
+               default:
+                       htx_remove_blk(htx, blk);
+                       total += bsize;
+                       count -= bsize;
+                       break;
+               }
+       }
+
+       // TODO should I call the mux directly here ?
+       qc_snd_buf(cs, buf, total, flags);
+
+ out:
+       return total;
 }
 
 /* Finalize the initialization of remotely initiated uni-stream <qcs>.
index f870f708ef4d6096503cc046fbc80d22601b01db..83229c2cb2d665eacbd7a22ce1efed00a507acb9 100644 (file)
@@ -1867,10 +1867,9 @@ static size_t qc_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
  * <count> bytes. Returns the number of bytes effectively sent. Some status
  * flags may be updated on the conn_stream.
  */
-static size_t qc_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
+size_t qc_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
 {
        struct qcs *qcs = cs->ctx;
-       size_t total = 0;
 
        TRACE_ENTER(QC_EV_QCS_SEND|QC_EV_STRM_SEND, qcs->qcc->conn, qcs);
 
@@ -1880,7 +1879,7 @@ static size_t qc_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
        }
 
        TRACE_LEAVE(QC_EV_QCS_SEND|QC_EV_STRM_SEND, qcs->qcc->conn, qcs);
-       return total;
+       return count;
 }
 
 /* Called from the upper layer, to send data from buffer <buf> for no more than
@@ -2118,7 +2117,8 @@ static int qc_takeover(struct connection *conn, int orig_tid)
 static const struct mux_ops qc_ops = {
        .init = qc_init,
        .wake = qc_wake,
-       .snd_buf = qc_snd_buf,
+       //.snd_buf = qc_snd_buf,
+       .snd_buf = h3_snd_buf,
        .rcv_buf = qc_rcv_buf,
        .subscribe = qc_subscribe,
        .unsubscribe = qc_unsubscribe,