diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/meson.build | 2 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 3 | ||||
-rw-r--r-- | src/network/networkd-network.c | 1 | ||||
-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 |
7 files changed, 121 insertions, 0 deletions
diff --git a/src/network/meson.build b/src/network/meson.build index 57d3772c3e..92ef0c1feb 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -123,6 +123,8 @@ sources = files(''' tc/htb.h tc/netem.c tc/netem.h + tc/pie.c + tc/pie.h tc/qdisc.c tc/qdisc.h tc/sfb.c diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 8bf80afddd..9b58702f10 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -313,6 +313,9 @@ NetworkEmulator.DelayJitterSec, config_parse_network_emulator_delay NetworkEmulator.LossRate, config_parse_network_emulator_rate, QDISC_KIND_NETEM, 0 NetworkEmulator.DuplicateRate, config_parse_network_emulator_rate, QDISC_KIND_NETEM, 0 NetworkEmulator.PacketLimit, config_parse_network_emulator_packet_limit, QDISC_KIND_NETEM, 0 +PIE.Parent, config_parse_qdisc_parent, QDISC_KIND_PIE, 0 +PIE.Handle, config_parse_qdisc_handle, QDISC_KIND_PIE, 0 +PIE.PacketLimit, config_parse_pie_packet_limit, QDISC_KIND_PIE, 0 StochasticFairBlue.Parent, config_parse_qdisc_parent, QDISC_KIND_SFB, 0 StochasticFairBlue.Handle, config_parse_qdisc_handle, QDISC_KIND_SFB, 0 StochasticFairBlue.PacketLimit, config_parse_stochastic_fair_blue_u32, QDISC_KIND_SFB, 0 diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 40e4009bec..62e9a7c5d5 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -495,6 +495,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi "HierarchyTokenBucket\0" "HierarchyTokenBucketClass\0" "NetworkEmulator\0" + "PIE\0" "StochasticFairBlue\0" "StochasticFairnessQueueing\0" "TokenBucketFilter\0" 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" |