]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: allow to configure default/initial send/recv congestion window and store...
authorSusant Sahani <145210+ssahani@users.noreply.github.com>
Fri, 29 Dec 2017 14:18:05 +0000 (19:48 +0530)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 29 Dec 2017 14:18:05 +0000 (23:18 +0900)
Currently we can only change initcwnd/initrwnd in the following way, and it does not store persistently:
sudo ip route change default via 192.168.1.1 dev tun0 initcwnd 20
sudo ip route change default via 192.168.1.1 dev tun0 initrwnd 20

For more details about initcwnd/initrwnd, please look at:
http://hjzhao.blogspot.com/2012/05/increase-initcwnd-for-performance.html
http://www.cdnplanet.com/blog/tune-tcp-initcwnd-for-optimum-performance
or google 'initcwnd initrwnd'

This work allows to configure the initcwnd and initrwnd.

Closes #2118

man/systemd.network.xml
src/libsystemd/sd-netlink/netlink-types.c
src/network/networkd-network-gperf.gperf
src/network/networkd-route.c
src/network/networkd-route.h

index f78beaa7dc72b7694ab85c23c75b4775dab3ea01..bdf8d9e0d90a6f62819b1c6b02ab60877356e14c 100644 (file)
             </para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>InitialCongestionWindow=</varname></term>
+          <listitem>
+            <para>The TCP initial congestion window or <literal>InitialCongestionWindow</literal>  is used during the start
+            of a TCP connection. During the start of a TCP session, when a client requests for a resource, the server's initial congestion window
+            determines how many data packets will be sent during the initial burst of data. Takes a number between between 1 and 4294967295 (2^32 - 1).
+            Defaults to unset.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term><varname>InitialAdvertisedReceiveWindow=</varname></term>
+          <listitem>
+            <para>The TCP receive window size or <literal>InitialAdvertisedReceiveWindow</literal> is the amount of receive data (in bytes)
+            that can be buffered at one time on a connection. The sending host can send only that amount of data before waiting for
+            an acknowledgment and window update from the receiving host. Takes a number between 1 and 4294967295 (2^32 - 1). Defaults to unset.
+            </para>
+          </listitem>
+        </varlistentry>
 
       </variablelist>
   </refsect1>
index 49a2f2a1e4b9fc8e2700a0f43d3ee965be657290..7cc4a14446175711e383a01a0a9daf97e737db30 100644 (file)
@@ -553,6 +553,7 @@ static const NLType rtnl_route_metrics_types[] = {
         [RTAX_INITCWND]          = { .type = NETLINK_TYPE_U32 },
         [RTAX_FEATURES]          = { .type = NETLINK_TYPE_U32 },
         [RTAX_RTO_MIN]           = { .type = NETLINK_TYPE_U32 },
+        [RTAX_INITRWND]          = { .type = NETLINK_TYPE_U32 },
 };
 
 static const NLTypeSystem rtnl_route_metrics_type_system = {
index cb0c01fbe740f0eb67d0c52169c58efc1014693c..e1990b03024feb0b8998655a0ae8f0ac8af9cea7 100644 (file)
@@ -108,6 +108,8 @@ Route.GatewayOnlink,                    config_parse_gateway_onlink,
 Route.IPv6Preference,                   config_parse_ipv6_route_preference,             0,                             0
 Route.Protocol,                         config_parse_route_protocol,                    0,                             0
 Route.Type,                             config_parse_route_type,                        0,                             0
+Route.InitialCongestionWindow,          config_parse_tcp_window,                        0,                             0
+Route.InitialAdvertisedReceiveWindow,   config_parse_tcp_window,                        0,                             0
 DHCP.ClientIdentifier,                  config_parse_dhcp_client_identifier,            0,                             offsetof(Network, dhcp_client_identifier)
 DHCP.UseDNS,                            config_parse_bool,                              0,                             offsetof(Network, dhcp_use_dns)
 DHCP.UseNTP,                            config_parse_bool,                              0,                             offsetof(Network, dhcp_use_ntp)
index b0ad707811b5eb114aaca50f092f90af10a95b8d..f06cc82717c62a7f9bad64662baea4dd0c96253e 100644 (file)
@@ -636,6 +636,18 @@ int route_configure(
                         return log_error_errno(r, "Could not append RTAX_MTU attribute: %m");
         }
 
+        if (route->initcwnd) {
+                r = sd_netlink_message_append_u32(req, RTAX_INITCWND, route->initcwnd);
+                if (r < 0)
+                        return log_error_errno(r, "Could not append RTAX_INITCWND attribute: %m");
+        }
+
+        if (route->initrwnd) {
+                r = sd_netlink_message_append_u32(req, RTAX_INITRWND, route->initrwnd);
+                if (r < 0)
+                        return log_error_errno(r, "Could not append RTAX_INITRWND attribute: %m");
+        }
+
         r = sd_netlink_message_close_container(req);
         if (r < 0)
                 return log_error_errno(r, "Could not append RTA_METRICS attribute: %m");
@@ -1069,3 +1081,49 @@ int config_parse_route_type(const char *unit,
 
         return 0;
 }
+
+int config_parse_tcp_window(const char *unit,
+                             const char *filename,
+                             unsigned line,
+                             const char *section,
+                             unsigned section_line,
+                             const char *lvalue,
+                             int ltype,
+                             const char *rvalue,
+                             void *data,
+                             void *userdata) {
+        Network *network = userdata;
+        _cleanup_route_free_ Route *n = NULL;
+        uint32_t k;
+        int r;
+
+        assert(filename);
+        assert(section);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = route_new_static(network, filename, section_line, &n);
+        if (r < 0)
+                return r;
+
+        r = safe_atou32(rvalue, &k);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r,
+                           "Could not parse TCP %s \"%s\", ignoring assignment: %m", rvalue, lvalue);
+                return 0;
+        }
+
+        if (streq(lvalue, "InitialCongestionWindow"))
+                n->initcwnd = k;
+        else if (streq(lvalue, "InitialAdvertisedReceiveWindow"))
+                n->initrwnd = k;
+        else {
+                log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse TCP %s: %s", lvalue, rvalue);
+                return 0;
+        }
+
+        n = NULL;
+
+        return 0;
+}
index cde31c96633b9640defe5c8b7929bd20499d1468..f856b62406fb3e10f7a52e477a75470920fbbbdf 100644 (file)
@@ -42,6 +42,8 @@ struct Route {
         uint32_t priority; /* note that ip(8) calls this 'metric' */
         uint32_t table;
         uint32_t mtu;
+        uint32_t initcwnd;
+        uint32_t initrwnd;
         unsigned char pref;
         unsigned flags;
 
@@ -82,3 +84,4 @@ int config_parse_gateway_onlink(const char *unit, const char *filename, unsigned
 int config_parse_ipv6_route_preference(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_route_protocol(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_route_type(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_tcp_window(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);