From: Amaury Denoyelle Date: Fri, 8 Dec 2023 14:52:00 +0000 (+0100) Subject: MINOR: hq-interop: use zero-copy to transfer single HTX data block X-Git-Tag: v3.0-dev1~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8e095b05828b8c82a01e37a18ea33e581e55431;p=thirdparty%2Fhaproxy.git MINOR: hq-interop: use zero-copy to transfer single HTX data block Similarly to H3, hq-interop now uses zero-copy when dealing with a HTX message with only a single data block. Exchange HTX and QCS buffer, and use the HTX data block for HTTP payload. This is only possible if QCS buffer is empty. Contrary to HTTP/3, no extra frame header is needed before transferring HTTP payload. hq-interop is only implemented for testing purpose so this change should not be noticeable by users. However, it will be useful to be able to test zero-copy transfer on QUIC interop testing. --- diff --git a/src/hq_interop.c b/src/hq_interop.c index 0bbf44c5ad..690c13bad0 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include static ssize_t hq_interop_rcv_buf(struct qcs *qcs, struct buffer *b, int fin) { @@ -110,6 +112,28 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, switch (btype) { case HTX_BLK_DATA: + if (unlikely(fsize == count && + !b_data(res) && + htx_nbblks(htx) == 1 && btype == HTX_BLK_DATA)) { + void *old_area = res->area; + + TRACE_DATA("perform zero-copy DATA transfer", QMUX_EV_STRM_SEND, + qcs->qcc->conn, qcs); + + /* remap MUX buffer to HTX area */ + *res = b_make(buf->area, buf->size, + sizeof(struct htx) + blk->addr, fsize); + + /* assign old MUX area to HTX buffer. */ + buf->area = old_area; + buf->data = buf->head = 0; + total += fsize; + + /* reload HTX with empty buffer. */ + *htx = *htx_from_buf(buf); + goto end; + } + if (fsize > count) fsize = count;