]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: add function for ALPN to app-ops conversion
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 3 Mar 2026 08:45:22 +0000 (09:45 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 3 Mar 2026 15:20:16 +0000 (16:20 +0100)
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.

include/haproxy/mux_quic.h
src/quic_conn.c

index d0b7fac81a2b3e6361f0241750da025860ac530a..b44ec2d6b71f1e546cedcbf47c47cf8197ddc593 100644 (file)
@@ -12,6 +12,9 @@
 #include <haproxy/mux_quic-t.h>
 #include <haproxy/stconn.h>
 
+#include <haproxy/h3.h>
+#include <haproxy/hq_interop.h>
+
 #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 */
index 6143fce39d49c6a3f99e4192834a39dfa873aaf9..2d87a42a94ee48c17f7827b900ada45a779298a8 100644 (file)
@@ -38,8 +38,6 @@
 #include <haproxy/freq_ctr.h>
 #include <haproxy/frontend.h>
 #include <haproxy/global.h>
-#include <haproxy/h3.h>
-#include <haproxy/hq_interop.h>
 #include <haproxy/log.h>
 #include <haproxy/mux_quic.h>
 #include <haproxy/ncbuf.h>
@@ -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> ALPN and <etps> early transport parameters.