From fb076d5f6c0cd35eb455b48b9a059704919a2a87 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 03:39:46 +0900 Subject: [PATCH 01/15] sd-netlink: add more attributes for CAKE --- .../sd-netlink/netlink-types-rtnl.c | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libsystemd/sd-netlink/netlink-types-rtnl.c b/src/libsystemd/sd-netlink/netlink-types-rtnl.c index 2c01751a52..85a6c79396 100644 --- a/src/libsystemd/sd-netlink/netlink-types-rtnl.c +++ b/src/libsystemd/sd-netlink/netlink-types-rtnl.c @@ -1028,9 +1028,23 @@ static const NLType rtnl_nexthop_types[] = { DEFINE_TYPE_SYSTEM(rtnl_nexthop); static const NLType rtnl_tca_option_data_cake_types[] = { - [TCA_CAKE_BASE_RATE64] = { .type = NETLINK_TYPE_U64 }, - [TCA_CAKE_OVERHEAD] = { .type = NETLINK_TYPE_S32 }, - [TCA_CAKE_MPU] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_BASE_RATE64] = { .type = NETLINK_TYPE_U64 }, + [TCA_CAKE_DIFFSERV_MODE] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_ATM] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_FLOW_MODE] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_OVERHEAD] = { .type = NETLINK_TYPE_S32 }, + [TCA_CAKE_RTT] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_TARGET] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_AUTORATE] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_MEMORY] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_NAT] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_RAW] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_WASH] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_MPU] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_INGRESS] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_ACK_FILTER] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_SPLIT_GSO] = { .type = NETLINK_TYPE_U32 }, + [TCA_CAKE_FWMARK] = { .type = NETLINK_TYPE_U32 }, }; static const NLType rtnl_tca_option_data_codel_types[] = { From ca2c3e921fbe526efcfdc46b6477621aebc93826 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 04:32:00 +0900 Subject: [PATCH 02/15] man: move Bandwidth= setting at the beginning of the [CAKE] section For consistency with tc-cake(8). --- man/systemd.network.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 49814a05eb..7f7729cf4c 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3463,14 +3463,6 @@ Token=prefixstable:2002:da8:1:: - - OverheadBytes= - - Specifies that bytes to be addeded to the size of each packet. Bytes may be negative. Takes - an integer in the range from -64 to 256. Defaults to unset and kernel's default is used. - - - Bandwidth= @@ -3479,6 +3471,15 @@ Token=prefixstable:2002:da8:1:: unset and kernel's default is used. + + + OverheadBytes= + + Specifies that bytes to be addeded to the size of each packet. Bytes may be negative. Takes + an integer in the range from -64 to 256. Defaults to unset and kernel's default is used. + + + From 69978eb9102ff7abd19afd4b7cd2467bc4643f6f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 09:20:21 +0900 Subject: [PATCH 03/15] =?UTF-8?q?man:=20use=20"=E2=80=A6"=20for=20specifyi?= =?UTF-8?q?ng=20ranges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- man/systemd.network.xml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 7f7729cf4c..39acb2a6a9 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1150,7 +1150,7 @@ Table=1234 Label= - The label for the prefix, an unsigned integer in the range 0–4294967294. + The label for the prefix, an unsigned integer in the range 0…4294967294. 0xffffffff is reserved. This setting is mandatory. @@ -1552,7 +1552,7 @@ Table=1234 TCPAdvertisedMaximumSegmentSize= 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. + 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. @@ -2049,7 +2049,7 @@ Table=1234 Takes an IPv6 address with prefix length in the same format as the Address= in the [Network] section. The DHCPv6 client will include a prefix hint in the DHCPv6 solicitation sent to the server. The prefix length must be in the range - 1–128. Defaults to unset. + 1…128. Defaults to unset. @@ -3095,7 +3095,7 @@ Token=prefixstable:2002:da8:1:: Termination= - Takes a boolean or a termination resistor value in ohm in the range 0–65535. When + Takes a boolean or a termination resistor value in ohm in the range 0…65535. When yes, the termination resistor is set to 120 ohm. When no or 0 is set, the termination resistor is disabled. When unset, the kernel's default will be used. @@ -3209,7 +3209,7 @@ Token=prefixstable:2002:da8:1:: PacketLimit= Specifies the maximum number of packets the qdisc may hold queued at a time. - An unsigned integer in the range 0–4294967294. Defaults to 1000. + An unsigned integer in the range 0…4294967294. Defaults to 1000. @@ -3358,7 +3358,7 @@ Token=prefixstable:2002:da8:1:: PacketLimit= Specifies the hard limit on the queue size in number of packets. When this limit is reached, - incoming packets are dropped. An unsigned integer in the range 0–4294967294. Defaults to unset and + incoming packets are dropped. An unsigned integer in the range 0…4294967294. Defaults to unset and kernel's default is used. @@ -3420,7 +3420,7 @@ Token=prefixstable:2002:da8:1:: Specifies the hard limit on the number of packets in the FIFO queue. The size limit prevents overflow in case the kernel is unable to dequeue packets as quickly as it receives them. When this limit is reached, incoming packets are dropped. An unsigned integer in the range - 0–4294967294. Defaults to unset and kernel's default is used. + 0…4294967294. Defaults to unset and kernel's default is used. @@ -3475,8 +3475,9 @@ Token=prefixstable:2002:da8:1:: OverheadBytes= - Specifies that bytes to be addeded to the size of each packet. Bytes may be negative. Takes - an integer in the range from -64 to 256. Defaults to unset and kernel's default is used. + Specifies that bytes to be addeded to the size of each packet. Bytes may be negative. + Takes an integer in the range -64…256. Defaults to unset and kernel's default is used. + @@ -3496,7 +3497,7 @@ Token=prefixstable:2002:da8:1:: PacketLimit= Specifies the hard limit on the queue size in number of packets. When this limit is reached, - incoming packets are dropped. An unsigned integer in the range 0–4294967294. Defaults to unset and + incoming packets are dropped. An unsigned integer in the range 0…4294967294. Defaults to unset and kernel's default is used. @@ -3580,7 +3581,7 @@ Token=prefixstable:2002:da8:1:: Bands= - Specifies the number of bands. An unsigned integer in the range 1–16. This value has to be at + Specifies the number of bands. An unsigned integer in the range 1…16. This value has to be at least large enough to cover the strict bands specified through the StrictBands= and bandwidth-sharing bands specified in QuantumBytes=. @@ -3590,7 +3591,7 @@ Token=prefixstable:2002:da8:1:: StrictBands= Specifies the number of bands that should be created in strict mode. An unsigned integer in - the range 1–16. + the range 1…16. @@ -3962,7 +3963,7 @@ Token=prefixstable:2002:da8:1:: PacketLimit= Specifies the hard limit on the queue size in number of packets. When this limit is reached, - incoming packets are dropped. An unsigned integer in the range 0–4294967294. Defaults to unset and + incoming packets are dropped. An unsigned integer in the range 0…4294967294. Defaults to unset and kernel's default is used. @@ -4019,8 +4020,8 @@ Token=prefixstable:2002:da8:1:: VLAN= - The VLAN ID allowed on the port. This can be either a single ID or a range M-N. VLAN IDs are valid - from 1 to 4094. + The VLAN ID allowed on the port. This can be either a single ID or a range M-N. Takes + an integer in the range 1…4094. From 025cd94e1c8ba4685acf7a8517edb00caaa8679b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 04:05:02 +0900 Subject: [PATCH 04/15] network: tc/cake: introduce AutoRateIngress= setting --- man/systemd.network.xml | 10 +++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 76 +++++++++++++++++++ src/network/tc/cake.h | 7 +- .../fuzz-network-parser/directives.network | 1 + 5 files changed, 94 insertions(+), 1 deletion(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 39acb2a6a9..4ace6d60d8 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3472,6 +3472,16 @@ Token=prefixstable:2002:da8:1:: + + AutoRateIngress= + + Takes a boolean value. Enables automatic capacity estimation based on traffic arriving + at this qdisc. This is most likely to be useful with cellular links, which tend to change + quality randomly. If this setting is enabled, the Bandwidth= setting is + used as an initial estimate. Defaults to unset, and the kernel's default is used. + + + OverheadBytes= diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 1f0a625183..c34b3e1812 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -386,6 +386,7 @@ BFIFO.LimitBytes, config_parse_bfifo_size, CAKE.Parent, config_parse_qdisc_parent, QDISC_KIND_CAKE, 0 CAKE.Handle, config_parse_qdisc_handle, QDISC_KIND_CAKE, 0 CAKE.Bandwidth, config_parse_cake_bandwidth, QDISC_KIND_CAKE, 0 +CAKE.AutoRateIngress, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.OverheadBytes, config_parse_cake_overhead, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 70dd095e93..0f77036fd8 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -11,6 +11,18 @@ #include "qdisc.h" #include "string-util.h" +static int cake_init(QDisc *qdisc) { + CommonApplicationsKeptEnhanced *c; + + assert(qdisc); + + c = CAKE(qdisc); + + c->autorate = -1; + + return 0; +} + static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) { CommonApplicationsKeptEnhanced *c; int r; @@ -31,6 +43,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_BASE_RATE64 attribute: %m"); } + if (c->autorate >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_AUTORATE, c->autorate); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_AUTORATE attribute: %m"); + } + r = sd_netlink_message_append_s32(req, TCA_CAKE_OVERHEAD, c->overhead); if (r < 0) return log_link_error_errno(link, r, "Could not append TCA_CAKE_OVERHEAD attribute: %m"); @@ -156,8 +174,66 @@ int config_parse_cake_overhead( return 0; } +int config_parse_cake_tristate( + 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_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; + CommonApplicationsKeptEnhanced *c; + Network *network = data; + int *dest, r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + return 0; + } + + c = CAKE(qdisc); + + if (streq(lvalue, "AutoRateIngress")) + dest = &c->autorate; + else + assert_not_reached(); + + if (isempty(rvalue)) { + *dest = -1; + TAKE_PTR(qdisc); + return 0; + } + + r = parse_boolean(rvalue); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + *dest = r; + TAKE_PTR(qdisc); + return 0; +} + const QDiscVTable cake_vtable = { .object_size = sizeof(CommonApplicationsKeptEnhanced), .tca_kind = "cake", + .init = cake_init, .fill_message = cake_fill_message, }; diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 1da28b7d20..ba9dcb9a08 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -8,9 +8,13 @@ typedef struct CommonApplicationsKeptEnhanced { QDisc meta; - int overhead; + /* Shaper parameters */ + int autorate; uint64_t bandwidth; + /* Overhead compensation parameters */ + int overhead; + } CommonApplicationsKeptEnhanced; DEFINE_QDISC_CAST(CAKE, CommonApplicationsKeptEnhanced); @@ -18,3 +22,4 @@ extern const QDiscVTable cake_vtable; CONFIG_PARSER_PROTOTYPE(config_parse_cake_bandwidth); CONFIG_PARSER_PROTOTYPE(config_parse_cake_overhead); +CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 2ff20e0f08..83e9fa9054 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -468,6 +468,7 @@ ECN= Parent= Handle= Bandwidth= +AutoRateIngress= OverheadBytes= [TrafficControlQueueingDiscipline] Parent= From 3a86a31e0c1d650ac6c5ca37d3b799f5b6692a4b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 04:14:08 +0900 Subject: [PATCH 05/15] network: tc/cake: do not pass 0 if OverheadBytes= is not specified --- src/network/tc/cake.c | 11 +++++++---- src/network/tc/cake.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 0f77036fd8..813a679bf7 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -49,9 +49,11 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_AUTORATE attribute: %m"); } - r = sd_netlink_message_append_s32(req, TCA_CAKE_OVERHEAD, c->overhead); - if (r < 0) - return log_link_error_errno(link, r, "Could not append TCA_CAKE_OVERHEAD attribute: %m"); + if (c->overhead_set) { + r = sd_netlink_message_append_s32(req, TCA_CAKE_OVERHEAD, c->overhead); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_OVERHEAD attribute: %m"); + } r = sd_netlink_message_close_container(req); if (r < 0) @@ -150,7 +152,7 @@ int config_parse_cake_overhead( c = CAKE(qdisc); if (isempty(rvalue)) { - c->overhead = 0; + c->overhead_set = false; TAKE_PTR(qdisc); return 0; } @@ -170,6 +172,7 @@ int config_parse_cake_overhead( } c->overhead = v; + c->overhead_set = true; TAKE_PTR(qdisc); return 0; } diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index ba9dcb9a08..08fa3c266b 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -13,6 +13,7 @@ typedef struct CommonApplicationsKeptEnhanced { uint64_t bandwidth; /* Overhead compensation parameters */ + bool overhead_set; int overhead; } CommonApplicationsKeptEnhanced; From b6eccfda1ae5fb1e5db61a2d642666f9b70a2b59 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 04:50:00 +0900 Subject: [PATCH 06/15] network: tc/cake: introduce CompensationMode= setting --- man/systemd.network.xml | 12 ++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 69 +++++++++++++++++++ src/network/tc/cake.h | 12 ++++ .../fuzz-network-parser/directives.network | 1 + 5 files changed, 95 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 4ace6d60d8..9a8d13d6c5 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3491,6 +3491,18 @@ Token=prefixstable:2002:da8:1:: + + CompensationMode= + + Takes one of none, atm, or ptm. + Specifies the compensation mode for overhead calculation. When none, no + compensation is taken into account. When atm, enables the compensation for + ATM cell framing, which is normally found on ADSL links. When ptm, enables + the compensation for PTM encoding, which is normally found on VDSL2 links and uses a 64b/65b + encoding scheme. Defaults to unset and the kernel's default is used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index c34b3e1812..2d0e1f833f 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -388,6 +388,7 @@ CAKE.Handle, config_parse_qdisc_handle, CAKE.Bandwidth, config_parse_cake_bandwidth, QDISC_KIND_CAKE, 0 CAKE.AutoRateIngress, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.OverheadBytes, config_parse_cake_overhead, QDISC_KIND_CAKE, 0 +CAKE.CompensationMode, config_parse_cake_compensation_mode, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 813a679bf7..fe007c00fd 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -9,6 +9,7 @@ #include "netlink-util.h" #include "parse-util.h" #include "qdisc.h" +#include "string-table.h" #include "string-util.h" static int cake_init(QDisc *qdisc) { @@ -19,6 +20,7 @@ static int cake_init(QDisc *qdisc) { c = CAKE(qdisc); c->autorate = -1; + c->compensation_mode = _CAKE_COMPENSATION_MODE_INVALID; return 0; } @@ -55,6 +57,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_OVERHEAD attribute: %m"); } + if (c->compensation_mode >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_ATM, c->compensation_mode); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_ATM attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -234,6 +242,67 @@ int config_parse_cake_tristate( return 0; } +static const char * const cake_compensation_mode_table[_CAKE_COMPENSATION_MODE_MAX] = { + [CAKE_COMPENSATION_MODE_NONE] = "none", + [CAKE_COMPENSATION_MODE_ATM] = "atm", + [CAKE_COMPENSATION_MODE_PTM] = "ptm", +}; + +DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(cake_compensation_mode, CakeCompensationMode); + +int config_parse_cake_compensation_mode( + 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_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; + CommonApplicationsKeptEnhanced *c; + Network *network = data; + CakeCompensationMode mode; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + return 0; + } + + c = CAKE(qdisc); + + if (isempty(rvalue)) { + c->compensation_mode = _CAKE_COMPENSATION_MODE_INVALID; + TAKE_PTR(qdisc); + return 0; + } + + mode = cake_compensation_mode_from_string(rvalue); + if (mode < 0) { + log_syntax(unit, LOG_WARNING, filename, line, mode, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + c->compensation_mode = mode; + TAKE_PTR(qdisc); + return 0; +} + const QDiscVTable cake_vtable = { .object_size = sizeof(CommonApplicationsKeptEnhanced), .tca_kind = "cake", diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 08fa3c266b..549b4e3c80 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -2,9 +2,19 @@ * Copyright © 2020 VMware, Inc. */ #pragma once +#include + #include "conf-parser.h" #include "qdisc.h" +typedef enum CakeCompensationMode { + CAKE_COMPENSATION_MODE_NONE = CAKE_ATM_NONE, + CAKE_COMPENSATION_MODE_ATM = CAKE_ATM_ATM, + CAKE_COMPENSATION_MODE_PTM = CAKE_ATM_PTM, + _CAKE_COMPENSATION_MODE_MAX, + _CAKE_COMPENSATION_MODE_INVALID = -EINVAL, +} CakeCompensationMode; + typedef struct CommonApplicationsKeptEnhanced { QDisc meta; @@ -15,6 +25,7 @@ typedef struct CommonApplicationsKeptEnhanced { /* Overhead compensation parameters */ bool overhead_set; int overhead; + CakeCompensationMode compensation_mode; } CommonApplicationsKeptEnhanced; @@ -24,3 +35,4 @@ extern const QDiscVTable cake_vtable; CONFIG_PARSER_PROTOTYPE(config_parse_cake_bandwidth); CONFIG_PARSER_PROTOTYPE(config_parse_cake_overhead); CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate); +CONFIG_PARSER_PROTOTYPE(config_parse_cake_compensation_mode); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 83e9fa9054..79ca97c90b 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -470,6 +470,7 @@ Handle= Bandwidth= AutoRateIngress= OverheadBytes= +CompensationMode= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From a049cf166ca8b778df32169d6912d4483ffaa7ec Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 05:48:15 +0900 Subject: [PATCH 07/15] network: tc/cake: introduce FlowIsolationMode= setting --- man/systemd.network.xml | 84 +++++++++++++++++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 73 ++++++++++++++++ src/network/tc/cake.h | 17 ++++ .../fuzz-network-parser/directives.network | 1 + 5 files changed, 176 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 9a8d13d6c5..c13b5fed4b 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3503,6 +3503,90 @@ Token=prefixstable:2002:da8:1:: + + FlowIsolationMode= + + CAKE places packets from different flows into different queues, then packets from each + queue are delivered fairly. This specifies whether the fairness is based on source address, + destination address, individual flows, or any combination of those. The available values are: + + + + + + + The flow isolation is disabled, and all traffic passes through a single queue. + + + + + + Flows are defined only by source address. Equivalnet to the srchost + option for tc qdisc command. See also + tc-cake8. + + + + + + Flows are defined only by destination address. Equivalnet to the + srchost option for tc qdisc command. See also + tc-cake8. + + + + + + Flows are defined by source-destination host pairs. Equivalent to the same option for + tc qdisc command. See also + tc-cake8. + + + + + + Flows are defined by the entire 5-tuple of source address, destination address, + transport protocol, source port and destination port. Equivalent to the same option for + tc qdisc command. See also + tc-cake8. + + + + + + Flows are defined by the 5-tuple (see flows in the above), and + fairness is applied first over source addresses, then over individual flows. Equivalnet + to the dual-srchost option for tc qdisc command. + See also + tc-cake8. + + + + + + Flows are defined by the 5-tuple (see flows in the above), and + fairness is applied first over destination addresses, then over individual flows. + Equivalnet to the dual-dsthost option for + tc qdisc command. See also + tc-cake8. + + + + + + Flows are defined by the 5-tuple (see flows), and fairness is + applied over source and destination addresses, and also over individual flows. + Equivalnet to the triple-isolate option for + tc qdisc command. See also + tc-cake8. + + + + + Defaults to unset and the kernel's default is used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 2d0e1f833f..eaef3ec03f 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -389,6 +389,7 @@ CAKE.Bandwidth, config_parse_cake_bandwidth, CAKE.AutoRateIngress, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.OverheadBytes, config_parse_cake_overhead, QDISC_KIND_CAKE, 0 CAKE.CompensationMode, config_parse_cake_compensation_mode, QDISC_KIND_CAKE, 0 +CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mode, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index fe007c00fd..39280ff6c8 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -21,6 +21,7 @@ static int cake_init(QDisc *qdisc) { c->autorate = -1; c->compensation_mode = _CAKE_COMPENSATION_MODE_INVALID; + c->flow_isolation_mode = _CAKE_FLOW_ISOLATION_MODE_INVALID; return 0; } @@ -63,6 +64,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_ATM attribute: %m"); } + if (c->flow_isolation_mode >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_FLOW_MODE, c->flow_isolation_mode); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_FLOW_MODE attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -303,6 +310,72 @@ int config_parse_cake_compensation_mode( return 0; } +static const char * const cake_flow_isolation_mode_table[_CAKE_FLOW_ISOLATION_MODE_MAX] = { + [CAKE_FLOW_ISOLATION_MODE_NONE] = "none", + [CAKE_FLOW_ISOLATION_MODE_SRC_IP] = "src-host", + [CAKE_FLOW_ISOLATION_MODE_DST_IP] = "dst-host", + [CAKE_FLOW_ISOLATION_MODE_HOSTS] = "hosts", + [CAKE_FLOW_ISOLATION_MODE_FLOWS] = "flows", + [CAKE_FLOW_ISOLATION_MODE_DUAL_SRC] = "dual-src-host", + [CAKE_FLOW_ISOLATION_MODE_DUAL_DST] = "dual-dst-host", + [CAKE_FLOW_ISOLATION_MODE_TRIPLE] = "triple", +}; + +DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(cake_flow_isolation_mode, CakeFlowIsolationMode); + +int config_parse_cake_flow_isolation_mode( + 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_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; + CommonApplicationsKeptEnhanced *c; + Network *network = data; + CakeFlowIsolationMode mode; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + return 0; + } + + c = CAKE(qdisc); + + if (isempty(rvalue)) { + c->flow_isolation_mode = _CAKE_FLOW_ISOLATION_MODE_INVALID; + TAKE_PTR(qdisc); + return 0; + } + + mode = cake_flow_isolation_mode_from_string(rvalue); + if (mode < 0) { + log_syntax(unit, LOG_WARNING, filename, line, mode, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + c->flow_isolation_mode = mode; + TAKE_PTR(qdisc); + return 0; +} + const QDiscVTable cake_vtable = { .object_size = sizeof(CommonApplicationsKeptEnhanced), .tca_kind = "cake", diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 549b4e3c80..9272357df7 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -15,6 +15,19 @@ typedef enum CakeCompensationMode { _CAKE_COMPENSATION_MODE_INVALID = -EINVAL, } CakeCompensationMode; +typedef enum CakeFlowIsolationMode { + CAKE_FLOW_ISOLATION_MODE_NONE = CAKE_FLOW_NONE, + CAKE_FLOW_ISOLATION_MODE_SRC_IP = CAKE_FLOW_SRC_IP, + CAKE_FLOW_ISOLATION_MODE_DST_IP = CAKE_FLOW_DST_IP, + CAKE_FLOW_ISOLATION_MODE_HOSTS = CAKE_FLOW_HOSTS, + CAKE_FLOW_ISOLATION_MODE_FLOWS = CAKE_FLOW_FLOWS, + CAKE_FLOW_ISOLATION_MODE_DUAL_SRC = CAKE_FLOW_DUAL_SRC, + CAKE_FLOW_ISOLATION_MODE_DUAL_DST = CAKE_FLOW_DUAL_DST, + CAKE_FLOW_ISOLATION_MODE_TRIPLE = CAKE_FLOW_TRIPLE, + _CAKE_FLOW_ISOLATION_MODE_MAX, + _CAKE_FLOW_ISOLATION_MODE_INVALID = -EINVAL, +} CakeFlowIsolationMode; + typedef struct CommonApplicationsKeptEnhanced { QDisc meta; @@ -27,6 +40,9 @@ typedef struct CommonApplicationsKeptEnhanced { int overhead; CakeCompensationMode compensation_mode; + /* Flow isolation parameters */ + CakeFlowIsolationMode flow_isolation_mode; + } CommonApplicationsKeptEnhanced; DEFINE_QDISC_CAST(CAKE, CommonApplicationsKeptEnhanced); @@ -36,3 +52,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_cake_bandwidth); CONFIG_PARSER_PROTOTYPE(config_parse_cake_overhead); CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate); CONFIG_PARSER_PROTOTYPE(config_parse_cake_compensation_mode); +CONFIG_PARSER_PROTOTYPE(config_parse_cake_flow_isolation_mode); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 79ca97c90b..b0db8d88d1 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -471,6 +471,7 @@ Bandwidth= AutoRateIngress= OverheadBytes= CompensationMode= +FlowIsolationMode= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From 4bff8086489a1db4e506d3c807ccddc2e88e4b03 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Nov 2021 05:55:54 +0900 Subject: [PATCH 08/15] network: tc/cake: introduce NAT= setting --- man/systemd.network.xml | 12 ++++++++++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 9 +++++++++ src/network/tc/cake.h | 1 + test/fuzz/fuzz-network-parser/directives.network | 1 + 5 files changed, 24 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index c13b5fed4b..13eb06fdca 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3587,6 +3587,18 @@ Token=prefixstable:2002:da8:1:: + + NAT= + + Takes a boolean value. When true, CAKE performs a NAT lookup before applying + flow-isolation rules, to determine the true addresses and port numbers of the packet, to + improve fairness between hosts inside the NAT. This has no practical effect when + FlowIsolationMode= is none or flows, + or if NAT is performed on a different host. Defaults to unset, and the kernel's default is + used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index eaef3ec03f..1fe4b72b5f 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -390,6 +390,7 @@ CAKE.AutoRateIngress, config_parse_cake_tristate, CAKE.OverheadBytes, config_parse_cake_overhead, QDISC_KIND_CAKE, 0 CAKE.CompensationMode, config_parse_cake_compensation_mode, QDISC_KIND_CAKE, 0 CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mode, QDISC_KIND_CAKE, 0 +CAKE.NAT, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 39280ff6c8..27395918ea 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -22,6 +22,7 @@ static int cake_init(QDisc *qdisc) { c->autorate = -1; c->compensation_mode = _CAKE_COMPENSATION_MODE_INVALID; c->flow_isolation_mode = _CAKE_FLOW_ISOLATION_MODE_INVALID; + c->nat = -1; return 0; } @@ -70,6 +71,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_FLOW_MODE attribute: %m"); } + if (c->nat >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_NAT, c->nat); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_NAT attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -227,6 +234,8 @@ int config_parse_cake_tristate( if (streq(lvalue, "AutoRateIngress")) dest = &c->autorate; + else if (streq(lvalue, "NAT")) + dest = &c->nat; else assert_not_reached(); diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 9272357df7..1be8cacbe9 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -42,6 +42,7 @@ typedef struct CommonApplicationsKeptEnhanced { /* Flow isolation parameters */ CakeFlowIsolationMode flow_isolation_mode; + int nat; } CommonApplicationsKeptEnhanced; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index b0db8d88d1..5d0d0968e7 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -472,6 +472,7 @@ AutoRateIngress= OverheadBytes= CompensationMode= FlowIsolationMode= +NAT= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From 863542e1ce105907b595e7caf090c484297e2572 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 04:16:20 +0900 Subject: [PATCH 09/15] network: tc/cake: introduce MPUBytes= setting --- man/systemd.network.xml | 8 +++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 65 +++++++++++++++++++ src/network/tc/cake.h | 2 + .../fuzz-network-parser/directives.network | 1 + 5 files changed, 77 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 13eb06fdca..b82efd4394 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3491,6 +3491,14 @@ Token=prefixstable:2002:da8:1:: + + MPUBytes= + + Rounds each packet (including overhead) up to the specified bytes. Takes an integer in + the range 1…256. Defaults to unset and kernel's default is used. + + + CompensationMode= diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 1fe4b72b5f..1c09f300bd 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -388,6 +388,7 @@ CAKE.Handle, config_parse_qdisc_handle, CAKE.Bandwidth, config_parse_cake_bandwidth, QDISC_KIND_CAKE, 0 CAKE.AutoRateIngress, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.OverheadBytes, config_parse_cake_overhead, QDISC_KIND_CAKE, 0 +CAKE.MPUBytes, config_parse_cake_mpu, QDISC_KIND_CAKE, 0 CAKE.CompensationMode, config_parse_cake_compensation_mode, QDISC_KIND_CAKE, 0 CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mode, QDISC_KIND_CAKE, 0 CAKE.NAT, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 27395918ea..7641574fd8 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -59,6 +59,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_OVERHEAD attribute: %m"); } + if (c->mpu > 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_MPU, c->mpu); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_MPU attribute: %m"); + } + if (c->compensation_mode >= 0) { r = sd_netlink_message_append_u32(req, TCA_CAKE_ATM, c->compensation_mode); if (r < 0) @@ -199,6 +205,65 @@ int config_parse_cake_overhead( return 0; } +int config_parse_cake_mpu( + 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_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; + CommonApplicationsKeptEnhanced *c; + Network *network = data; + uint32_t v; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + return 0; + } + + c = CAKE(qdisc); + + if (isempty(rvalue)) { + c->mpu = 0; + TAKE_PTR(qdisc); + return 0; + } + + r = safe_atou32(rvalue, &v); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + if (v <= 0 || v > 256) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Invalid '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + c->mpu = v; + TAKE_PTR(qdisc); + return 0; +} + int config_parse_cake_tristate( const char *unit, const char *filename, diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 1be8cacbe9..c8defb505e 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -38,6 +38,7 @@ typedef struct CommonApplicationsKeptEnhanced { /* Overhead compensation parameters */ bool overhead_set; int overhead; + uint32_t mpu; CakeCompensationMode compensation_mode; /* Flow isolation parameters */ @@ -51,6 +52,7 @@ extern const QDiscVTable cake_vtable; CONFIG_PARSER_PROTOTYPE(config_parse_cake_bandwidth); CONFIG_PARSER_PROTOTYPE(config_parse_cake_overhead); +CONFIG_PARSER_PROTOTYPE(config_parse_cake_mpu); CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate); CONFIG_PARSER_PROTOTYPE(config_parse_cake_compensation_mode); CONFIG_PARSER_PROTOTYPE(config_parse_cake_flow_isolation_mode); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 5d0d0968e7..de6d460eb1 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -470,6 +470,7 @@ Handle= Bandwidth= AutoRateIngress= OverheadBytes= +MPUBytes= CompensationMode= FlowIsolationMode= NAT= From fe8e156e7ab334ab59725b6cd4834952b731f4d6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 04:59:37 +0900 Subject: [PATCH 10/15] network: tc/cake: introduce PriorityQueueingProfile= setting --- man/systemd.network.xml | 53 ++++++++++++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 70 +++++++++++++++++++ src/network/tc/cake.h | 14 ++++ .../fuzz-network-parser/directives.network | 1 + 5 files changed, 139 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index b82efd4394..31fa8d31ff 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3607,6 +3607,59 @@ Token=prefixstable:2002:da8:1:: + + PriorityQueueingPreset= + + CAKE divides traffic into tins, and each tin has its own independent + set of flow-isolation queues, bandwidth threshold, and priority. This specifies the preset of + tin profiles. The available values are: + + + + + + Disables priority queueing by placing all traffic in one tin. + + + + + + Enables priority queueing based on the legacy interpretation of TOS + Precedence field. Use of this preset on the modern Internet is + firmly discouraged. + + + + + + Enables priority queueing based on the Differentiated Service + (DiffServ) field with eight tins: Background Traffic, High + Throughput, Best Effort, Video Streaming, Low Latency Transactions, Interactive Shell, + Minimum Latency, and Network Control. + + + + + + Enables priority queueing based on the Differentiated Service + (DiffServ) field with four tins: Background Traffic, Best Effort, + Streaming Media, and Latency Sensitive. + + + + + + Enables priority queueing based on the Differentiated Service + (DiffServ) field with three tins: Background Traffic, Best Effort, + and Latency Sensitive. + + + + + Defaults to unset, and the kernel's default is used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 1c09f300bd..0404f91123 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -392,6 +392,7 @@ CAKE.MPUBytes, config_parse_cake_mpu, CAKE.CompensationMode, config_parse_cake_compensation_mode, QDISC_KIND_CAKE, 0 CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mode, QDISC_KIND_CAKE, 0 CAKE.NAT, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 +CAKE.PriorityQueueingPreset, config_parse_cake_priority_queueing_preset, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 7641574fd8..cd03f8feac 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -23,6 +23,7 @@ static int cake_init(QDisc *qdisc) { c->compensation_mode = _CAKE_COMPENSATION_MODE_INVALID; c->flow_isolation_mode = _CAKE_FLOW_ISOLATION_MODE_INVALID; c->nat = -1; + c->preset = _CAKE_PRESET_INVALID; return 0; } @@ -83,6 +84,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_NAT attribute: %m"); } + if (c->preset >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_DIFFSERV_MODE, c->preset); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_DIFFSERV_MODE attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -450,6 +457,69 @@ int config_parse_cake_flow_isolation_mode( return 0; } +static const char * const cake_priority_queueing_preset_table[_CAKE_PRESET_MAX] = { + [CAKE_PRESET_DIFFSERV3] = "diffserv3", + [CAKE_PRESET_DIFFSERV4] = "diffserv4", + [CAKE_PRESET_DIFFSERV8] = "diffserv8", + [CAKE_PRESET_BESTEFFORT] = "besteffort", + [CAKE_PRESET_PRECEDENCE] = "precedence", +}; + +DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(cake_priority_queueing_preset, CakePriorityQueueingPreset); + +int config_parse_cake_priority_queueing_preset( + 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_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; + CommonApplicationsKeptEnhanced *c; + CakePriorityQueueingPreset preset; + Network *network = data; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + return 0; + } + + c = CAKE(qdisc); + + if (isempty(rvalue)) { + c->preset = _CAKE_PRESET_INVALID; + TAKE_PTR(qdisc); + return 0; + } + + preset = cake_priority_queueing_preset_from_string(rvalue); + if (preset < 0) { + log_syntax(unit, LOG_WARNING, filename, line, preset, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + c->preset = preset; + TAKE_PTR(qdisc); + return 0; +} + const QDiscVTable cake_vtable = { .object_size = sizeof(CommonApplicationsKeptEnhanced), .tca_kind = "cake", diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index c8defb505e..a14cb6b806 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -28,6 +28,16 @@ typedef enum CakeFlowIsolationMode { _CAKE_FLOW_ISOLATION_MODE_INVALID = -EINVAL, } CakeFlowIsolationMode; +typedef enum CakePriorityQueueingPreset { + CAKE_PRESET_DIFFSERV3 = CAKE_DIFFSERV_DIFFSERV3, + CAKE_PRESET_DIFFSERV4 = CAKE_DIFFSERV_DIFFSERV4, + CAKE_PRESET_DIFFSERV8 = CAKE_DIFFSERV_DIFFSERV8, + CAKE_PRESET_BESTEFFORT = CAKE_DIFFSERV_BESTEFFORT, + CAKE_PRESET_PRECEDENCE = CAKE_DIFFSERV_PRECEDENCE, + _CAKE_PRESET_MAX, + _CAKE_PRESET_INVALID = -EINVAL, +} CakePriorityQueueingPreset; + typedef struct CommonApplicationsKeptEnhanced { QDisc meta; @@ -45,6 +55,9 @@ typedef struct CommonApplicationsKeptEnhanced { CakeFlowIsolationMode flow_isolation_mode; int nat; + /* Priority queue parameters */ + CakePriorityQueueingPreset preset; + } CommonApplicationsKeptEnhanced; DEFINE_QDISC_CAST(CAKE, CommonApplicationsKeptEnhanced); @@ -56,3 +69,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_cake_mpu); CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate); CONFIG_PARSER_PROTOTYPE(config_parse_cake_compensation_mode); CONFIG_PARSER_PROTOTYPE(config_parse_cake_flow_isolation_mode); +CONFIG_PARSER_PROTOTYPE(config_parse_cake_priority_queueing_preset); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index de6d460eb1..e4734af879 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -474,6 +474,7 @@ MPUBytes= CompensationMode= FlowIsolationMode= NAT= +PriorityQueueingPreset= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From 049b66ccdd096173c0806903cb9d263605acdcbb Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 05:13:20 +0900 Subject: [PATCH 11/15] network: tc/cake: introduce FirewallMark= setting --- man/systemd.network.xml | 9 +++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 65 +++++++++++++++++++ src/network/tc/cake.h | 2 + .../fuzz-network-parser/directives.network | 1 + 5 files changed, 78 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 31fa8d31ff..3cc9e8e778 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3660,6 +3660,15 @@ Token=prefixstable:2002:da8:1:: + + FirewallMark= + + Takes an integer in the range 1…4294967295. When specified, firewall-mark-based + overriding of CAKE's tin selection is enabled. Defaults to unset, and the kernel's default is + used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 0404f91123..f7866cbc14 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -393,6 +393,7 @@ CAKE.CompensationMode, config_parse_cake_compensation_mode CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mode, QDISC_KIND_CAKE, 0 CAKE.NAT, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.PriorityQueueingPreset, config_parse_cake_priority_queueing_preset, QDISC_KIND_CAKE, 0 +CAKE.FirewallMark, config_parse_cake_fwmark, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index cd03f8feac..598a019ac2 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -90,6 +90,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_DIFFSERV_MODE attribute: %m"); } + if (c->fwmark > 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_FWMARK, c->fwmark); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_FWMARK attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -520,6 +526,65 @@ int config_parse_cake_priority_queueing_preset( return 0; } +int config_parse_cake_fwmark( + 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_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL; + CommonApplicationsKeptEnhanced *c; + Network *network = data; + uint32_t fwmark; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + return 0; + } + + c = CAKE(qdisc); + + if (isempty(rvalue)) { + c->fwmark = 0; + TAKE_PTR(qdisc); + return 0; + } + + r = safe_atou32(rvalue, &fwmark); + if (r < 0) { + log_syntax(unit, LOG_WARNING, filename, line, r, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + if (fwmark <= 0) { + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Invalid '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + c->fwmark = fwmark; + TAKE_PTR(qdisc); + return 0; +} + const QDiscVTable cake_vtable = { .object_size = sizeof(CommonApplicationsKeptEnhanced), .tca_kind = "cake", diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index a14cb6b806..8743d592ad 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -57,6 +57,7 @@ typedef struct CommonApplicationsKeptEnhanced { /* Priority queue parameters */ CakePriorityQueueingPreset preset; + uint32_t fwmark; } CommonApplicationsKeptEnhanced; @@ -70,3 +71,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate); CONFIG_PARSER_PROTOTYPE(config_parse_cake_compensation_mode); CONFIG_PARSER_PROTOTYPE(config_parse_cake_flow_isolation_mode); CONFIG_PARSER_PROTOTYPE(config_parse_cake_priority_queueing_preset); +CONFIG_PARSER_PROTOTYPE(config_parse_cake_fwmark); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index e4734af879..de8bec2750 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -475,6 +475,7 @@ CompensationMode= FlowIsolationMode= NAT= PriorityQueueingPreset= +FirewallMark= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From d05dce95d87bc3070064e5a34486f8b2aff87d78 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 05:32:44 +0900 Subject: [PATCH 12/15] network: tc/cake: introduce Wash= setting --- man/systemd.network.xml | 8 ++++++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 9 +++++++++ src/network/tc/cake.h | 3 +++ test/fuzz/fuzz-network-parser/directives.network | 1 + 5 files changed, 22 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 3cc9e8e778..78c0f6cd57 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3669,6 +3669,14 @@ Token=prefixstable:2002:da8:1:: + + Wash= + + Takes a boolean value. When true, CAKE clears the DSCP fields, except for ECN bits, of + any packet passing through CAKE. Defaults to unset, and the kernel's default is used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index f7866cbc14..956d7b130e 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -394,6 +394,7 @@ CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mo CAKE.NAT, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.PriorityQueueingPreset, config_parse_cake_priority_queueing_preset, QDISC_KIND_CAKE, 0 CAKE.FirewallMark, config_parse_cake_fwmark, QDISC_KIND_CAKE, 0 +CAKE.Wash, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 598a019ac2..cad36dc237 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -24,6 +24,7 @@ static int cake_init(QDisc *qdisc) { c->flow_isolation_mode = _CAKE_FLOW_ISOLATION_MODE_INVALID; c->nat = -1; c->preset = _CAKE_PRESET_INVALID; + c->wash = -1; return 0; } @@ -96,6 +97,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_FWMARK attribute: %m"); } + if (c->wash >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_WASH, c->wash); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_WASH attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -314,6 +321,8 @@ int config_parse_cake_tristate( dest = &c->autorate; else if (streq(lvalue, "NAT")) dest = &c->nat; + else if (streq(lvalue, "Wash")) + dest = &c->wash; else assert_not_reached(); diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 8743d592ad..a947f9cdc7 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -59,6 +59,9 @@ typedef struct CommonApplicationsKeptEnhanced { CakePriorityQueueingPreset preset; uint32_t fwmark; + /* Other parameters */ + int wash; + } CommonApplicationsKeptEnhanced; DEFINE_QDISC_CAST(CAKE, CommonApplicationsKeptEnhanced); diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index de8bec2750..92c942c708 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -476,6 +476,7 @@ FlowIsolationMode= NAT= PriorityQueueingPreset= FirewallMark= +Wash= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From 35896db4895f68050c3edd2c58b913dcba4e0fd8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 05:38:13 +0900 Subject: [PATCH 13/15] network: tc/cake: introduce SplitGSO= setting --- man/systemd.network.xml | 9 +++++++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 9 +++++++++ src/network/tc/cake.h | 1 + test/fuzz/fuzz-network-parser/directives.network | 1 + 5 files changed, 21 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 78c0f6cd57..d844b205d4 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3677,6 +3677,15 @@ Token=prefixstable:2002:da8:1:: + + SplitGSO= + + Takes a boolean value. When true, CAKE will split General Segmentation Offload (GSO) + super-packets into their on-the-wire components and dequeue them individually. Defaults to + unset, and the kernel's default is used. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 956d7b130e..33a2f296d6 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -395,6 +395,7 @@ CAKE.NAT, config_parse_cake_tristate, CAKE.PriorityQueueingPreset, config_parse_cake_priority_queueing_preset, QDISC_KIND_CAKE, 0 CAKE.FirewallMark, config_parse_cake_fwmark, QDISC_KIND_CAKE, 0 CAKE.Wash, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 +CAKE.SplitGSO, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0 ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index cad36dc237..34e89c847b 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -25,6 +25,7 @@ static int cake_init(QDisc *qdisc) { c->nat = -1; c->preset = _CAKE_PRESET_INVALID; c->wash = -1; + c->split_gso = -1; return 0; } @@ -103,6 +104,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_WASH attribute: %m"); } + if (c->split_gso >= 0) { + r = sd_netlink_message_append_u32(req, TCA_CAKE_SPLIT_GSO, c->wash); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_SPLIT_GSO attribute: %m"); + } + r = sd_netlink_message_close_container(req); if (r < 0) return log_link_error_errno(link, r, "Could not close container TCA_OPTIONS: %m"); @@ -323,6 +330,8 @@ int config_parse_cake_tristate( dest = &c->nat; else if (streq(lvalue, "Wash")) dest = &c->wash; + else if (streq(lvalue, "SplitGSO")) + dest = &c->split_gso; else assert_not_reached(); diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index a947f9cdc7..165a17f53f 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -61,6 +61,7 @@ typedef struct CommonApplicationsKeptEnhanced { /* Other parameters */ int wash; + int split_gso; } CommonApplicationsKeptEnhanced; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 92c942c708..d6efeacd42 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -477,6 +477,7 @@ NAT= PriorityQueueingPreset= FirewallMark= Wash= +SplitGSO= [TrafficControlQueueingDiscipline] Parent= NetworkEmulatorDelaySec= From 1c7a81e6266688a0078defcd1957eccbbe834d07 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 10:04:47 +0900 Subject: [PATCH 14/15] network: tc/cake: introduce UseRawPacketSize= setting --- man/systemd.network.xml | 9 +++++++++ src/network/networkd-network-gperf.gperf | 1 + src/network/tc/cake.c | 10 ++++++++++ src/network/tc/cake.h | 1 + test/fuzz/fuzz-network-parser/directives.network | 1 + 5 files changed, 22 insertions(+) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index d844b205d4..e5e3fd0ba3 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -3511,6 +3511,15 @@ Token=prefixstable:2002:da8:1:: + + UseRawPacketSize= + + Takes a boolean value. When true, the packet size reported by the Linux kernel will be + used, instead of the underlying IP packet size. Defaults to unset, and the kernel's default + is used. + + + FlowIsolationMode= diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 33a2f296d6..901608beb4 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -390,6 +390,7 @@ CAKE.AutoRateIngress, config_parse_cake_tristate, CAKE.OverheadBytes, config_parse_cake_overhead, QDISC_KIND_CAKE, 0 CAKE.MPUBytes, config_parse_cake_mpu, QDISC_KIND_CAKE, 0 CAKE.CompensationMode, config_parse_cake_compensation_mode, QDISC_KIND_CAKE, 0 +CAKE.UseRawPacketSize, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.FlowIsolationMode, config_parse_cake_flow_isolation_mode, QDISC_KIND_CAKE, 0 CAKE.NAT, config_parse_cake_tristate, QDISC_KIND_CAKE, 0 CAKE.PriorityQueueingPreset, config_parse_cake_priority_queueing_preset, QDISC_KIND_CAKE, 0 diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c index 34e89c847b..27b7f8d9f6 100644 --- a/src/network/tc/cake.c +++ b/src/network/tc/cake.c @@ -21,6 +21,7 @@ static int cake_init(QDisc *qdisc) { c->autorate = -1; c->compensation_mode = _CAKE_COMPENSATION_MODE_INVALID; + c->raw = -1; c->flow_isolation_mode = _CAKE_FLOW_ISOLATION_MODE_INVALID; c->nat = -1; c->preset = _CAKE_PRESET_INVALID; @@ -74,6 +75,13 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) return log_link_error_errno(link, r, "Could not append TCA_CAKE_ATM attribute: %m"); } + if (c->raw > 0) { + /* TCA_CAKE_RAW attribute is mostly a flag, not boolean. */ + r = sd_netlink_message_append_u32(req, TCA_CAKE_RAW, 0); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_CAKE_RAW attribute: %m"); + } + if (c->flow_isolation_mode >= 0) { r = sd_netlink_message_append_u32(req, TCA_CAKE_FLOW_MODE, c->flow_isolation_mode); if (r < 0) @@ -326,6 +334,8 @@ int config_parse_cake_tristate( if (streq(lvalue, "AutoRateIngress")) dest = &c->autorate; + else if (streq(lvalue, "UseRawPacketSize")) + dest = &c->raw; else if (streq(lvalue, "NAT")) dest = &c->nat; else if (streq(lvalue, "Wash")) diff --git a/src/network/tc/cake.h b/src/network/tc/cake.h index 165a17f53f..ff68cedabf 100644 --- a/src/network/tc/cake.h +++ b/src/network/tc/cake.h @@ -50,6 +50,7 @@ typedef struct CommonApplicationsKeptEnhanced { int overhead; uint32_t mpu; CakeCompensationMode compensation_mode; + int raw; /* Flow isolation parameters */ CakeFlowIsolationMode flow_isolation_mode; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index d6efeacd42..fb8befe730 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -472,6 +472,7 @@ AutoRateIngress= OverheadBytes= MPUBytes= CompensationMode= +UseRawPacketSize= FlowIsolationMode= NAT= PriorityQueueingPreset= From 0b251e8bf96e3f79819436699e5d3226b0fcd200 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Nov 2021 05:50:42 +0900 Subject: [PATCH 15/15] test-network: add testcases for CAKE settings --- test/test-network/conf/25-qdisc-cake.network | 12 +++++++++++- test/test-network/systemd-networkd-tests.py | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/test/test-network/conf/25-qdisc-cake.network b/test/test-network/conf/25-qdisc-cake.network index 9220a20bf5..b13720c6dd 100644 --- a/test/test-network/conf/25-qdisc-cake.network +++ b/test/test-network/conf/25-qdisc-cake.network @@ -9,5 +9,15 @@ Address=10.1.2.3/16 [CAKE] Parent=root Handle=3a -OverheadBytes=128 Bandwidth=500M +AutoRateIngress=yes +OverheadBytes=128 +MPUBytes=20 +CompensationMode=atm +UseRawPacketSize=yes +FlowIsolationMode=dual-dst-host +NAT=yes +PriorityQueueingPreset=diffserv8 +FirewallMark=0xff00 +Wash=yes +SplitGSO=yes diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 9d12d6a609..a68055086c 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3262,9 +3262,19 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): output = check_output('tc qdisc show dev dummy98') print(output) - self.assertRegex(output, 'qdisc cake 3a: root') - self.assertRegex(output, 'bandwidth 500Mbit') - self.assertRegex(output, 'overhead 128') + self.assertIn('qdisc cake 3a: root', output) + self.assertIn('bandwidth 500Mbit', output) + self.assertIn('autorate-ingress', output) + self.assertIn('diffserv8', output) + self.assertIn('dual-dsthost', output) + self.assertIn(' nat', output) + self.assertIn(' wash', output) + self.assertIn(' split-gso', output) + self.assertIn(' raw', output) + self.assertIn(' atm', output) + self.assertIn('overhead 128', output) + self.assertIn('mpu 20', output) + self.assertIn('fwmark 0xff00', output) @expectedFailureIfPIEIsNotAvailable() def test_qdisc_pie(self):