mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
REORG: mux-quic: export HTTP related function in a dedicated file
Extract function dealing with HTX outside of MUX QUIC. For the moment, only rcv_buf stream operation is concerned. The main objective is to be able to support both TCP and HTTP proxy mode with a common base and add specialized modules on top of it. This should be backported up to 2.6.
This commit is contained in:
parent
36d50bff22
commit
d80fbcaca2
2
Makefile
2
Makefile
@ -646,7 +646,7 @@ OPTIONS_OBJS += src/quic_sock.o src/proto_quic.o src/xprt_quic.o src/quic_tls.o
|
|||||||
src/cbuf.o src/qpack-dec.o src/qpack-tbl.o src/h3.o src/qpack-enc.o \
|
src/cbuf.o src/qpack-dec.o src/qpack-tbl.o src/h3.o src/qpack-enc.o \
|
||||||
src/hq_interop.o src/cfgparse-quic.o src/quic_loss.o \
|
src/hq_interop.o src/cfgparse-quic.o src/quic_loss.o \
|
||||||
src/quic_tp.o src/quic_stream.o src/quic_stats.o src/h3_stats.o \
|
src/quic_tp.o src/quic_stream.o src/quic_stats.o src/h3_stats.o \
|
||||||
src/quic_cc_cubic.o src/qmux_trace.o
|
src/quic_cc_cubic.o src/qmux_trace.o src/qmux_http.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(USE_LUA),)
|
ifneq ($(USE_LUA),)
|
||||||
|
14
include/haproxy/qmux_http.h
Normal file
14
include/haproxy/qmux_http.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef _HAPROXY_MUX_QUIC_HTTP_H
|
||||||
|
#define _HAPROXY_MUX_QUIC_HTTP_H
|
||||||
|
|
||||||
|
#ifdef USE_QUIC
|
||||||
|
|
||||||
|
#include <haproxy/buf.h>
|
||||||
|
#include <haproxy/mux_quic.h>
|
||||||
|
|
||||||
|
size_t qcs_http_rcv_buf(struct qcs *qcs, struct buffer *buf, size_t count,
|
||||||
|
char *fin);
|
||||||
|
|
||||||
|
#endif /* USE_QUIC */
|
||||||
|
|
||||||
|
#endif /* _HAPROXY_MUX_QUIC_HTTP_H */
|
@ -5,10 +5,10 @@
|
|||||||
#include <haproxy/api.h>
|
#include <haproxy/api.h>
|
||||||
#include <haproxy/connection.h>
|
#include <haproxy/connection.h>
|
||||||
#include <haproxy/dynbuf.h>
|
#include <haproxy/dynbuf.h>
|
||||||
#include <haproxy/htx.h>
|
|
||||||
#include <haproxy/list.h>
|
#include <haproxy/list.h>
|
||||||
#include <haproxy/ncbuf.h>
|
#include <haproxy/ncbuf.h>
|
||||||
#include <haproxy/pool.h>
|
#include <haproxy/pool.h>
|
||||||
|
#include <haproxy/qmux_http.h>
|
||||||
#include <haproxy/qmux_trace.h>
|
#include <haproxy/qmux_trace.h>
|
||||||
#include <haproxy/quic_stream.h>
|
#include <haproxy/quic_stream.h>
|
||||||
#include <haproxy/quic_tp-t.h>
|
#include <haproxy/quic_tp-t.h>
|
||||||
@ -2062,49 +2062,13 @@ static size_t qc_rcv_buf(struct stconn *sc, struct buffer *buf,
|
|||||||
size_t count, int flags)
|
size_t count, int flags)
|
||||||
{
|
{
|
||||||
struct qcs *qcs = __sc_mux_strm(sc);
|
struct qcs *qcs = __sc_mux_strm(sc);
|
||||||
struct htx *qcs_htx = NULL;
|
|
||||||
struct htx *cs_htx = NULL;
|
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
char fin = 0;
|
char fin = 0;
|
||||||
|
|
||||||
TRACE_ENTER(QMUX_EV_STRM_RECV, qcs->qcc->conn, qcs);
|
TRACE_ENTER(QMUX_EV_STRM_RECV, qcs->qcc->conn, qcs);
|
||||||
|
|
||||||
qcs_htx = htx_from_buf(&qcs->rx.app_buf);
|
ret = qcs_http_rcv_buf(qcs, buf, count, &fin);
|
||||||
if (htx_is_empty(qcs_htx)) {
|
|
||||||
/* Set buffer data to 0 as HTX is empty. */
|
|
||||||
htx_to_buf(qcs_htx, &qcs->rx.app_buf);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = qcs_htx->data;
|
|
||||||
|
|
||||||
cs_htx = htx_from_buf(buf);
|
|
||||||
if (htx_is_empty(cs_htx) && htx_used_space(qcs_htx) <= count) {
|
|
||||||
/* EOM will be copied to cs_htx via b_xfer(). */
|
|
||||||
if (qcs_htx->flags & HTX_FL_EOM)
|
|
||||||
fin = 1;
|
|
||||||
|
|
||||||
htx_to_buf(cs_htx, buf);
|
|
||||||
htx_to_buf(qcs_htx, &qcs->rx.app_buf);
|
|
||||||
b_xfer(buf, &qcs->rx.app_buf, b_data(&qcs->rx.app_buf));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
htx_xfer_blks(cs_htx, qcs_htx, count, HTX_BLK_UNUSED);
|
|
||||||
BUG_ON(qcs_htx->flags & HTX_FL_PARSING_ERROR);
|
|
||||||
|
|
||||||
/* Copy EOM from src to dst buffer if all data copied. */
|
|
||||||
if (htx_is_empty(qcs_htx) && (qcs_htx->flags & HTX_FL_EOM)) {
|
|
||||||
cs_htx->flags |= HTX_FL_EOM;
|
|
||||||
fin = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cs_htx->extra = qcs_htx->extra ? (qcs_htx->data + qcs_htx->extra) : 0;
|
|
||||||
htx_to_buf(cs_htx, buf);
|
|
||||||
htx_to_buf(qcs_htx, &qcs->rx.app_buf);
|
|
||||||
ret -= qcs_htx->data;
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (b_data(&qcs->rx.app_buf)) {
|
if (b_data(&qcs->rx.app_buf)) {
|
||||||
se_fl_set(qcs->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
|
se_fl_set(qcs->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
|
||||||
}
|
}
|
||||||
|
63
src/qmux_http.c
Normal file
63
src/qmux_http.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include <haproxy/qmux_http.h>
|
||||||
|
|
||||||
|
#include <haproxy/api-t.h>
|
||||||
|
#include <haproxy/htx.h>
|
||||||
|
#include <haproxy/qmux_trace.h>
|
||||||
|
|
||||||
|
/* QUIC MUX rcv_buf operation using HTX data. Received data from stream <qcs>
|
||||||
|
* will be transferred as HTX in <buf>. Output buffer is expected to be of
|
||||||
|
* length <count>. <fin> will be set to signal the last data to receive on this
|
||||||
|
* stream.
|
||||||
|
*
|
||||||
|
* Return the size in bytes of transferred data.
|
||||||
|
*/
|
||||||
|
size_t qcs_http_rcv_buf(struct qcs *qcs, struct buffer *buf, size_t count,
|
||||||
|
char *fin)
|
||||||
|
{
|
||||||
|
struct htx *qcs_htx = NULL;
|
||||||
|
struct htx *cs_htx = NULL;
|
||||||
|
size_t ret = 0;
|
||||||
|
|
||||||
|
TRACE_ENTER(QMUX_EV_STRM_RECV, qcs->qcc->conn, qcs);
|
||||||
|
|
||||||
|
*fin = 0;
|
||||||
|
qcs_htx = htx_from_buf(&qcs->rx.app_buf);
|
||||||
|
if (htx_is_empty(qcs_htx)) {
|
||||||
|
/* Set buffer data to 0 as HTX is empty. */
|
||||||
|
htx_to_buf(qcs_htx, &qcs->rx.app_buf);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = qcs_htx->data;
|
||||||
|
|
||||||
|
cs_htx = htx_from_buf(buf);
|
||||||
|
if (htx_is_empty(cs_htx) && htx_used_space(qcs_htx) <= count) {
|
||||||
|
/* EOM will be copied to cs_htx via b_xfer(). */
|
||||||
|
if (qcs_htx->flags & HTX_FL_EOM)
|
||||||
|
*fin = 1;
|
||||||
|
|
||||||
|
htx_to_buf(cs_htx, buf);
|
||||||
|
htx_to_buf(qcs_htx, &qcs->rx.app_buf);
|
||||||
|
b_xfer(buf, &qcs->rx.app_buf, b_data(&qcs->rx.app_buf));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
htx_xfer_blks(cs_htx, qcs_htx, count, HTX_BLK_UNUSED);
|
||||||
|
BUG_ON(qcs_htx->flags & HTX_FL_PARSING_ERROR);
|
||||||
|
|
||||||
|
/* Copy EOM from src to dst buffer if all data copied. */
|
||||||
|
if (htx_is_empty(qcs_htx) && (qcs_htx->flags & HTX_FL_EOM)) {
|
||||||
|
cs_htx->flags |= HTX_FL_EOM;
|
||||||
|
*fin = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cs_htx->extra = qcs_htx->extra ? (qcs_htx->data + qcs_htx->extra) : 0;
|
||||||
|
htx_to_buf(cs_htx, buf);
|
||||||
|
htx_to_buf(qcs_htx, &qcs->rx.app_buf);
|
||||||
|
ret -= qcs_htx->data;
|
||||||
|
|
||||||
|
end:
|
||||||
|
TRACE_LEAVE(QMUX_EV_STRM_RECV, qcs->qcc->conn, qcs);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user