From c492f1b17f0b13a353eeac44e28f4e3bfd0c8561 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 12 Jan 2023 19:45:58 +0100 Subject: [PATCH] MINOR: listener: move TCP_FO to bind_conf It's set per bind line ("tfo") and only used in tcp_bind_listener() so there's no point keeping the address family tests, let's just store the flag in the bind_conf under the name BC_O_TCP_FO. --- include/haproxy/listener-t.h | 3 ++- src/cfgparse-tcp.c | 8 +------- src/proto_tcp.c | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 6c0c6844c..9e180ad4e 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -101,7 +101,7 @@ enum li_status { /* unused 0x0040 */ #define LI_O_ACC_PROXY 0x0080 /* find the proxied address in the first request line */ #define LI_O_UNLIMITED 0x0100 /* listener not subject to global limits (peers & stats socket) */ -#define LI_O_TCP_FO 0x0200 /* enable TCP Fast Open (linux >= 3.7) */ +/* unused 0x0200 */ /* unused 0x0400 */ /* unused 0x0800 */ #define LI_O_ACC_CIP 0x1000 /* find the proxied address in the NetScaler Client IP header */ @@ -124,6 +124,7 @@ enum li_status { #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 */ +#define BC_O_TCP_FO 0x00000400 /* enable TCP Fast Open (linux >= 3.7) */ /* flags used with bind_conf->ssl_options */ diff --git a/src/cfgparse-tcp.c b/src/cfgparse-tcp.c index 179f210e6..d753e64e5 100644 --- a/src/cfgparse-tcp.c +++ b/src/cfgparse-tcp.c @@ -73,13 +73,7 @@ static int bind_parse_defer_accept(char **args, int cur_arg, struct proxy *px, s /* parse the "tfo" bind keyword */ static int bind_parse_tfo(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_TCP_FO; - } - + conf->options |= BC_O_TCP_FO; return 0; } #endif diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 662e669db..7a8d83070 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -670,7 +670,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) sizeof(zero)); #endif #if defined(TCP_FASTOPEN) - if (listener->options & LI_O_TCP_FO) { + if (listener->bind_conf->options & BC_O_TCP_FO) { /* TFO needs a queue length, let's use the configured backlog */ int qlen = listener_backlog(listener); if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)) == -1) {