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
This commit is contained in:
Susant Sahani 2020-03-09 10:48:03 +01:00 committed by Yu Watanabe
parent 55d228311b
commit bde4ae88c8
9 changed files with 157 additions and 0 deletions

View File

@ -2500,6 +2500,38 @@
</variablelist>
</refsect1>
<refsect1>
<title>[PIE] Section Options</title>
<para>The <literal>[PIE]</literal> section manages the queueing discipline
(qdisc) of Proportional Integral controller-Enhanced (PIE).</para>
<variablelist class='network-directives'>
<varlistentry>
<term><varname>Parent=</varname></term>
<listitem>
<para>Specifies the parent Queueing Discipline (qdisc). Takes one of <literal>root</literal>,
<literal>clsact</literal> or <literal>ingress</literal>. Defaults to <literal>root</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Handle=</varname></term>
<listitem>
<para>Specifies the major number of unique identifier of the qdisc, known as the handle.
Takes a number in hexadecimal ranges 1 to ffff. Defaults to unset.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>PacketLimit=</varname></term>
<listitem>
<para>Specifies the hard limit on the queue size in number of packets. When this limit is reached, incoming packets are
dropped. An unsigned integer ranges 1 to 4294967294. Defaults to unset and kernel's default is used.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>[StochasticFairBlue] Section Options</title>
<para>The <literal>[StochasticFairBlue]</literal> section manages the queueing discipline

View File

@ -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

View File

@ -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

View File

@ -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"

95
src/network/tc/pie.c Normal file
View File

@ -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,
};

17
src/network/tc/pie.h Normal file
View File

@ -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);

View File

@ -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,

View File

@ -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"

View File

@ -370,3 +370,7 @@ GenericRIO=
Parent=
Handle=
PacketLimit=
[PIE]
Parent=
Handle=
PacketLimit=