From: Amaury Denoyelle Date: Tue, 3 Mar 2026 08:45:22 +0000 (+0100) Subject: MINOR: mux-quic: add function for ALPN to app-ops conversion X-Git-Tag: v3.4-dev6~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9c7cf1c68490610283811a0ef9aeec6accc6546d;p=thirdparty%2Fhaproxy.git MINOR: mux-quic: add function for ALPN to app-ops conversion Extract the conversion from ALPN to qcc_app_ops type from quic_conn source file into QUIC MUX. The newly created function is named quic_alpn_to_app_ops(). This will serve as a central point to identify which ALPNs are currently supported in our QUIC stack. This patch is purely a small refactoring. It will be useful for the next one which rework MUX app-ops layer init. The current cleanup allows notably to remove H3/hq-interop headers from quic_conn source file. --- diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index d0b7fac81..b44ec2d6b 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -12,6 +12,9 @@ #include #include +#include +#include + #define qcc_report_glitch(qcc, inc, ...) ({ \ COUNT_GLITCH(__VA_ARGS__); \ _qcc_report_glitch(qcc, inc); \ @@ -115,6 +118,16 @@ void qcc_show_quic(struct qcc *qcc); void qcc_wakeup(struct qcc *qcc); +static inline const struct qcc_app_ops *quic_alpn_to_app_ops(const char *alpn, int alpn_len) +{ + if (alpn_len >= 2 && memcmp(alpn, "h3", 2) == 0) + return &h3_ops; + else if (alpn_len >= 10 && memcmp(alpn, "hq-interop", 10) == 0) + return &hq_interop_ops; + + return NULL; +} + #endif /* USE_QUIC */ #endif /* _HAPROXY_MUX_QUIC_H */ diff --git a/src/quic_conn.c b/src/quic_conn.c index 6143fce39..2d87a42a9 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -38,8 +38,6 @@ #include #include #include -#include -#include #include #include #include @@ -274,14 +272,11 @@ void quic_set_tls_alert(struct quic_conn *qc, int alert) */ int quic_set_app_ops(struct quic_conn *qc, const char *alpn, int alpn_len) { - if (alpn_len >= 2 && memcmp(alpn, "h3", 2) == 0) - qc->app_ops = &h3_ops; - else if (alpn_len >= 10 && memcmp(alpn, "hq-interop", 10) == 0) - qc->app_ops = &hq_interop_ops; - else + if (!(qc->app_ops = quic_alpn_to_app_ops(alpn, alpn_len))) return 0; return 1; + } /* Try to reuse ALPN and early transport parameters.