From: Willy Tarreau Date: Mon, 13 Nov 2006 00:22:38 +0000 (+0100) Subject: [MEDIUM] add support for SO_REUSEPORT on Linux X-Git-Tag: v1.3.4~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58b2f836851b78029ac5a7803ee8531709cec888;p=thirdparty%2Fhaproxy.git [MEDIUM] add support for SO_REUSEPORT on Linux 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. --- diff --git a/include/common/compat.h b/include/common/compat.h index 58908d79a9..8261f8f982 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -49,6 +49,19 @@ #include #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 #endif