MINOR: connection: define conn_select_mux_fe()

Define a new function conn_select_mux_fe().

The objective is to have a preliminary function to determine the MUX
which will be used without initializing it. This will be useful for MUX
which relies on a specific XPRT handshake prior to its startup, which is
the case for QMux protocol.

The code of conn_select_mux_fe() is identical to the beginning of
conn_install_mux_fe() with a similar MUX selection logic. However,
connection MUX initialization is not performed in this case. In a future
patch, both functions should be merged together to reduce code
duplication.
This commit is contained in:
Amaury Denoyelle 2026-05-18 16:57:05 +02:00
parent 6aab6d4e98
commit 86ffbaa0f5
2 changed files with 24 additions and 0 deletions

View file

@ -86,6 +86,7 @@ int conn_create_mux(struct connection *conn, int *closed_connection);
int conn_notify_mux(struct connection *conn, int old_flags, int forced_wake);
int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct buffer *buf,
struct ist mux_proto, int mode);
const struct mux_proto_list *conn_select_mux_fe(const struct connection *conn);
int conn_install_mux_fe(struct connection *conn, void *ctx);
int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess,
const struct mux_ops *force_mux_ops);

View file

@ -319,6 +319,29 @@ int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct buffer *buf,
return 0;
}
/* Returns the mux_proto_list entry compatible with <conn> frontend connection
* or NULL if nothing eligible.
* TODO duplicate code to merge with conn_install_mux_fe().
*/
const struct mux_proto_list *conn_select_mux_fe(const struct connection *conn)
{
struct bind_conf *bind_conf;
const char *alpn_str = NULL;
struct ist alpn;
int alpn_len = 0, mode;
bind_conf = __objt_listener(conn->target)->bind_conf;
if (bind_conf->mux_proto)
return bind_conf->mux_proto;
mode = conn_pr_mode_to_proto_mode(bind_conf->frontend->mode);
conn_get_alpn(conn, &alpn_str, &alpn_len);
alpn = ist2(alpn_str, alpn_len);
return conn_get_best_mux_entry(IST_NULL, alpn, PROTO_SIDE_FE,
proto_is_quic(conn->ctrl), mode);
}
/* installs the best mux for incoming connection <conn> using the upper context
* <ctx>. If the mux protocol is forced, we use it to find the best
* mux. Otherwise we use the ALPN name, if any. Returns < 0 on error.