]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] add support for SO_REUSEPORT on Linux
authorWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2006 00:22:38 +0000 (01:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2006 00:22:38 +0000 (01:22 +0100)
SO_REUSEPORT does not exist on Linux but the checks are available in
the code. With a little patch, it's possible to implement the feature,
but the value of SO_REUSEPORT will still have to be known from userland.
This patch adds a workaround to this problem by figuring out the value
for the one used by SO_REUSEADDR.

include/common/compat.h

index 58908d79a915ecc00682a5ea3829018d2d44aac0..8261f8f9820ac0f4cf5bf8e451f31c4630a72b81 100644 (file)
 #include <linux/netfilter_ipv4.h>
 #endif
 
+/* We'll try to enable SO_REUSEPORT on Linux 2.4 and 2.6 if not defined.
+ * There are two families of values depending on the architecture. Those
+ * are at least valid on Linux 2.4 and 2.6, reason why we'll rely on the
+ * NETFILTER define.
+ */
+#if !defined(SO_REUSEPORT) && defined(NETFILTER)
+#if    (SO_REUSEADDR == 2)
+#define SO_REUSEPORT 15
+#elif  (SO_REUSEADDR == 0x0004)
+#define SO_REUSEPORT 0x0200
+#endif /* SO_REUSEADDR */
+#endif /* SO_REUSEPORT */
+
 #if defined(__dietlibc__)
 #include <strings.h>
 #endif