networkd: initcwn/initwnd use the right parsers
authorSusant Sahani <susant@redhat.com>
Tue, 2 Jan 2018 09:20:15 +0000 (14:50 +0530)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Jan 2018 14:07:03 +0000 (15:07 +0100)
Closes #7765

man/systemd.network.xml
src/network/networkd-route.c

index bdf8d9e..f1bd751 100644 (file)
         <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>The TCP initial congestion window is used during the start of a TCP connection. During the start of a TCP
+            session, when a client requests a resource, the server's initial congestion window determines how many data bytes
+            will be sent during the initial burst of data. 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>
           </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>The TCP initial advertised receive window is the amount of receive data (in bytes) that can initally 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 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>
           </listitem>
         </varlistentry>
index f06cc82..87a92b6 100644 (file)
@@ -636,13 +636,13 @@ int route_configure(
                         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);
                 if (r < 0)
                         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);
                 if (r < 0)
                         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,
                              void *data,
                              void *userdata) {
-        Network *network = userdata;
         _cleanup_route_free_ Route *n = NULL;
-        uint32_t k;
+        Network *network = userdata;
+        uint64_t k;
         int r;
 
         assert(filename);
@@ -1107,10 +1107,10 @@ int config_parse_tcp_window(const char *unit,
         if (r < 0)
                 return r;
 
-        r = safe_atou32(rvalue, &k);
-        if (r < 0) {
+        r = parse_size(rvalue, 1024, &k);
+        if (r < 0 || k > UINT32_MAX)  {
                 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;
         }