From cae828cbf5116e5b4a603bcc2522fcdd1db207d3 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 5 Aug 2025 10:18:42 +0200 Subject: [PATCH] MINOR: quic: define QUIC_FL_CONN_IS_BACK flag Define a new quic_conn flag assign if the connection is used on the backend side. This is similar to other haproxy components such as struct connection and muxes element. This flag is positionned via qc_new_conn(). Also update quic traces to mark proxy side as 'F' or 'B' suffix. --- include/haproxy/quic_conn-t.h | 5 +++-- include/haproxy/quic_conn.h | 6 ++++++ src/quic_conn.c | 2 +- src/quic_trace.c | 5 +++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index 98434416d..a4c294be1 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -448,7 +448,7 @@ struct quic_conn_closed { #define QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED (1U << 0) #define QUIC_FL_CONN_SPIN_BIT (1U << 1) /* Spin bit set by remote peer */ #define QUIC_FL_CONN_NEED_POST_HANDSHAKE_FRMS (1U << 2) /* HANDSHAKE_DONE must be sent */ -/* gap here */ +#define QUIC_FL_CONN_IS_BACK (1U << 3) /* conn used on backend side */ #define QUIC_FL_CONN_ACCEPT_REGISTERED (1U << 4) #define QUIC_FL_CONN_UDP_GSO_EIO (1U << 5) /* GSO disabled due to a EIO occured on same listener */ #define QUIC_FL_CONN_IDLE_TIMER_RESTARTED_AFTER_READ (1U << 6) @@ -488,6 +488,7 @@ static forceinline char *qc_show_flags(char *buf, size_t len, const char *delim, _(QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED, _(QUIC_FL_CONN_SPIN_BIT, _(QUIC_FL_CONN_NEED_POST_HANDSHAKE_FRMS, + _(QUIC_FL_CONN_IS_BACK, _(QUIC_FL_CONN_ACCEPT_REGISTERED, _(QUIC_FL_CONN_UDP_GSO_EIO, _(QUIC_FL_CONN_IDLE_TIMER_RESTARTED_AFTER_READ, @@ -508,7 +509,7 @@ static forceinline char *qc_show_flags(char *buf, size_t len, const char *delim, _(QUIC_FL_CONN_EXP_TIMER, _(QUIC_FL_CONN_CLOSING, _(QUIC_FL_CONN_DRAINING, - _(QUIC_FL_CONN_IMMEDIATE_CLOSE)))))))))))))))))))))))); + _(QUIC_FL_CONN_IMMEDIATE_CLOSE))))))))))))))))))))))))); /* epilogue */ _(~0U); return buf; diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h index 7e6adf51d..56367f1b4 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -82,6 +82,12 @@ void qc_check_close_on_released_mux(struct quic_conn *qc); int quic_stateless_reset_token_cpy(unsigned char *pos, size_t len, const unsigned char *salt, size_t saltlen); +/* Returns true if is used on the backed side (as a client). */ +static inline int qc_is_back(const struct quic_conn *qc) +{ + return qc->flags & QUIC_FL_CONN_IS_BACK; +} + /* Free the CIDs attached to QUIC connection. */ static inline void free_quic_conn_cids(struct quic_conn *conn) { diff --git a/src/quic_conn.c b/src/quic_conn.c index 874f7ecb4..2917ad062 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -1198,7 +1198,7 @@ struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4, else { struct quic_connection_id *conn_cid = NULL; - qc->flags = QUIC_FL_CONN_PEER_VALIDATED_ADDR; + qc->flags = QUIC_FL_CONN_IS_BACK|QUIC_FL_CONN_PEER_VALIDATED_ADDR; qc->state = QUIC_HS_ST_CLIENT_INITIAL; /* This is the original connection ID from the peer server diff --git a/src/quic_trace.c b/src/quic_trace.c index c8fe5524b..6fa260df6 100644 --- a/src/quic_trace.c +++ b/src/quic_trace.c @@ -115,8 +115,9 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace if (qc) { const struct quic_tls_ctx *tls_ctx; - chunk_appendf(&trace_buf, " : qc@%p idle_timer_task@%p flags=0x%x", - qc, qc->idle_timer_task, qc->flags); + chunk_appendf(&trace_buf, " : qc@%p(%c) idle_timer_task@%p flags=0x%x", + qc, (qc->flags & QUIC_FL_CONN_IS_BACK) ? 'B' : 'F', + qc->idle_timer_task, qc->flags); if (mask & QUIC_EV_CONN_NEW) { const int *ssl_err = a2;