]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: route - add support to configure tcp advmss
authorSusant Sahani <ssahani@vmware.com>
Thu, 7 Jan 2021 15:17:17 +0000 (16:17 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 8 Jan 2021 14:06:13 +0000 (14:06 +0000)
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.network

index 422268b0f7c9ae1cb07dea87d31fb47641dfd0a4..542743aa5b308e73ad527a58750ef6de51ceefb0 100644 (file)
@@ -1482,6 +1482,14 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
             service type to CS6 (network control) or CS4 (Realtime). Defaults to CS6.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>TCPAdvertisedMaximumSegmentSize=</varname></term>
+          <listitem>
+            <para>Specifies the Path MSS (in bytes) hints given on TCP layer. The usual suffixes K, M, G, are
+            supported and are understood to the base of 1024. An unsigned integer in the range 1–4294967294.
+            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 444c6c78bc144432a8706204cf6d19c042b11784..81878dcea1a133dc179467dba3e38c35bd3a1318 100644 (file)
@@ -179,6 +179,7 @@ Route.Protocol,                              config_parse_route_protocol,
 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.TCPAdvertisedMaximumSegmentSize,       config_parse_tcp_advmss,                                  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 0c15fc53f4cee775174a19ec3a5a5834fa41f72c..b6bf9803b4166e57a26474a81fb82d486f510475 100644 (file)
@@ -310,6 +310,8 @@ void route_hash_func(const Route *route, struct siphash *state) {
                 siphash24_compress(&route->initcwnd, sizeof(route->initcwnd), state);
                 siphash24_compress(&route->initrwnd, sizeof(route->initrwnd), state);
 
+                siphash24_compress(&route->advmss, sizeof(route->advmss), state);
+
                 break;
         default:
                 /* treat any other address family as AF_UNSPEC */
@@ -393,6 +395,10 @@ int route_compare_func(const Route *a, const Route *b) {
                 if (r != 0)
                         return r;
 
+                r = CMP(a->advmss, b->advmss);
+                if (r != 0)
+                        return r;
+
                 return 0;
         default:
                 /* treat any other address family as AF_UNSPEC */
@@ -475,6 +481,7 @@ static void route_copy(Route *dest, const Route *src, const MultipathRoute *m) {
         dest->initcwnd = src->initcwnd;
         dest->initrwnd = src->initrwnd;
         dest->lifetime = src->lifetime;
+        dest->advmss= src->advmss;
 
         if (m) {
                 dest->gw_family = m->gateway.family;
@@ -1122,6 +1129,12 @@ int route_configure(
                         return log_link_error_errno(link, r, "Could not append RTAX_FASTOPEN_NO_COOKIE attribute: %m");
         }
 
+        if (route->advmss > 0) {
+                r = sd_netlink_message_append_u32(req, RTAX_ADVMSS, route->advmss);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append RTAX_ADVMSS attribute: %m");
+        }
+
         r = sd_netlink_message_close_container(req);
         if (r < 0)
                 return log_link_error_errno(link, r, "Could not append RTA_METRICS attribute: %m");
@@ -2074,6 +2087,62 @@ int config_parse_route_type(
         return 0;
 }
 
+int config_parse_tcp_advmss(
+                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;
+        uint64_t u;
+        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 (isempty(rvalue)) {
+                n->advmss = 0;
+                return 0;
+        }
+
+        r = parse_size(rvalue, 1024, &u);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Could not parse TCPAdvertisedMaximumSegmentSize= \"%s\", ignoring assignment: %m", rvalue);
+                return 0;
+        }
+
+        if (u == 0 || u > UINT32_MAX) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid TCPAdvertisedMaximumSegmentSize= \"%s\", ignoring assignment: %m", rvalue);
+                return 0;
+        }
+
+        n->advmss = u;
+
+        TAKE_PTR(n);
+        return 0;
+}
+
 int config_parse_tcp_window(
                 const char *unit,
                 const char *filename,
index 82ef4ee2a0e370f2cf76a2ad10a6b7fd599414af..8923966ddf3bccf053481f2f1e0158ce639091b0 100644 (file)
@@ -40,6 +40,7 @@ typedef struct Route {
         uint32_t mtu;
         uint32_t initcwnd;
         uint32_t initrwnd;
+        uint32_t advmss;
         unsigned char pref;
         unsigned flags;
         int gateway_onlink;
@@ -98,3 +99,4 @@ 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_advmss);
index e7860702c6a4a1d8ce35f75c4570a4378b72963c..c8435a0a847eec253a727d585d314cee7f6f146f 100644 (file)
@@ -163,6 +163,7 @@ Source=
 Metric=
 TTLPropagate=
 MultiPathRoute=
+TCPAdvertisedMaximumSegmentSize=
 [Network]
 IPv6DuplicateAddressDetection=
 IPMasquerade=