]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: xprt_qmux: define default value for get_alpn
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 29 Apr 2026 13:09:38 +0000 (15:09 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 21 May 2026 13:09:10 +0000 (15:09 +0200)
Extend get_alpn() for xprt_qmux layer. If lower layer does not implement
ALPN negotiation, return a statically default protocol value. Currently
this is set to "h3".

This change is required to support QMux in clear without SSL. In the
future, it could be useful to configure the default protocol, for
example by extending the syntax for the "proto" keyword.

src/xprt_qmux.c

index 88f4b0120faa15439990c4f40cbd112892a0ad9c..4060ec566e14c31c93116d7e9613516a265c0c0b 100644 (file)
@@ -12,6 +12,9 @@
 #include <haproxy/quic_frame.h>
 #include <haproxy/quic_tp-t.h>
 
+/* Default protocol when not running over SSL layer. */
+#define XPRT_QMUX_DEFAULT_ALPN  "h3"
+
 struct xprt_qmux_ctx {
        struct connection *conn;
        struct wait_event wait_event;
@@ -346,6 +349,14 @@ static int xprt_qmux_get_alpn(const struct connection *conn, void *xprt_ctx,
                               const char **str, int *len)
 {
        struct xprt_qmux_ctx *ctx = xprt_ctx;
+
+       /* Return a the default ALPN if lower layer is not able to negotiate it. */
+       if (!ctx->ops_lower || !ctx->ops_lower->get_alpn) {
+               *str = XPRT_QMUX_DEFAULT_ALPN;
+               *len = strlen(XPRT_QMUX_DEFAULT_ALPN);
+               return 1;
+       }
+
        return ctx->ops_lower->get_alpn(conn, ctx->ctx_lower, str, len);
 }