diff --git a/include/haproxy/xprt_quic.h b/include/haproxy/xprt_quic.h index 2c98ed602..dc90f3d20 100644 --- a/include/haproxy/xprt_quic.h +++ b/include/haproxy/xprt_quic.h @@ -179,49 +179,6 @@ static inline void quic_pin_cid_to_tid(unsigned char *cid, int target_tid) cid[0] = cid[0] - (cid[0] % global.nbthread) + target_tid; } -/* Allocate a new CID with as sequence number and attach it to - * ebtree. - * - * The CID is randomly generated in part with the result altered to be - * associated with the current thread ID. This means this function must only - * be called by the quic_conn thread. - * - * Returns the new CID if succeeded, NULL if not. - */ -static inline struct quic_connection_id *new_quic_cid(struct eb_root *root, - struct quic_conn *qc, - int seq_num) -{ - struct quic_connection_id *cid; - - cid = pool_alloc(pool_head_quic_connection_id); - if (!cid) - return NULL; - - cid->cid.len = QUIC_HAP_CID_LEN; - if (RAND_bytes(cid->cid.data, cid->cid.len) != 1 || - RAND_bytes(cid->stateless_reset_token, - sizeof cid->stateless_reset_token) != 1) { - fprintf(stderr, "Could not generate %d random bytes\n", cid->cid.len); - goto err; - } - - quic_pin_cid_to_tid(cid->cid.data, tid); - - cid->qc = qc; - - cid->seq_num.key = seq_num; - cid->retire_prior_to = 0; - /* insert the allocated CID in the quic_conn tree */ - eb64_insert(root, &cid->seq_num); - - return cid; - - err: - pool_free(pool_head_quic_connection_id, cid); - return NULL; -} - /* The maximum size of a variable-length QUIC integer encoded with 1 byte */ #define QUIC_VARINT_1_BYTE_MAX ((1UL << 6) - 1) /* The maximum size of a variable-length QUIC integer encoded with 2 bytes */ diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 66c3555a4..0d598ce46 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -3262,6 +3262,49 @@ int qc_send_ppkts(struct qring *qr, struct ssl_sock_ctx *ctx) return 1; } +/* Allocate a new CID with as sequence number and attach it to + * ebtree. + * + * The CID is randomly generated in part with the result altered to be + * associated with the current thread ID. This means this function must only + * be called by the quic_conn thread. + * + * Returns the new CID if succeeded, NULL if not. + */ +static struct quic_connection_id *new_quic_cid(struct eb_root *root, + struct quic_conn *qc, + int seq_num) +{ + struct quic_connection_id *cid; + + cid = pool_alloc(pool_head_quic_connection_id); + if (!cid) + return NULL; + + cid->cid.len = QUIC_HAP_CID_LEN; + if (RAND_bytes(cid->cid.data, cid->cid.len) != 1 || + RAND_bytes(cid->stateless_reset_token, + sizeof cid->stateless_reset_token) != 1) { + fprintf(stderr, "Could not generate %d random bytes\n", cid->cid.len); + goto err; + } + + quic_pin_cid_to_tid(cid->cid.data, tid); + + cid->qc = qc; + + cid->seq_num.key = seq_num; + cid->retire_prior_to = 0; + /* insert the allocated CID in the quic_conn tree */ + eb64_insert(root, &cid->seq_num); + + return cid; + + err: + pool_free(pool_head_quic_connection_id, cid); + return NULL; +} + /* Build all the frames which must be sent just after the handshake have succeeded. * This is essentially NEW_CONNECTION_ID frames. A QUIC server must also send * a HANDSHAKE_DONE frame.