mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
MINOR: server: support QUIC for dynamic servers
To properly support QUIC for dynamic servers, it is required to extend add server CLI handler : * ensure conformity between server address and proto * automatically set proto to QUIC if not specified * prepare_srv callback must be called to initialize required SSL context Prior to this patch, crashes may occur when trying to use QUIC with dynamic servers. Also, destroy_srv callback must be called when a dynamic server is deallocated. This ensures that there is no memory leak due to SSL context. No need to backport.
This commit is contained in:
parent
626cfd85aa
commit
42365f53e8
24
src/server.c
24
src/server.c
@ -3131,6 +3131,8 @@ void srv_free_params(struct server *srv)
|
||||
|
||||
if (xprt_get(XPRT_SSL) && xprt_get(XPRT_SSL)->destroy_srv)
|
||||
xprt_get(XPRT_SSL)->destroy_srv(srv);
|
||||
else if (xprt_get(XPRT_QUIC) && xprt_get(XPRT_QUIC)->destroy_srv)
|
||||
xprt_get(XPRT_QUIC)->destroy_srv(srv);
|
||||
|
||||
while (!LIST_ISEMPTY(&srv->pp_tlvs)) {
|
||||
srv_tlv = LIST_ELEM(srv->pp_tlvs.n, struct srv_pp_tlv_list *, list);
|
||||
@ -6070,6 +6072,14 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
*/
|
||||
srv->init_addr_methods = SRV_IADDR_NONE;
|
||||
|
||||
if (!srv->mux_proto && srv_is_quic(srv)) {
|
||||
/* Force QUIC as mux-proto on server with quic addresses.
|
||||
* Incompatibilities with TCP proxy mode will be catch by the
|
||||
* next code block.
|
||||
*/
|
||||
srv->mux_proto = get_mux_proto(ist("quic"));
|
||||
}
|
||||
|
||||
if (srv->mux_proto) {
|
||||
int proto_mode = conn_pr_mode_to_proto_mode(be->mode);
|
||||
const struct mux_proto_list *mux_ent;
|
||||
@ -6080,6 +6090,16 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
ha_alert("MUX protocol is not usable for server.\n");
|
||||
goto out;
|
||||
}
|
||||
else {
|
||||
if ((mux_ent->mux->flags & MX_FL_FRAMED) && !srv_is_quic(srv)) {
|
||||
ha_alert("MUX protocol is incompatible with stream transport used by server.\n");
|
||||
goto out;
|
||||
}
|
||||
else if (!(mux_ent->mux->flags & MX_FL_FRAMED) && srv_is_quic(srv)) {
|
||||
ha_alert("MUX protocol is incompatible with framed transport used by server.\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!srv_alloc_lb(srv, be)) {
|
||||
@ -6103,6 +6123,10 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
if (xprt_get(XPRT_SSL)->prepare_srv(srv))
|
||||
goto out;
|
||||
}
|
||||
else if (xprt_get(XPRT_QUIC) && xprt_get(XPRT_QUIC)->prepare_srv) {
|
||||
if (xprt_get(XPRT_QUIC)->prepare_srv(srv))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (srv->trackit) {
|
||||
|
Loading…
Reference in New Issue
Block a user