1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-28 11:21:59 +03:00

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
This commit is contained in:
Susant Sahani 2017-12-29 19:48:05 +05:30 committed by Yu Watanabe
parent 5543b2b2c9
commit 323d9329e7
5 changed files with 83 additions and 0 deletions

View File

@ -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>

View 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 = {

View 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)

View 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;
}

View 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);