networkd: initcwn/initwnd use the right parsers

Closes #7765
This commit is contained in:
Susant Sahani 2018-01-02 14:50:15 +05:30 committed by Lennart Poettering
parent 28da8a9f1e
commit 6b21ad33ab
2 changed files with 15 additions and 14 deletions

View file

@ -1070,19 +1070,20 @@
<varlistentry> <varlistentry>
<term><varname>InitialCongestionWindow=</varname></term> <term><varname>InitialCongestionWindow=</varname></term>
<listitem> <listitem>
<para>The TCP initial congestion window or <literal>InitialCongestionWindow</literal> is used during the start <para>The TCP initial congestion window is used during the start of a TCP connection. During the start of a TCP
of a TCP connection. During the start of a TCP session, when a client requests for a resource, the server's initial congestion window session, when a client requests a resource, the server's initial congestion window determines how many data bytes
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). will be sent during the initial burst of data. Takes a size in bytes between 1 and 4294967295 (2^32 - 1). The usual
Defaults to unset. suffixes K, M, G are supported and are understood to the base of 1024. Defaults to unset.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>InitialAdvertisedReceiveWindow=</varname></term> <term><varname>InitialAdvertisedReceiveWindow=</varname></term>
<listitem> <listitem>
<para>The TCP receive window size or <literal>InitialAdvertisedReceiveWindow</literal> is the amount of receive data (in bytes) <para>The TCP initial advertised receive window is the amount of receive data (in bytes) that can initally be buffered at one time
that can be buffered at one time on a connection. The sending host can send only that amount of data before waiting for on a connection. The sending host can send only that amount of data before waiting for an acknowledgment and window update
an acknowledgment and window update from the receiving host. Takes a number between 1 and 4294967295 (2^32 - 1). Defaults to unset. from the receiving host. Takes a size in bytes between 1 and 4294967295 (2^32 - 1). The usual suffixes K, M, G are supported
and are understood to the base of 1024. Defaults to unset.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View file

@ -636,13 +636,13 @@ int route_configure(
return log_error_errno(r, "Could not append RTAX_MTU attribute: %m"); return log_error_errno(r, "Could not append RTAX_MTU attribute: %m");
} }
if (route->initcwnd) { if (route->initcwnd > 0) {
r = sd_netlink_message_append_u32(req, RTAX_INITCWND, route->initcwnd); r = sd_netlink_message_append_u32(req, RTAX_INITCWND, route->initcwnd);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not append RTAX_INITCWND attribute: %m"); return log_error_errno(r, "Could not append RTAX_INITCWND attribute: %m");
} }
if (route->initrwnd) { if (route->initrwnd > 0) {
r = sd_netlink_message_append_u32(req, RTAX_INITRWND, route->initrwnd); r = sd_netlink_message_append_u32(req, RTAX_INITRWND, route->initrwnd);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not append RTAX_INITRWND attribute: %m"); return log_error_errno(r, "Could not append RTAX_INITRWND attribute: %m");
@ -1092,9 +1092,9 @@ int config_parse_tcp_window(const char *unit,
const char *rvalue, const char *rvalue,
void *data, void *data,
void *userdata) { void *userdata) {
Network *network = userdata;
_cleanup_route_free_ Route *n = NULL; _cleanup_route_free_ Route *n = NULL;
uint32_t k; Network *network = userdata;
uint64_t k;
int r; int r;
assert(filename); assert(filename);
@ -1107,10 +1107,10 @@ int config_parse_tcp_window(const char *unit,
if (r < 0) if (r < 0)
return r; return r;
r = safe_atou32(rvalue, &k); r = parse_size(rvalue, 1024, &k);
if (r < 0) { if (r < 0 || k > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Could not parse TCP %s \"%s\", ignoring assignment: %m", rvalue, lvalue); "Could not parse TCP %s \"%s\" bytes, ignoring assignment: %m", rvalue, lvalue);
return 0; return 0;
} }