/* platform-specific options */
#define GTUNE_USE_SPLICE (1<<4)
#define GTUNE_USE_GAI (1<<5)
-#define GTUNE_USE_REUSEPORT (1<<6)
+/* unused: (1<<6) */
#define GTUNE_RESOLVE_DONTFAIL (1<<7)
#define GTUNE_SOCKET_TRANSFER (1<<8)
#define CONNECT_DELACK_ALWAYS 0x00000004 /* Use a delayed ACK */
#define CONNECT_CAN_USE_TFO 0x00000008 /* We can use TFO for this connection */
+/* Flags for protocol->flags */
+#define PROTO_F_REUSEPORT_SUPPORTED 0x00000001 /* SO_REUSEPORT is supported */
+
/* protocol families define standard functions acting on a given address family
* for a socket implementation, such as AF_INET/PF_INET for example.
*/
#include <haproxy/arg.h>
#include <haproxy/cfgcond.h>
#include <haproxy/global.h>
+#include <haproxy/proto_tcp.h>
#include <haproxy/tools.h>
/* supported condition predicates */
else if (strcmp(str, "GETADDRINFO") == 0)
return !!(global.tune.options & GTUNE_USE_GAI);
else if (strcmp(str, "REUSEPORT") == 0)
- return !!(global.tune.options & GTUNE_USE_REUSEPORT);
+ return !!(proto_tcpv4.flags & PROTO_F_REUSEPORT_SUPPORTED);
else if (strcmp(str, "FAST-FORWARD") == 0)
return !!(global.tune.options & GTUNE_USE_FAST_FWD);
else if (strcmp(str, "SERVER-SSL-VERIFY-NONE") == 0)
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/peers.h>
+#include <haproxy/protocol.h>
#include <haproxy/tools.h>
/* some keywords that are still being parsed using strcmp() and are not
else if (strcmp(args[0], "noreuseport") == 0) {
if (alertif_too_many_args(0, file, linenum, args, &err_code))
goto out;
- global.tune.options &= ~GTUNE_USE_REUSEPORT;
+ protocol_clrf_all(PROTO_F_REUSEPORT_SUPPORTED);
}
else if (strcmp(args[0], "quiet") == 0) {
if (alertif_too_many_args(0, file, linenum, args, &err_code))
#if defined(USE_GETADDRINFO)
global.tune.options |= GTUNE_USE_GAI;
#endif
-#if defined(SO_REUSEPORT)
- global.tune.options |= GTUNE_USE_REUSEPORT;
-#endif
#ifdef USE_THREAD
global.tune.options |= GTUNE_IDLE_POOL_SHARED;
#endif
#endif
#if defined(SO_REUSEPORT)
else if (*flag == 'd' && flag[1] == 'R')
- global.tune.options &= ~GTUNE_USE_REUSEPORT;
+ protocol_clrf_all(PROTO_F_REUSEPORT_SUPPORTED);
#endif
else if (*flag == 'd' && flag[1] == 'F')
global.tune.options &= ~GTUNE_USE_FAST_FWD;
.default_iocb = quic_lstnr_sock_fd_iocb,
.receivers = LIST_HEAD_INIT(proto_quic4.receivers),
.nb_receivers = 0,
+#ifdef SO_REUSEPORT
+ .flags = PROTO_F_REUSEPORT_SUPPORTED,
+#endif
};
INITCALL1(STG_REGISTER, protocol_register, &proto_quic4);
.default_iocb = quic_lstnr_sock_fd_iocb,
.receivers = LIST_HEAD_INIT(proto_quic6.receivers),
.nb_receivers = 0,
+#ifdef SO_REUSEPORT
+ .flags = PROTO_F_REUSEPORT_SUPPORTED,
+#endif
};
INITCALL1(STG_REGISTER, protocol_register, &proto_quic6);
.default_iocb = sock_accept_iocb,
.receivers = LIST_HEAD_INIT(proto_tcpv4.receivers),
.nb_receivers = 0,
+#ifdef SO_REUSEPORT
+ .flags = PROTO_F_REUSEPORT_SUPPORTED,
+#endif
};
INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
.default_iocb = sock_accept_iocb,
.receivers = LIST_HEAD_INIT(proto_tcpv6.receivers),
.nb_receivers = 0,
+#ifdef SO_REUSEPORT
+ .flags = PROTO_F_REUSEPORT_SUPPORTED,
+#endif
};
INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv6);
.rx_unbind = sock_unbind,
.receivers = LIST_HEAD_INIT(proto_udp4.receivers),
.nb_receivers = 0,
+#ifdef SO_REUSEPORT
+ .flags = PROTO_F_REUSEPORT_SUPPORTED,
+#endif
};
INITCALL1(STG_REGISTER, protocol_register, &proto_udp4);
.rx_unbind = sock_unbind,
.receivers = LIST_HEAD_INIT(proto_udp6.receivers),
.nb_receivers = 0,
+#ifdef SO_REUSEPORT
+ .flags = PROTO_F_REUSEPORT_SUPPORTED,
+#endif
};
INITCALL1(STG_REGISTER, protocol_register, &proto_udp6);
/* OpenBSD and Linux 3.9 support this. As it's present in old libc versions of
* Linux, it might return an error that we will silently ignore.
*/
- if (!ext && (global.tune.options & GTUNE_USE_REUSEPORT))
+ if (!ext && (rx->proto->flags & PROTO_F_REUSEPORT_SUPPORTED))
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
#endif
/* FreeBSD 12 and above use this to load-balance incoming connections.
* This is limited to 256 listeners per group however.
*/
- if (!ext && (global.tune.options & GTUNE_USE_REUSEPORT))
+ if (!ext && (rx->proto->flags & PROTO_F_REUSEPORT_SUPPORTED))
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, &one, sizeof(one));
#endif