From: Willy Tarreau Date: Thu, 12 Jan 2023 18:42:48 +0000 (+0100) Subject: MINOR: listener: move the DEF_ACCEPT option to the bind_conf X-Git-Tag: v2.8-dev3~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9b4d21248be9996ff23a25e576669bc24b22371;p=thirdparty%2Fhaproxy.git MINOR: listener: move the DEF_ACCEPT option to the bind_conf 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. --- diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index ecddebcec4..6c0c6844c6 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -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 */ diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c index c46a126c7a..179f210e6f 100644 --- a/src/cfgparse-tcp.c +++ b/src/cfgparse-tcp.c @@ -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 diff --git a/src/proto_tcp.c b/src/proto_tcp.c index d0850bdb62..662e669db0 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -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");