mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
network: route - add support to configure tcp advmss
This commit is contained in:
parent
cdcb12cc1c
commit
007cac09a2
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -163,6 +163,7 @@ Source=
|
||||
Metric=
|
||||
TTLPropagate=
|
||||
MultiPathRoute=
|
||||
TCPAdvertisedMaximumSegmentSize=
|
||||
[Network]
|
||||
IPv6DuplicateAddressDetection=
|
||||
IPMasquerade=
|
||||
|
Loading…
Reference in New Issue
Block a user