diff options
author | Susant Sahani <ssahani@vmware.com> | 2020-03-09 10:48:03 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-03-12 13:58:35 +0900 |
commit | bde4ae88c898068797a3ba4e339803465d51ca5b (patch) | |
tree | becb4e869a0a59f9686a05905882672b33223807 /src/network/tc | |
parent | 55d228311bb6e6111f4015038d35fbd73010b688 (diff) | |
download | systemd-bde4ae88c898068797a3ba4e339803465d51ca5b.tar.gz |
network: tc- introduce PIE
Proportional Integral controller-Enhanced (PIE) is a control
theoretic active queue management scheme. It is based on the
proportional integral controller but aims to control delay.
http://man7.org/linux/man-pages/man8/tc-pie.8.html
Diffstat (limited to 'src/network/tc')
-rw-r--r-- | src/network/tc/pie.c | 95 | ||||
-rw-r--r-- | src/network/tc/pie.h | 17 | ||||
-rw-r--r-- | src/network/tc/qdisc.c | 1 | ||||
-rw-r--r-- | src/network/tc/qdisc.h | 2 |
4 files changed, 115 insertions, 0 deletions
diff --git a/src/network/tc/pie.c b/src/network/tc/pie.c new file mode 100644 index 0000000000..e92ced1343 --- /dev/null +++ b/src/network/tc/pie.c @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: LGPL-2.1+ + * Copyright © 2020 VMware, Inc. */ + +#include <linux/pkt_sched.h> + +#include "alloc-util.h" +#include "conf-parser.h" +#include "pie.h" +#include "netlink-util.h" +#include "parse-util.h" +#include "string-util.h" + +static int pie_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) { + proportional_integral_controller_enhanced *pie; + int r; + + assert(link); + assert(qdisc); + assert(req); + + pie = PIE(qdisc); + + r = sd_netlink_message_open_container_union(req, TCA_OPTIONS, "pie"); + if (r < 0) + return log_link_error_errno(link, r, "Could not open container TCA_OPTIONS: %m"); + + if (pie->packet_limit > 0) { + r = sd_netlink_message_append_u32(req, TCA_PIE_LIMIT, pie->packet_limit); + if (r < 0) + return log_link_error_errno(link, r, "Could not append TCA_PIE_PLIMIT 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_pie_packet_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; + proportional_integral_controller_enhanced *pie; + Network *network = data; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = qdisc_new_static(QDISC_KIND_PIE, network, filename, section_line, &qdisc); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) + return log_syntax(unit, LOG_ERR, filename, line, r, + "More than one kind of queueing discipline, ignoring assignment: %m"); + + pie = PIE(qdisc); + + if (isempty(rvalue)) { + pie->packet_limit = 0; + + qdisc = NULL; + return 0; + } + + r = safe_atou32(rvalue, &pie->packet_limit); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to parse '%s=', ignoring assignment: %s", + lvalue, rvalue); + return 0; + } + + qdisc = NULL; + + return 0; +} + +const QDiscVTable pie_vtable = { + .object_size = sizeof(proportional_integral_controller_enhanced), + .tca_kind = "pie", + .fill_message = pie_fill_message, +}; diff --git a/src/network/tc/pie.h b/src/network/tc/pie.h new file mode 100644 index 0000000000..44214f1ba1 --- /dev/null +++ b/src/network/tc/pie.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1+ + * Copyright © 2020 VMware, Inc. */ +#pragma once + +#include "conf-parser.h" +#include "qdisc.h" + +typedef struct proportional_integral_controller_enhanced { + QDisc meta; + + uint32_t packet_limit; +} proportional_integral_controller_enhanced; + +DEFINE_QDISC_CAST(PIE, proportional_integral_controller_enhanced); +extern const QDiscVTable pie_vtable; + +CONFIG_PARSER_PROTOTYPE(config_parse_pie_packet_limit); diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c index 31b6a716c4..44f296e744 100644 --- a/src/network/tc/qdisc.c +++ b/src/network/tc/qdisc.c @@ -23,6 +23,7 @@ const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = { [QDISC_KIND_GRED] = &gred_vtable, [QDISC_KIND_HTB] = &htb_vtable, [QDISC_KIND_NETEM] = &netem_vtable, + [QDISC_KIND_PIE] = &pie_vtable, [QDISC_KIND_PFIFO] = &pfifo_vtable, [QDISC_KIND_SFB] = &sfb_vtable, [QDISC_KIND_SFQ] = &sfq_vtable, diff --git a/src/network/tc/qdisc.h b/src/network/tc/qdisc.h index 403d6a5b53..81e740f66d 100644 --- a/src/network/tc/qdisc.h +++ b/src/network/tc/qdisc.h @@ -17,6 +17,7 @@ typedef enum QDiscKind { QDISC_KIND_HTB, QDISC_KIND_NETEM, QDISC_KIND_PFIFO, + QDISC_KIND_PIE, QDISC_KIND_SFB, QDISC_KIND_SFQ, QDISC_KIND_TBF, @@ -85,6 +86,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle); #include "fq.h" #include "gred.h" #include "htb.h" +#include "pie.h" #include "netem.h" #include "sfb.h" #include "sfq.h" |