summaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2014-08-14 14:31:47 +0530
committerLennart Poettering <lennart@poettering.net>2014-08-14 13:14:39 +0200
commit9528592ff8d7ff361da430285deba8196e8984d5 (patch)
tree1cbe201fbd1c66e6a8c65ddedc8f7d9b96161c72 /src/core/socket.c
parent41488fe9024a8955d19811620fd55dcc56a5b2ba (diff)
socket: add support for TCP fast Open
TCP Fast Open (TFO) speeds up the opening of successiveTCP) connections between two endpoints.It works by using a TFO cookie in the initial SYN packet to authenticate a previously connected client. It starts sending data to the client before the receipt of the final ACK packet of the three way handshake is received, skipping a round trip and lowering the latency in the start of transmission of data.
Diffstat (limited to 'src/core/socket.c')
-rw-r--r--src/core/socket.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 5af15964ff..44827ad346 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -481,6 +481,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
"%sDirectoryMode: %04o\n"
"%sKeepAlive: %s\n"
"%sNoDelay: %s\n"
+ "%sFastOpen: %s\n"
"%sFreeBind: %s\n"
"%sTransparent: %s\n"
"%sBroadcast: %s\n"
@@ -496,6 +497,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
prefix, s->directory_mode,
prefix, yes_no(s->keep_alive),
prefix, yes_no(s->no_delay),
+ prefix, yes_no(s->fast_open),
prefix, yes_no(s->free_bind),
prefix, yes_no(s->transparent),
prefix, yes_no(s->broadcast),
@@ -798,6 +800,12 @@ static void socket_apply_socket_options(Socket *s, int fd) {
log_warning_unit(UNIT(s)->id, "TCP_NODELAY failed: %m");
}
+ if (s->fast_open) {
+ int b = s->fast_open;
+ if (setsockopt(fd, SOL_TCP, TCP_FASTOPEN, &b, sizeof(b)) < 0)
+ log_warning_unit(UNIT(s)->id, "TCP_FASTOPEN failed: %m");
+ }
+
if (s->broadcast) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0)