From 91b780a4553031b28796dd47b54eb58a7a1826fa Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 20 May 2022 16:15:01 +0200 Subject: [PATCH] CLEANUP: listener: store stream vs dgram at the bind_conf level Let's collect the set of xprt-level and sock-level dgram/stream protocols seen on a bind line and store that in the bind_conf itself while they're being parsed. This will make it much easier to detect incompatibilities later than the current approch which consists in scanning all listeners in post-parsing. --- include/haproxy/listener-t.h | 4 ++++ src/cfgparse.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 6f4ae2fadb..c712504c4d 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -117,6 +117,10 @@ enum li_status { #define BC_O_USE_SSL 0x00000001 /* SSL is being used on this bind_conf */ #define BC_O_GENERATE_CERTS 0x00000002 /* 1 if generate-certificates option is set, else 0 */ #define BC_O_QUIC_FORCE_RETRY 0x00000004 /* always send Retry on reception of Initial without token */ +#define BC_O_USE_SOCK_DGRAM 0x00000008 /* at least one datagram-type listener is used */ +#define BC_O_USE_SOCK_STREAM 0x00000010 /* at least one stream-type listener is used */ +#define BC_O_USE_XPRT_DGRAM 0x00000020 /* at least one dgram-only xprt listener is used */ +#define BC_O_USE_XPRT_STREAM 0x00000040 /* at least one stream-only xprt listener is used */ /* flags used with bind_conf->ssl_options */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 9def9b96e0..d48efac9c8 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -155,6 +155,15 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, goto fail; /* OK the address looks correct */ + if (proto->proto_type == PROTO_TYPE_DGRAM) + bind_conf->options |= BC_O_USE_SOCK_DGRAM; + else + bind_conf->options |= BC_O_USE_SOCK_STREAM; + + if (proto->xprt_type == PROTO_TYPE_DGRAM) + bind_conf->options |= BC_O_USE_XPRT_DGRAM; + else + bind_conf->options |= BC_O_USE_XPRT_STREAM; #ifdef USE_QUIC /* The transport layer automatically switches to QUIC when QUIC -- 2.47.3