From f4679bcb571bfb99c29b2df8b92b27cc3a6bb619 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 13 May 2019 16:44:55 +0530 Subject: [PATCH 1/3] sd-netlink: support RTAX_FASTOPEN_NO_COOKIE --- src/libsystemd/sd-netlink/netlink-types.c | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index c847c373387..f207d2e5aae 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -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 = { From 633c7258655ba94b2b9c24689de150717839e78b Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 13 May 2019 16:45:33 +0530 Subject: [PATCH 2/3] networkd: route add support to configure fastopen_no_cookie This patch adds fastopen_no_cookie option to enable/disable TCP fastopen without a cookie on a per-route basis. --- man/systemd.network.xml | 8 ++++ src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-route.c | 45 +++++++++++++++++++ src/network/networkd-route.h | 2 + .../fuzz-network-parser/directives.network | 1 + 5 files changed, 57 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 3ff1a036ff5..0395f2c3305 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1218,6 +1218,14 @@ + + FastOpenNoCookie= + + 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. + + + MTUBytes= diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index c6036e29faf..e8e228092cd 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -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) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 379077cbfde..03332cd21b3 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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, }; @@ -644,6 +645,12 @@ int route_configure( 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, diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index 1e8320fdc08..892da25bd56 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -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); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 97e8e4a5802..3c4a16bc39b 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -78,6 +78,7 @@ PreferredSource= Scope= MTUBytes= QuickAck= +FastOpenNoCookie= Source= Metric= [Network] From 67c193bfb06a09ea97f06cc86554f70bb210a551 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Tue, 14 May 2019 08:09:54 +0530 Subject: [PATCH 3/3] networkd: route fix coding style --- src/network/networkd-route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 03332cd21b3..179eeac017b 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -639,7 +639,7 @@ 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");