From: Yu Watanabe Date: Wed, 3 Nov 2021 19:59:37 +0000 (+0900) Subject: network: tc/cake: introduce PriorityQueueingProfile= setting X-Git-Tag: v250-rc1~330^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe8e156e7ab334ab59725b6cd4834952b731f4d6;p=thirdparty%2Fsystemd.git network: tc/cake: introduce PriorityQueueingProfile= setting --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index b82efd4394c..31fa8d31ff0 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 1c09f300bd6..0404f911230 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 7641574fd8f..cd03f8feac7 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 c8defb505eb..a14cb6b8066 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 de6d460eb1f..e4734af8794 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=