[lttng-dev] [PATCH lttng-tools] Fix: Use SOL_SOCKET level for SO_KEEPALIVE on all platform

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed Feb 21 16:48:10 EST 2018


----- On Feb 21, 2018, at 4:40 PM, Jonathan Rajotte jonathan.rajotte-julien at efficios.com wrote:

> COMPAT_SOCKET_LEVEL is not needed. Should not have been
> there in the first place.

This changelog is incomplete. It should state that the linux wrapper had a bug:
it mixed up SOL_SOCKET with SOL_TCP, which was causing the issue below:

> 
> On Linux, the setsockopt for SO_KEEPALIVE would result in an actual call
> to:
>    setsockopt(22, SOL_TCP, TCP_DEFER_ACCEPT, [1], 4)
> 

Thanks,

Mathieu

> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
> src/bin/lttng-relayd/tcp_keep_alive.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/bin/lttng-relayd/tcp_keep_alive.c
> b/src/bin/lttng-relayd/tcp_keep_alive.c
> index 4a2cd9f..469bec3 100644
> --- a/src/bin/lttng-relayd/tcp_keep_alive.c
> +++ b/src/bin/lttng-relayd/tcp_keep_alive.c
> @@ -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");
> --
> 2.7.4
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list