]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce TCPCongestionControlAlgorithm=
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 26 Aug 2022 05:43:07 +0000 (14:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 26 Aug 2022 10:47:23 +0000 (19:47 +0900)
Closes #24432.

man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/networkd-route.c
src/network/networkd-route.h
test/fuzz/fuzz-network-parser/directives

index 818df99e5a1c993d0114160757c987270ecb691d..b9d74d6097799838ef83e8423067702e9c7a7e4c 100644 (file)
@@ -1622,6 +1622,15 @@ Table=1234</programlisting></para>
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>TCPCongestionControlAlgorithm=</varname></term>
+        <listitem>
+          <para>Specifies the TCP congestion control algorithm for the route. Takes a name of the algorithm,
+          e.g. <literal>bbr</literal>, <literal>dctcp</literal>, or <literal>vegas</literal>. When unset,
+          the kernel's default will be used.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>MultiPathRoute=<replaceable>address</replaceable>[@<replaceable>name</replaceable>] [<replaceable>weight</replaceable>]</varname></term>
         <listitem>
index a4f038681a42e04217e05436f3e3281af717eaf1..dce7339d2f092cde4c6914d1cdf5bf3724bb2ed6 100644 (file)
@@ -196,6 +196,7 @@ Route.Type,                                  config_parse_route_type,
 Route.InitialCongestionWindow,               config_parse_tcp_window,                                  0,                             0
 Route.InitialAdvertisedReceiveWindow,        config_parse_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
 Route.FastOpenNoCookie,                      config_parse_route_boolean,                               0,                             0
 Route.TTLPropagate,                          config_parse_route_boolean,                               0,                             0
index 71e578d89820f5c40e658c5966b30cb75832b939..4f097364a188c3487dc9b178a5b05b0a35b42824 100644 (file)
@@ -107,6 +107,8 @@ Route *route_free(Route *route) {
 
         sd_event_source_disable_unref(route->expire);
 
+        free(route->tcp_congestion_control_algo);
+
         return mfree(route);
 }
 
@@ -319,6 +321,7 @@ int route_get(Manager *manager, Link *link, const Route *in, Route **ret) {
 
 int route_dup(const Route *src, Route **ret) {
         _cleanup_(route_freep) Route *dest = NULL;
+        int r;
 
         /* This does not copy mulipath routes. */
 
@@ -336,6 +339,11 @@ int route_dup(const Route *src, Route **ret) {
         dest->manager = NULL;
         dest->multipath_routes = NULL;
         dest->expire = NULL;
+        dest->tcp_congestion_control_algo = NULL;
+
+        r = free_and_strdup(&dest->tcp_congestion_control_algo, src->tcp_congestion_control_algo);
+        if (r < 0)
+                return r;
 
         *ret = TAKE_PTR(dest);
         return 0;
@@ -1231,6 +1239,12 @@ static int route_configure(const Route *route, uint32_t lifetime_sec, Link *link
                         return r;
         }
 
+        if (!isempty(route->tcp_congestion_control_algo)) {
+                r = sd_netlink_message_append_string(m, RTAX_CC_ALGO, route->tcp_congestion_control_algo);
+                if (r < 0)
+                        return r;
+        }
+
         r = sd_netlink_message_close_container(m);
         if (r < 0)
                 return r;
@@ -2498,6 +2512,46 @@ int config_parse_route_type(
         return 0;
 }
 
+int config_parse_tcp_congestion(
+                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_or_set_invalidp) Route *n = NULL;
+        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;
+        }
+
+        r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype,
+                                rvalue, &n->tcp_congestion_control_algo, userdata);
+        if (r < 0)
+                return r;
+
+        TAKE_PTR(n);
+        return 0;
+}
+
 int config_parse_tcp_advmss(
                 const char *unit,
                 const char *filename,
index b431e1a30f4c60f1eb33e5154c1e0cd399683b68..fd4433eae4e54460a456dcced54340dc2517dcfd 100644 (file)
@@ -50,6 +50,7 @@ struct Route {
         uint32_t initcwnd;
         uint32_t initrwnd;
         uint32_t advmss;
+        char *tcp_congestion_control_algo;
         unsigned char pref;
         unsigned flags;
         int gateway_onlink; /* Only used in conf parser and route_section_verify(). */
@@ -123,5 +124,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
 CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
 CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
 CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);
+CONFIG_PARSER_PROTOTYPE(config_parse_tcp_congestion);
 CONFIG_PARSER_PROTOTYPE(config_parse_tcp_advmss);
 CONFIG_PARSER_PROTOTYPE(config_parse_route_nexthop);
index b7e8f1683487cfb9f9a9af88ec22a00dd9b7b090..6f76f7ee18c64f50317c434fccbb60ae086e3a3b 100644 (file)
@@ -189,6 +189,7 @@ Metric=
 TTLPropagate=
 MultiPathRoute=
 TCPAdvertisedMaximumSegmentSize=
+TCPCongestionControlAlgorithm=
 NextHop=
 [Network]
 KeepMaster=