]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: listener: store stream vs dgram at the bind_conf level
authorWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 14:15:01 +0000 (16:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 16:41:55 +0000 (18:41 +0200)
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
src/cfgparse.c

index 6f4ae2fadb3f1701f18b1d07ec8b74f732368f89..c712504c4d4af79504e8fbc8ad66a0995f2201cf 100644 (file)
@@ -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 */
index 9def9b96e0d5be28e5bac75246be53ecaa8eafbc..d48efac9c8c844a64a24876f16bd65308f995d67 100644 (file)
@@ -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