Move quic_cstream struct definition from quic_conn-t.h to quic_tls-t.h.
Its pool is also moved from quic_conn module to quic_tls. Same thing for
quic_cstream_new() and quic_cstream_free().
/* The maximum number of bytes of CRYPTO data in flight during handshakes. */
#define QUIC_CRYPTO_IN_FLIGHT_MAX 4096
-/* Crypto data stream (one by encryption level) */
-struct quic_cstream {
- struct {
- uint64_t offset; /* absolute current base offset of ncbuf */
- struct ncbuf ncbuf; /* receive buffer - can handle out-of-order offset frames */
- } rx;
- struct {
- uint64_t offset; /* last offset of data ready to be sent */
- uint64_t sent_offset; /* last offset sent by transport layer */
- struct buffer buf; /* transmit buffer before sending via xprt */
- } tx;
-
- struct qc_stream_desc *desc;
-};
-
struct quic_path {
/* Control congestion. */
struct quic_cc cc;
size_t sz;
};
+/* Crypto data stream (one by encryption level) */
+struct quic_cstream {
+ struct {
+ uint64_t offset; /* absolute current base offset of ncbuf */
+ struct ncbuf ncbuf; /* receive buffer - can handle out-of-order offset frames */
+ } rx;
+ struct {
+ uint64_t offset; /* last offset of data ready to be sent */
+ uint64_t sent_offset; /* last offset sent by transport layer */
+ struct buffer buf; /* transmit buffer before sending via xprt */
+ } tx;
+
+ struct qc_stream_desc *desc;
+};
+
struct quic_enc_level {
struct list list;
/* Attach point to enqueue this encryption level during retransmissions */
DECLARE_STATIC_POOL(pool_head_quic_cids, "quic_cids", sizeof(struct eb_root));
DECLARE_POOL(pool_head_quic_connection_id,
"quic_connection_id", sizeof(struct quic_connection_id));
-DECLARE_STATIC_POOL(pool_head_quic_cstream, "quic_cstream", sizeof(struct quic_cstream));
struct task *quic_conn_app_io_cb(struct task *t, void *context, unsigned int state);
static int quic_conn_init_timer(struct quic_conn *qc);
return t;
}
-/* Release the memory allocated for <cs> CRYPTO stream */
-void quic_cstream_free(struct quic_cstream *cs)
-{
- if (!cs) {
- /* This is the case for ORTT encryption level */
- return;
- }
-
- quic_free_ncbuf(&cs->rx.ncbuf);
-
- qc_stream_desc_release(cs->desc);
- pool_free(pool_head_quic_cstream, cs);
-}
-
-/* Allocate a new QUIC stream for <qc>.
- * Return it if succeeded, NULL if not.
- */
-struct quic_cstream *quic_cstream_new(struct quic_conn *qc)
-{
- struct quic_cstream *cs, *ret_cs = NULL;
-
- TRACE_ENTER(QUIC_EV_CONN_LPKT, qc);
- cs = pool_alloc(pool_head_quic_cstream);
- if (!cs) {
- TRACE_ERROR("crypto stream allocation failed", QUIC_EV_CONN_INIT, qc);
- goto leave;
- }
-
- cs->rx.offset = 0;
- cs->rx.ncbuf = NCBUF_NULL;
- cs->rx.offset = 0;
-
- cs->tx.offset = 0;
- cs->tx.sent_offset = 0;
- cs->tx.buf = BUF_NULL;
- cs->desc = qc_stream_desc_new((uint64_t)-1, -1, cs, qc);
- if (!cs->desc) {
- TRACE_ERROR("crypto stream allocation failed", QUIC_EV_CONN_INIT, qc);
- goto err;
- }
-
- ret_cs = cs;
- leave:
- TRACE_LEAVE(QUIC_EV_CONN_LPKT, qc);
- return ret_cs;
-
- err:
- pool_free(pool_head_quic_cstream, cs);
- goto leave;
-}
-
/* Callback called upon loss detection and PTO timer expirations. */
struct task *qc_process_timer(struct task *task, void *ctx, unsigned int state)
{
#include <haproxy/pool.h>
#include <haproxy/quic_ack.h>
#include <haproxy/quic_conn.h>
+#include <haproxy/quic_rx.h>
+#include <haproxy/quic_stream.h>
DECLARE_POOL(pool_head_quic_enc_level, "quic_enc_level", sizeof(struct quic_enc_level));
DECLARE_POOL(pool_head_quic_tls_key, "quic_tls_key", QUIC_TLS_KEY_LEN);
DECLARE_POOL(pool_head_quic_crypto_buf, "quic_crypto_buf", sizeof(struct quic_crypto_buf));
+DECLARE_STATIC_POOL(pool_head_quic_cstream, "quic_cstream", sizeof(struct quic_cstream));
/* Initial salt depending on QUIC version to derive client/server initial secrets.
* This one is for draft-29 QUIC version.
chunk_appendf(buf, "%02x", secret[i]);
}
+/* Release the memory allocated for <cs> CRYPTO stream */
+void quic_cstream_free(struct quic_cstream *cs)
+{
+ if (!cs) {
+ /* This is the case for ORTT encryption level */
+ return;
+ }
+
+ quic_free_ncbuf(&cs->rx.ncbuf);
+
+ qc_stream_desc_release(cs->desc);
+ pool_free(pool_head_quic_cstream, cs);
+}
+
+/* Allocate a new QUIC stream for <qc>.
+ * Return it if succeeded, NULL if not.
+ */
+struct quic_cstream *quic_cstream_new(struct quic_conn *qc)
+{
+ struct quic_cstream *cs, *ret_cs = NULL;
+
+ TRACE_ENTER(QUIC_EV_CONN_LPKT, qc);
+ cs = pool_alloc(pool_head_quic_cstream);
+ if (!cs) {
+ TRACE_ERROR("crypto stream allocation failed", QUIC_EV_CONN_INIT, qc);
+ goto leave;
+ }
+
+ cs->rx.offset = 0;
+ cs->rx.ncbuf = NCBUF_NULL;
+ cs->rx.offset = 0;
+
+ cs->tx.offset = 0;
+ cs->tx.sent_offset = 0;
+ cs->tx.buf = BUF_NULL;
+ cs->desc = qc_stream_desc_new((uint64_t)-1, -1, cs, qc);
+ if (!cs->desc) {
+ TRACE_ERROR("crypto stream allocation failed", QUIC_EV_CONN_INIT, qc);
+ goto err;
+ }
+
+ ret_cs = cs;
+ leave:
+ TRACE_LEAVE(QUIC_EV_CONN_LPKT, qc);
+ return ret_cs;
+
+ err:
+ pool_free(pool_head_quic_cstream, cs);
+ goto leave;
+}
+
/* Uninitialize <qel> QUIC encryption level. Never fails. */
void quic_conn_enc_level_uninit(struct quic_conn *qc, struct quic_enc_level *qel)
{