Fix: Use SOL_SOCKET level for SO_KEEPALIVE on all platform
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 21 Feb 2018 21:59:54 +0000 (16:59 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 26 Feb 2018 22:48:37 +0000 (17:48 -0500)
On Linux, COMPAT_SOCKET_LEVEL was set to SOL_TCP instead
of SOL_SOCKET, this resulted in execution of:
    setsockopt(..., SOL_TCP, TCP_DEFER_ACCEPT, ...)

Instead of:
    setsockopt(..., SOL_SOCKET, SO_KEEPALIVE, ...)

Hence, TCP keep alive was not enabled.

COMPAT_SOCKET_LEVEL is not needed. All platforms supported use the
SOL_SOCKET level for SO_KEEPALIVE.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/tcp_keep_alive.c

index 4a2cd9f1bd84d8427db624c5d66a22c598489594..469bec31d19c5f8b8ceada265bdc6b1b1c0315f9 100644 (file)
@@ -36,7 +36,6 @@
 /* Per-platform definitions of TCP socket options. */
 #if defined (__linux__)
 
-#define COMPAT_SOCKET_LEVEL SOL_TCP
 #define COMPAT_TCP_LEVEL SOL_TCP
 #define COMPAT_TCP_ABORT_THRESHOLD 0 /* Does not exist on linux. */
 #define COMPAT_TCP_KEEPIDLE TCP_KEEPIDLE
@@ -45,7 +44,6 @@
 
 #elif defined (__sun__) /* ! defined (__linux__) */
 
-#define COMPAT_SOCKET_LEVEL SOL_SOCKET
 #define COMPAT_TCP_LEVEL IPPROTO_TCP
 
 #ifdef TCP_KEEPALIVE_THRESHOLD
@@ -65,7 +63,6 @@
 
 #else /* ! defined (__linux__) && ! defined (__sun__) */
 
-#define COMPAT_SOCKET_LEVEL 0
 #define COMPAT_TCP_LEVEL 0
 #define COMPAT_TCP_ABORT_THRESHOLD 0
 #define COMPAT_TCP_KEEPIDLE 0
@@ -547,7 +544,7 @@ int socket_apply_keep_alive_config(int socket_fd)
                goto end;
        }
 
-       ret = setsockopt(socket_fd, COMPAT_SOCKET_LEVEL, SO_KEEPALIVE, &val,
+       ret = setsockopt(socket_fd, SOL_SOCKET, SO_KEEPALIVE, &val,
                        sizeof(val));
        if (ret < 0) {
                PERROR("setsockopt so_keepalive");
This page took 0.027006 seconds and 4 git commands to generate.