summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@vmware.com>2021-01-07 16:17:17 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2021-01-08 14:06:13 +0000
commit007cac09a2e3e7e5c067f93948fb33f37166c9bb (patch)
treecf60cba3fac44a9d549126438dd1e82da2f4b3e3
parentcdcb12cc1c913ffdac6181f8e18a81bcf92c4527 (diff)
downloadsystemd-007cac09a2e3e7e5c067f93948fb33f37166c9bb.tar.gz
network: route - add support to configure tcp advmss
-rw-r--r--man/systemd.network.xml8
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/networkd-route.c69
-rw-r--r--src/network/networkd-route.h2
-rw-r--r--test/fuzz/fuzz-network-parser/directives.network1
5 files changed, 81 insertions, 0 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 422268b0f7..542743aa5b 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -1483,6 +1483,14 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></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>
<para>Configures multipath route. Multipath routing is the technique of using multiple
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 444c6c78bc..81878dcea1 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -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
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 0c15fc53f4..b6bf9803b4 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -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,
diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h
index 82ef4ee2a0..8923966ddf 100644
--- a/src/network/networkd-route.h
+++ b/src/network/networkd-route.h
@@ -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);
diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network
index e7860702c6..c8435a0a84 100644
--- a/test/fuzz/fuzz-network-parser/directives.network
+++ b/test/fuzz/fuzz-network-parser/directives.network
@@ -163,6 +163,7 @@ Source=
Metric=
TTLPropagate=
MultiPathRoute=
+TCPAdvertisedMaximumSegmentSize=
[Network]
IPv6DuplicateAddressDetection=
IPMasquerade=