Merge client TFO setting

This commit is contained in:
yrutschle 2019-03-10 09:39:48 +01:00
commit ff91f94315
2 changed files with 9 additions and 1 deletions

View File

@ -277,6 +277,11 @@ int connect_addr(struct connection *cnx, int fd_from)
log_message(LOG_ERR, "forward to %s failed:socket: %s\n",
cnx->proto->name, strerror(errno));
} else {
one = 1;
// indicate desire to use TCP Fast Open
setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &one, sizeof(one));
// no need to check return value; if it's not supported, that's okay
if (cfg.transparent) {
res = bind_peer(fd, fd_from);
CHECK_RES_RETURN(res, "bind_peer");
@ -288,7 +293,6 @@ int connect_addr(struct connection *cnx, int fd_from)
close(fd);
} else {
if (cnx->proto->keepalive) {
one = 1;
res = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&one, sizeof(one));
CHECK_RES_RETURN(res, "setsockopt(SO_KEEPALIVE)");
}

View File

@ -67,6 +67,10 @@
#define IP_FREEBIND 0
#endif
#ifndef TCP_FASTOPEN_CONNECT
#define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect. */
#endif
enum connection_state {
ST_PROBING=1, /* Waiting for timeout to find where to forward */
ST_SHOVELING /* Connexion is established */