]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: DHCP4 allow to set InitialCongestionWindow and InitialAdvertisedReceiveWindow 28335/head
authorSusant Sahani <ssahani@gmail.com>
Mon, 10 Jul 2023 09:48:58 +0000 (15:18 +0530)
committerSusant Sahani <ssahani@gmail.com>
Sat, 15 Jul 2023 13:54:27 +0000 (19:24 +0530)
man/systemd.network.xml
src/network/networkd-dhcp4.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.h
src/network/networkd-route.c
src/network/networkd-route.h

index 1ab28cde4bbd510fddc38f302f146349d22bf3ae..959ce08314f8a4fe1fdb91146b2d2571cdc612ad 100644 (file)
@@ -2073,6 +2073,20 @@ allow my_server_t localnet_peer_t:peer recv;</programlisting>
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>InitialCongestionWindow=</varname></term>
+        <listitem>
+          <para>As in the [Route] section.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><varname>InitialAdvertisedReceiveWindow=</varname></term>
+        <listitem>
+          <para>As in the [Route] section.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>UseGateway=</varname></term>
         <listitem>
index 321e87bc7ebac4bb94936f067392a05638fc137c..e2fe836f2c7f19ce9aa9924399fddf5bc19865b7 100644 (file)
@@ -203,6 +203,10 @@ static int dhcp4_request_route(Route *in, Link *link) {
                 route->mtu = link->network->dhcp_route_mtu;
         if (route->quickack < 0)
                 route->quickack = link->network->dhcp_quickack;
+        if (route->initcwnd == 0)
+                route->initcwnd = link->network->dhcp_initial_congestion_window;
+        if (route->initrwnd == 0)
+                route->initrwnd = link->network->dhcp_advertised_receive_window;
 
         if (route_get(NULL, link, route, &existing) < 0) /* This is a new route. */
                 link->dhcp4_configured = false;
index 6a7ef24651ffe422ea6ea6f0806ba7b8363f389c..a5d328e0378fb936115b9fb92a94a10df1c2f88c 100644 (file)
@@ -195,8 +195,8 @@ Route.GatewayOnlink,                         config_parse_route_boolean,
 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
+Route.InitialCongestionWindow,               config_parse_route_tcp_window,                            0,                             0
+Route.InitialAdvertisedReceiveWindow,        config_parse_route_tcp_window,                            0,                             0
 Route.TCPAdvertisedMaximumSegmentSize,       config_parse_tcp_advmss,                                  0,                             0
 Route.TCPCongestionControlAlgorithm,         config_parse_tcp_congestion,                              0,                             0
 Route.QuickAck,                              config_parse_route_boolean,                               0,                             0
@@ -249,6 +249,8 @@ DHCPv4.SocketPriority,                       config_parse_dhcp_socket_priority,
 DHCPv4.SendOption,                           config_parse_dhcp_send_option,                            AF_INET,                       offsetof(Network, dhcp_client_send_options)
 DHCPv4.SendVendorOption,                     config_parse_dhcp_send_option,                            0,                             offsetof(Network, dhcp_client_send_vendor_options)
 DHCPv4.RouteMTUBytes,                        config_parse_mtu,                                         AF_INET,                       offsetof(Network, dhcp_route_mtu)
+DHCPv4.InitialCongestionWindow,              config_parse_tcp_window,                                  0,                             offsetof(Network, dhcp_initial_congestion_window)
+DHCPv4.InitialAdvertisedReceiveWindow,       config_parse_tcp_window,                                  0,                             offsetof(Network, dhcp_advertised_receive_window)
 DHCPv4.FallbackLeaseLifetimeSec,             config_parse_dhcp_fallback_lease_lifetime,                0,                             0
 DHCPv4.Use6RD,                               config_parse_bool,                                        0,                             offsetof(Network, dhcp_use_6rd)
 DHCPv4.NetLabel,                             config_parse_string,                                      CONFIG_PARSE_STRING_SAFE,      offsetof(Network, dhcp_netlabel)
index e473a725005137c23e0b968e71015c9d96d7b06e..886729cd5a1232b16a9991d56ffffe67a5aa537c 100644 (file)
@@ -148,6 +148,8 @@ struct Network {
         bool dhcp_use_routes;
         int dhcp_use_gateway;
         bool dhcp_quickack;
+        uint32_t dhcp_initial_congestion_window;
+        uint32_t dhcp_advertised_receive_window;
         bool dhcp_use_timezone;
         bool dhcp_use_hostname;
         bool dhcp_use_6rd;
index f7215858e6237ae9d92fff322a87c07e5cb6a44a..f1f4447ec796ff2e072eead82054d7451bf10fdb 100644 (file)
@@ -2643,8 +2643,7 @@ int config_parse_tcp_window(
                 void *data,
                 void *userdata) {
 
-        _cleanup_(route_free_or_set_invalidp) Route *n = NULL;
-        Network *network = userdata;
+        uint32_t *window = ASSERT_PTR(data);
         uint32_t k;
         int r;
 
@@ -2654,15 +2653,6 @@ int config_parse_tcp_window(
         assert(rvalue);
         assert(data);
 
-        r = route_new_static(network, filename, section_line, &n);
-        if (r == -ENOMEM)
-                return log_oom();
-        if (r < 0) {
-                log_syntax(unit, LOG_WARNING, filename, line, r,
-                           "Failed to allocate route, ignoring assignment: %m");
-                return 0;
-        }
-
         r = safe_atou32(rvalue, &k);
         if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
@@ -2680,13 +2670,53 @@ int config_parse_tcp_window(
                 return 0;
         }
 
+        *window = k;
+        return 0;
+}
+
+int config_parse_route_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) {
+
+        _cleanup_(route_free_or_set_invalidp) Route *n = NULL;
+        Network *network = userdata;
+        uint32_t *d;
+        int r;
+
+        assert(filename);
+        assert(section);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = route_new_static(network, filename, section_line, &n);
+        if (r == -ENOMEM)
+                return log_oom();
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Failed to allocate route, ignoring assignment: %m");
+                return 0;
+        }
+
         if (streq(lvalue, "InitialCongestionWindow"))
-                n->initcwnd = k;
+                d = &n->initcwnd;
         else if (streq(lvalue, "InitialAdvertisedReceiveWindow"))
-                n->initrwnd = k;
+                d = &n->initrwnd;
         else
                 assert_not_reached();
 
+        r = config_parse_tcp_window(unit, filename, line, section, section_line, lvalue, ltype, rvalue, d, userdata);
+        if (r < 0)
+                return r;
+
         TAKE_PTR(n);
         return 0;
 }
index 5fc76b17f8549a87e7c9cba1303539a699e06b04..1f84d31733ba7fe80f5d468da8294848ffe0c3ad 100644 (file)
@@ -122,6 +122,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean);
 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
 CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
 CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
+CONFIG_PARSER_PROTOTYPE(config_parse_route_tcp_window);
 CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
 CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
 CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);