Skip to content

Commit

Permalink
Remove debugging code
Browse files Browse the repository at this point in the history
Remove `getsockopt()` calls introduced in adrienverge#799 to investigate the
possible relation of TCP keep-alives with random disconnections.

The retrieved values did not help, they only confuse us. I believe
everything happens at the PPP level, with options `lcp-echo-interval`
and `lcp-echo-failure`.
  • Loading branch information
DimitriPapadopoulos committed Dec 24, 2023
1 parent de959f4 commit 00aab83
Showing 1 changed file with 0 additions and 68 deletions.
68 changes: 0 additions & 68 deletions src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,6 @@ static int get_gateway_host_ip(struct tunnel *tunnel)
return 0;
}

static int get_socket_option(int sockfd, int level, int optname)
{
int optval;
socklen_t optlen = sizeof(optval);

if (getsockopt(sockfd, level, optname, &optval, &optlen) < 0)
return -1;
assert(optlen == sizeof(optval));
return optval;
}

/*
* Establish a regular TCP connection.
*/
Expand All @@ -654,63 +643,6 @@ static int tcp_connect(struct tunnel *tunnel)
goto err_socket;
}

/*
* Attempt to find default TCP socket options on different platforms.
*/
#ifdef SO_KEEPALIVE
ret = get_socket_option(handle, SOL_SOCKET, SO_KEEPALIVE);
if (ret < 0)
log_warn("getsockopt: %s: %s\n", "SO_KEEPALIVE", strerror(errno));
else
log_debug("SO_KEEPALIVE: %s\n", (ret ? "ON" : "OFF"));
#endif
#ifdef TCP_KEEPIDLE
ret = get_socket_option(handle, IPPROTO_TCP, TCP_KEEPIDLE);
if (ret < 0)
log_warn("getsockopt: %s: %s\n", "TCP_KEEPIDLE", strerror(errno));
else
log_debug("TCP_KEEPIDLE: %d\n", ret);
#endif
#ifdef TCP_KEEPALIVE
ret = get_socket_option(handle, IPPROTO_TCP, TCP_KEEPALIVE);
if (ret < 0)
log_warn("getsockopt: %s: %s\n", "TCP_KEEPALIVE", strerror(errno));
else
log_debug("TCP_KEEPALIVE: %d\n", ret);
#endif
#ifdef TCP_KEEPINTVL
ret = get_socket_option(handle, IPPROTO_TCP, TCP_KEEPINTVL);
if (ret < 0)
log_warn("getsockopt: %s: %s\n", "TCP_KEEPINTVL", strerror(errno));
else
log_debug("TCP_KEEPINTVL: %d\n", ret);
#endif
#ifdef TCP_KEEPCNT
ret = get_socket_option(handle, IPPROTO_TCP, TCP_KEEPCNT);
if (ret < 0)
log_warn("getsockopt: %s: %s\n", "TCP_KEEPCNT", strerror(errno));
else
log_debug("TCP_KEEPCNT: %d\n", ret);
#endif
#ifdef SO_SNDBUF
ret = get_socket_option(handle, SOL_SOCKET, SO_SNDBUF);
if (ret < 0)
#ifndef __APPLE__
log_warn("getsockopt: %s: %s\n", "SO_SNDBUF", strerror(errno));
else
#endif
log_debug("SO_SNDBUF: %d\n", ret);
#endif
#ifdef SO_RCVBUF
ret = get_socket_option(handle, SOL_SOCKET, SO_RCVBUF);
if (ret < 0)
#ifndef __APPLE__
log_warn("getsockopt: %s: %s\n", "SO_RCVBUF", strerror(errno));
else
#endif
log_debug("SO_RCVBUF: %d\n", ret);
#endif

if (iface_len == IF_NAMESIZE) {
log_error("socket: Too long iface name\n");
goto err_post_socket;
Expand Down

0 comments on commit 00aab83

Please sign in to comment.