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.
This commit is contained in:
Willy Tarreau 2023-01-12 19:42:48 +01:00
parent 9bdcf42922
commit d9b4d21248
3 changed files with 5 additions and 10 deletions

View 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 */

View 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

View 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");