chiark / gitweb /
socket: add support for TCP fast Open
authorSusant Sahani <susant@redhat.com>
Thu, 14 Aug 2014 09:01:47 +0000 (14:31 +0530)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 Aug 2014 11:14:39 +0000 (13:14 +0200)
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.

man/systemd.socket.xml
src/core/dbus-socket.c
src/core/load-fragment-gperf.gperf.m4
src/core/socket.c
src/core/socket.h

index 352825f5802847ce21e389483516aa5d0ce0e05a..170d010f601625c04679276c6062f8c3a9a803b3 100644 (file)
                                 <option>false</option>.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><varname>FastOpen=</varname></term>
+                                <listitem><para>Takes a boolean
+                                argument. It works by using a TFO cookie (a TCP option) in the initial
+                                SYN packet to authenticate a previously connected client. If successful,
+                                it may start 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.
+                                This controls the TCP_FASTOPEN socket option (see
+                                the <ulink url="http://lwn.net/Articles/508865/">TCP
+                                Fast Open: expediting web services</ulink> for details.)
+                                Defaults to
+                                <option>false</option>.</para></listitem>
+                        </varlistentry>
+
                         <varlistentry>
                                 <term><varname>Priority=</varname></term>
                                 <listitem><para>Takes an integer
index ad135a1ac20a892e4d425a8b4c020aa03713a616..71c0115ab4df50a98a0b5c137e6de1850b989d39 100644 (file)
@@ -97,6 +97,7 @@ const sd_bus_vtable bus_socket_vtable[] = {
         SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Socket, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("Accept", "b", bus_property_get_bool, offsetof(Socket, accept), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("KeepAlive", "b", bus_property_get_bool, offsetof(Socket, keep_alive), SD_BUS_VTABLE_PROPERTY_CONST),
+        SD_BUS_PROPERTY("FastOpen" , "b", bus_property_get_bool, offsetof(Socket, fast_open), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("Priority", "i", bus_property_get_int, offsetof(Socket, priority), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("ReceiveBuffer", "t", bus_property_get_size, offsetof(Socket, receive_buffer), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("SendBuffer", "t", bus_property_get_size, offsetof(Socket, send_buffer), SD_BUS_VTABLE_PROPERTY_CONST),
index f4acdda22a656210240bba8b8f1d59356048a0f9..08d05937f5321ff9dcdea0be4ecefc6e7b26dad3 100644 (file)
@@ -232,6 +232,7 @@ Socket.Accept,                   config_parse_bool,                  0,
 Socket.MaxConnections,           config_parse_unsigned,              0,                             offsetof(Socket, max_connections)
 Socket.KeepAlive,                config_parse_bool,                  0,                             offsetof(Socket, keep_alive)
 Socket.NoDelay,                  config_parse_bool,                  0,                             offsetof(Socket, no_delay)
+Socket.FastOpen,                 config_parse_bool,                  0,                             offsetof(Socket, fast_open)
 Socket.Priority,                 config_parse_int,                   0,                             offsetof(Socket, priority)
 Socket.ReceiveBuffer,            config_parse_iec_size,              0,                             offsetof(Socket, receive_buffer)
 Socket.SendBuffer,               config_parse_iec_size,              0,                             offsetof(Socket, send_buffer)
index 5af15964ff088b591fbfac1f201663849c482d5e..44827ad346934382b24243b154b310ae13873195 100644 (file)
@@ -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)
index 98396e73206e9b2adadc6a8d08801bb11a97ab9b..6c0084c477b6fbe34d7988fc46690243edd60164 100644 (file)
@@ -135,6 +135,7 @@ struct Socket {
         /* Socket options */
         bool keep_alive;
         bool no_delay;
+        bool fast_open;
         bool free_bind;
         bool transparent;
         bool broadcast;