summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@vmware.com>2019-12-07 20:48:18 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-12-10 16:06:31 +0100
commit4e5ef1491901959a251e13d6b84f481540ee1ed4 (patch)
tree44774195ff53a6d19594210f348783043e2ae9a0
parentnetwork tc: qdisc parent add support to set ingress (diff)
downloadsystemd-4e5ef1491901959a251e13d6b84f481540ee1ed4.tar.xz
systemd-4e5ef1491901959a251e13d6b84f481540ee1ed4.zip
network tc: Add support to conkfigure CoDel - Controlled-Delay Active Queue Management algorithm
``` $ tc qdisc show dev dummy99 qdisc fq_codel 8005: dev dummy99 root refcnt 2 limit 1000p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn $ network cat dumm99.network [Match] Name=dummy99 [TrafficControlQueueingDiscipline] Parent=root FairQueuingControlledDelayPacketLimit=1000 ```
-rw-r--r--man/systemd.network.xml8
-rw-r--r--src/network/meson.build2
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/tc/fq-codel.c91
-rw-r--r--src/network/tc/fq-codel.h17
-rw-r--r--src/network/tc/qdisc.c10
-rw-r--r--src/network/tc/qdisc.h3
-rw-r--r--test/fuzz/fuzz-network-parser/directives.network1
8 files changed, 133 insertions, 0 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index a23f0e6c23..acafa8a712 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -2442,6 +2442,14 @@
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>FairQueuingControlledDelayPacketLimit=</varname></term>
+ <listitem>
+ <para>Specifies the hard limit on the real queue size. When this limit is reached, incoming packets are
+ dropped. Defaults to unset and kernel's default is used.</para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
diff --git a/src/network/meson.build b/src/network/meson.build
index 8a09078315..41e482e7a1 100644
--- a/src/network/meson.build
+++ b/src/network/meson.build
@@ -107,6 +107,8 @@ sources = files('''
networkd-util.h
networkd-wifi.c
networkd-wifi.h
+ tc/fq-codel.c
+ tc/fq-codel.h
tc/netem.c
tc/netem.h
tc/qdisc.c
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index ea4ba31b80..e80f0afd8f 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -258,6 +258,7 @@ TrafficControlQueueingDiscipline.TokenBufferFilterMPUBytes, con
TrafficControlQueueingDiscipline.TokenBufferFilterPeakRate, config_parse_tc_token_buffer_filter_size, 0, 0
TrafficControlQueueingDiscipline.TokenBufferFilterLatencySec, config_parse_tc_token_buffer_filter_latency, 0, 0
TrafficControlQueueingDiscipline.StochasticFairnessQueueingPerturbPeriodSec, config_parse_tc_stochastic_fairness_queueing_perturb_period, 0, 0
+TrafficControlQueueingDiscipline.FairQueuingControlledDelayPacketLimit, config_parse_tc_fair_queuing_controlled_delay_limit, 0, 0
/* backwards compatibility: do not add new entries to this section */
Network.IPv4LL, config_parse_ipv4ll, 0, offsetof(Network, link_local)
DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier)
diff --git a/src/network/tc/fq-codel.c b/src/network/tc/fq-codel.c
new file mode 100644
index 0000000000..174d70e1f7
--- /dev/null
+++ b/src/network/tc/fq-codel.c
@@ -0,0 +1,91 @@
+/* SPDX-License-Identifier: LGPL-2.1+
+ * Copyright © 2019 VMware, Inc. */
+
+#include <linux/pkt_sched.h>
+
+#include "alloc-util.h"
+#include "conf-parser.h"
+#include "netlink-util.h"
+#include "parse-util.h"
+#include "qdisc.h"
+#include "string-util.h"
+
+int fair_queuing_controlled_delay_new(FairQueuingControlledDelay **ret) {
+ FairQueuingControlledDelay *fqcd = NULL;
+
+ fqcd = new0(FairQueuingControlledDelay, 1);
+ if (!fqcd)
+ return -ENOMEM;
+
+ *ret = TAKE_PTR(fqcd);
+
+ return 0;
+}
+
+int fair_queuing_controlled_delay_fill_message(Link *link, const FairQueuingControlledDelay *fqcd, sd_netlink_message *req) {
+ int r;
+
+ assert(link);
+ assert(fqcd);
+ assert(req);
+
+ r = sd_netlink_message_open_array(req, TCA_OPTIONS);
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not open container TCA_OPTIONS: %m");
+
+ r = sd_netlink_message_append_data(req, TCA_FQ_CODEL_LIMIT, &fqcd->limit, sizeof(fqcd->limit));
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not append TCA_FQ_CODEL_LIMIT 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");
+
+ return 0;
+}
+
+int config_parse_tc_fair_queuing_controlled_delay_limit(
+ 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;
+ Network *network = data;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ r = qdisc_new_static(network, filename, section_line, &qdisc);
+ if (r < 0)
+ return r;
+
+ if (isempty(rvalue)) {
+ qdisc->fq_codel.limit = 0;
+
+ qdisc = NULL;
+ return 0;
+ }
+
+ r = safe_atou32(rvalue, &qdisc->fq_codel.limit);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r,
+ "Failed to parse '%s=', ignoring assignment: %s",
+ lvalue, rvalue);
+ return 0;
+ }
+
+ qdisc->has_fair_queuing_controlled_delay = true;
+ qdisc = NULL;
+
+ return 0;
+}
diff --git a/src/network/tc/fq-codel.h b/src/network/tc/fq-codel.h
new file mode 100644
index 0000000000..0ddb5099a8
--- /dev/null
+++ b/src/network/tc/fq-codel.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: LGPL-2.1+
+ * Copyright © 2019 VMware, Inc. */
+#pragma once
+
+#include "sd-netlink.h"
+
+#include "conf-parser.h"
+#include "networkd-link.h"
+
+typedef struct FairQueuingControlledDelay {
+ uint32_t limit;
+} FairQueuingControlledDelay;
+
+int fair_queuing_controlled_delay_new(FairQueuingControlledDelay **ret);
+int fair_queuing_controlled_delay_fill_message(Link *link, const FairQueuingControlledDelay *sfq, sd_netlink_message *req);
+
+CONFIG_PARSER_PROTOTYPE(config_parse_tc_fair_queuing_controlled_delay_limit);
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
index 57e3025d7c..d066e0713f 100644
--- a/src/network/tc/qdisc.c
+++ b/src/network/tc/qdisc.c
@@ -169,6 +169,16 @@ int qdisc_configure(Link *link, QDisc *qdisc) {
return r;
}
+ if (qdisc->has_fair_queuing_controlled_delay) {
+ r = free_and_strdup(&tca_kind, "fq_codel");
+ if (r < 0)
+ return log_oom();
+
+ r = fair_queuing_controlled_delay_fill_message(link, &qdisc->fq_codel, req);
+ if (r < 0)
+ return r;
+ }
+
p = tca_kind ?:qdisc->tca_kind;
if (p) {
r = sd_netlink_message_append_string(req, TCA_KIND, p);
diff --git a/src/network/tc/qdisc.h b/src/network/tc/qdisc.h
index cc68bdfaa7..53968bcf1f 100644
--- a/src/network/tc/qdisc.h
+++ b/src/network/tc/qdisc.h
@@ -3,6 +3,7 @@
#pragma once
#include "conf-parser.h"
+#include "fq-codel.h"
#include "netem.h"
#include "networkd-link.h"
#include "networkd-network.h"
@@ -25,10 +26,12 @@ typedef struct QDisc {
bool has_network_emulator:1;
bool has_token_buffer_filter:1;
bool has_stochastic_fairness_queueing:1;
+ bool has_fair_queuing_controlled_delay:1;
NetworkEmulator ne;
TokenBufferFilter tbf;
StochasticFairnessQueueing sfq;
+ FairQueuingControlledDelay fq_codel;
} QDisc;
void qdisc_free(QDisc *qdisc);
diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network
index c3264522b4..c71fe5ce77 100644
--- a/test/fuzz/fuzz-network-parser/directives.network
+++ b/test/fuzz/fuzz-network-parser/directives.network
@@ -278,3 +278,4 @@ TokenBufferFilterMPUBytes=
TokenBufferFilterPeakRate=
TokenBufferFilterLatencySec=
StochasticFairnessQueueingPerturbPeriodSec=
+FairQueuingControlledDelayPacketLimit=