1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #12555 from ssahani/route-properties

networkd: route add support to configure fastopen_no_cookie
This commit is contained in:
Yu Watanabe 2019-05-14 09:03:52 +02:00 committed by GitHub
commit 6e114a2475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 15 deletions

View File

@ -1218,6 +1218,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>FastOpenNoCookie=</varname></term>
<listitem>
<para>Takes a boolean. When true enables TCP fastopen without a cookie on a per-route basis.
When unset, the kernel's default will be used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MTUBytes=</varname></term>
<listitem>

View File

@ -587,20 +587,22 @@ static const NLTypeSystem rtnl_address_type_system = {
/* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
static const NLType rtnl_route_metrics_types[] = {
[RTAX_MTU] = { .type = NETLINK_TYPE_U32 },
[RTAX_WINDOW] = { .type = NETLINK_TYPE_U32 },
[RTAX_RTT] = { .type = NETLINK_TYPE_U32 },
[RTAX_RTTVAR] = { .type = NETLINK_TYPE_U32 },
[RTAX_SSTHRESH] = { .type = NETLINK_TYPE_U32 },
[RTAX_CWND] = { .type = NETLINK_TYPE_U32 },
[RTAX_ADVMSS] = { .type = NETLINK_TYPE_U32 },
[RTAX_REORDERING] = { .type = NETLINK_TYPE_U32 },
[RTAX_HOPLIMIT] = { .type = NETLINK_TYPE_U32 },
[RTAX_INITCWND] = { .type = NETLINK_TYPE_U32 },
[RTAX_FEATURES] = { .type = NETLINK_TYPE_U32 },
[RTAX_RTO_MIN] = { .type = NETLINK_TYPE_U32 },
[RTAX_INITRWND] = { .type = NETLINK_TYPE_U32 },
[RTAX_QUICKACK] = { .type = NETLINK_TYPE_U32 },
[RTAX_MTU] = { .type = NETLINK_TYPE_U32 },
[RTAX_WINDOW] = { .type = NETLINK_TYPE_U32 },
[RTAX_RTT] = { .type = NETLINK_TYPE_U32 },
[RTAX_RTTVAR] = { .type = NETLINK_TYPE_U32 },
[RTAX_SSTHRESH] = { .type = NETLINK_TYPE_U32 },
[RTAX_CWND] = { .type = NETLINK_TYPE_U32 },
[RTAX_ADVMSS] = { .type = NETLINK_TYPE_U32 },
[RTAX_REORDERING] = { .type = NETLINK_TYPE_U32 },
[RTAX_HOPLIMIT] = { .type = NETLINK_TYPE_U32 },
[RTAX_INITCWND] = { .type = NETLINK_TYPE_U32 },
[RTAX_FEATURES] = { .type = NETLINK_TYPE_U32 },
[RTAX_RTO_MIN] = { .type = NETLINK_TYPE_U32 },
[RTAX_INITRWND] = { .type = NETLINK_TYPE_U32 },
[RTAX_QUICKACK] = { .type = NETLINK_TYPE_U32 },
[RTAX_CC_ALGO] = { .type = NETLINK_TYPE_U32 },
[RTAX_FASTOPEN_NO_COOKIE] = { .type = NETLINK_TYPE_U32 },
};
static const NLTypeSystem rtnl_route_metrics_type_system = {

View File

@ -127,6 +127,7 @@ Route.Type, config_parse_route_type,
Route.InitialCongestionWindow, config_parse_tcp_window, 0, 0
Route.InitialAdvertisedReceiveWindow, config_parse_tcp_window, 0, 0
Route.QuickAck, config_parse_quickack, 0, 0
Route.FastOpenNoCookie, config_parse_fast_open_no_cookie, 0, 0
DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier)
DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns)
DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp)

View File

@ -59,6 +59,7 @@ int route_new(Route **ret) {
.table = RT_TABLE_MAIN,
.lifetime = USEC_INFINITY,
.quickack = -1,
.fast_open_no_cookie = -1,
.gateway_onlink = -1,
};
@ -638,12 +639,18 @@ int route_configure(
return log_link_error_errno(link, r, "Could not append RTAX_INITRWND attribute: %m");
}
if (route->quickack != -1) {
if (route->quickack >= 0) {
r = sd_netlink_message_append_u32(req, RTAX_QUICKACK, route->quickack);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_QUICKACK attribute: %m");
}
if (route->fast_open_no_cookie >= 0) {
r = sd_netlink_message_append_u32(req, RTAX_FASTOPEN_NO_COOKIE, route->fast_open_no_cookie);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_FASTOPEN_NO_COOKIE 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");
@ -1197,6 +1204,44 @@ int config_parse_quickack(
return 0;
}
int config_parse_fast_open_no_cookie(
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;
int k, r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k,
"Failed to parse TCP fastopen no cookie, ignoring: %s", rvalue);
return 0;
}
n->fast_open_no_cookie = k;
TAKE_PTR(n);
return 0;
}
int config_parse_route_mtu(
const char *unit,
const char *filename,

View File

@ -17,6 +17,7 @@ struct Route {
int family;
int quickack;
int fast_open_no_cookie;
unsigned char dst_prefixlen;
unsigned char src_prefixlen;
@ -74,4 +75,5 @@ CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
CONFIG_PARSER_PROTOTYPE(config_parse_quickack);
CONFIG_PARSER_PROTOTYPE(config_parse_fast_open_no_cookie);
CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);

View File

@ -80,6 +80,7 @@ PreferredSource=
Scope=
MTUBytes=
QuickAck=
FastOpenNoCookie=
Source=
Metric=
[Network]