]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: move the DEF_ACCEPT option to the bind_conf
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 18:42:48 +0000 (19:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Feb 2023 17:00:20 +0000 (18:00 +0100)
This option is set per bind line, and was only set stored when the
address family is AF_INET4 or AF_INET6. That's pointless since it's
used only in tcp_bind_listener() which is only used for such families
as well, so it can now be moved to the bind_conf under the name
BC_O_DEF_ACCEPT.

include/haproxy/listener-t.h
src/cfgparse-tcp.c
src/proto_tcp.c

index ecddebcec4500b59f79a074ff8ec927d57133ea3..6c0c6844c67cba097a7d78fc40b0426fd47cd328 100644 (file)
@@ -95,7 +95,7 @@ enum li_status {
 /* unused                       0x0001  */
 /* unused                       0x0002  */
 /* unused                       0x0004  */
-#define LI_O_DEF_ACCEPT         0x0008  /* wait up to 1 second for data before accepting */
+/* unused                       0x0008  */
 #define LI_O_TCP_L4_RULES       0x0010  /* run TCP L4 rules checks on the incoming connection */
 #define LI_O_TCP_L5_RULES       0x0020  /* run TCP L5 rules checks on the incoming session */
 /* unused                       0x0040  */
@@ -123,6 +123,7 @@ enum li_status {
 #define BC_O_USE_XPRT_STREAM    0x00000040 /* at least one stream-only xprt listener is used */
 #define BC_O_NOLINGER           0x00000080 /* disable lingering on these listeners */
 #define BC_O_NOQUICKACK         0x00000100 /* disable quick ack of immediate data (linux) */
+#define BC_O_DEF_ACCEPT         0x00000200 /* wait up to 1 second for data before accepting */
 
 
 /* flags used with bind_conf->ssl_options */
index c46a126c7a4ec25947f64bd3ebafd3c9c6e4ecb6..179f210e6f2c2c559faef2139f9c8e41717de4c5 100644 (file)
@@ -64,13 +64,7 @@ static int bind_parse_transparent(char **args, int cur_arg, struct proxy *px, st
 /* parse the "defer-accept" bind keyword */
 static int bind_parse_defer_accept(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
-       struct listener *l;
-
-       list_for_each_entry(l, &conf->listeners, by_bind) {
-               if (l->rx.addr.ss_family == AF_INET || l->rx.addr.ss_family == AF_INET6)
-                       l->options |= LI_O_DEF_ACCEPT;
-       }
-
+       conf->options |= BC_O_DEF_ACCEPT;
        return 0;
 }
 #endif
index d0850bdb62a022fa3329762fce6c4387b47b3305..662e669db021544aa14e107cc738284f5f685473 100644 (file)
@@ -658,7 +658,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
                    sizeof(zero));
 #endif
 #if defined(TCP_DEFER_ACCEPT)
-       if (listener->options & LI_O_DEF_ACCEPT) {
+       if (listener->bind_conf->options & BC_O_DEF_ACCEPT) {
                /* defer accept by up to one second */
                int accept_delay = 1;
                if (setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &accept_delay, sizeof(accept_delay)) == -1) {
@@ -706,7 +706,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 
 #if !defined(TCP_DEFER_ACCEPT) && defined(SO_ACCEPTFILTER)
        /* the socket needs to listen first */
-       if (listener->options & LI_O_DEF_ACCEPT) {
+       if (listener->bind_conf->options & BC_O_DEF_ACCEPT) {
                struct accept_filter_arg accept;
                memset(&accept, 0, sizeof(accept));
                strcpy(accept.af_name, "dataready");