diff options
author | Susant Sahani <145210+ssahani@users.noreply.github.com> | 2017-12-29 15:18:05 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2017-12-29 15:18:05 +0100 |
commit | 323d9329e7a3d62a76d2f60b6884e1aa69bfe685 (patch) | |
tree | 12af2c89ae824b8a5078f938549768a109060701 | |
parent | Merge pull request #7745 from poettering/sockaddr-size (diff) | |
download | systemd-323d9329e7a3d62a76d2f60b6884e1aa69bfe685.tar.xz systemd-323d9329e7a3d62a76d2f60b6884e1aa69bfe685.zip |
networkd: allow to configure default/initial send/recv congestion window and store persistentl (#7750)
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
-rw-r--r-- | man/systemd.network.xml | 19 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-types.c | 1 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 2 | ||||
-rw-r--r-- | src/network/networkd-route.c | 58 | ||||
-rw-r--r-- | src/network/networkd-route.h | 3 |
5 files changed, 83 insertions, 0 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml index f78beaa7dc..bdf8d9e0d9 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1067,6 +1067,25 @@ </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> diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index 49a2f2a1e4..7cc4a14446 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -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 = { diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index cb0c01fbe7..e1990b0302 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -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) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index b0ad707811..f06cc82717 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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; +} diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index cde31c9663..f856b62406 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -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); |