mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
network: tc: introduce DRR class
This commit is contained in:
parent
f5fc04417e
commit
ad365c5de7
@ -2765,6 +2765,42 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[DeficitRoundRobinSchedulerClass] Section Options</title>
|
||||
<para>The <literal>[DeficitRoundRobinSchedulerClass]</literal> section manages the traffic control class of
|
||||
Deficit Round Robin Scheduler (DRR).</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>, <literal>ingress</literal> or a class id. The class id takes the
|
||||
major and minor number in hexadecimal ranges 1 to ffff separated with a colon
|
||||
(<literal>major:minor</literal>). Defaults to <literal>root</literal>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ClassId=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the major and minur number of unique identifier of the class, known as the
|
||||
class ID. Each number is in hexadecimal ranges 1 to ffff. Defaults to unset.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>Quantum=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the amount of bytes a flow is allowed to dequeue before the
|
||||
scheduler moves to the next class. An unsigned integer ranges 1 to 4294967294.
|
||||
Defaults to the MTU of the interface.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[GenericRandomEarlyDetection] Section Options</title>
|
||||
<para>The <literal>[GenericRandomEarlyDetection]</literal> section manages the queueing discipline
|
||||
|
@ -271,6 +271,9 @@ ControlledDelay.CEThresholdSec, config_parse_controlled_delay_usec,
|
||||
ControlledDelay.ECN, config_parse_controlled_delay_bool, QDISC_KIND_CODEL, 0
|
||||
DeficitRoundRobinScheduler.Parent, config_parse_qdisc_parent, QDISC_KIND_DRR, 0
|
||||
DeficitRoundRobinScheduler.Handle, config_parse_qdisc_handle, QDISC_KIND_DRR, 0
|
||||
DeficitRoundRobinSchedulerClass.Parent, config_parse_tclass_parent, TCLASS_KIND_DRR, 0
|
||||
DeficitRoundRobinSchedulerClass.ClassId, config_parse_tclass_classid, TCLASS_KIND_DRR, 0
|
||||
DeficitRoundRobinSchedulerClass.Quantum, config_parse_drr_size, TCLASS_KIND_DRR, 0
|
||||
PFIFO.Parent, config_parse_qdisc_parent, QDISC_KIND_PFIFO, 0
|
||||
PFIFO.Handle, config_parse_qdisc_handle, QDISC_KIND_PFIFO, 0
|
||||
PFIFO.PacketLimit, config_parse_fifo_size, QDISC_KIND_PFIFO, 0
|
||||
|
@ -489,6 +489,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
"CAKE\0"
|
||||
"ControlledDelay\0"
|
||||
"DeficitRoundRobinScheduler\0"
|
||||
"DeficitRoundRobinSchedulerClass\0"
|
||||
"PFIFO\0"
|
||||
"FairQueueing\0"
|
||||
"FairQueueingControlledDelay\0"
|
||||
|
@ -1,9 +1,105 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+
|
||||
* Copyright © 2020 VMware, Inc. */
|
||||
|
||||
#include <linux/pkt_sched.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "drr.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
const QDiscVTable drr_vtable = {
|
||||
.object_size = sizeof(DeficitRoundRobinScheduler),
|
||||
.tca_kind = "drr",
|
||||
};
|
||||
|
||||
static int drr_class_fill_message(Link *link, TClass *tclass, sd_netlink_message *req) {
|
||||
DeficitRoundRobinSchedulerClass *drr;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(tclass);
|
||||
assert(req);
|
||||
|
||||
drr = TCLASS_TO_DRR(tclass);
|
||||
|
||||
r = sd_netlink_message_open_container_union(req, TCA_OPTIONS, "drr");
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not open container TCA_OPTIONS: %m");
|
||||
|
||||
if (drr->quantum > 0) {
|
||||
r = sd_netlink_message_append_u32(req, TCA_DRR_QUANTUM, drr->quantum);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append TCA_DRR_QUANTUM, 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_drr_size(
|
||||
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_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
|
||||
DeficitRoundRobinSchedulerClass *drr;
|
||||
Network *network = data;
|
||||
uint64_t u;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = tclass_new_static(TCLASS_KIND_DRR, network, filename, section_line, &tclass);
|
||||
if (r < 0)
|
||||
return log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to create traffic control class, ignoring assignment: %m");
|
||||
|
||||
drr = TCLASS_TO_DRR(tclass);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
drr->quantum = 0;
|
||||
|
||||
tclass = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_size(rvalue, 1000, &u);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (u > UINT32_MAX) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid '%s=', ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
drr->quantum = (uint32_t) u;
|
||||
|
||||
tclass = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const TClassVTable drr_tclass_vtable = {
|
||||
.object_size = sizeof(DeficitRoundRobinSchedulerClass),
|
||||
.tca_kind = "drr",
|
||||
.fill_message = drr_class_fill_message,
|
||||
};
|
||||
|
@ -10,3 +10,14 @@ typedef struct DeficitRoundRobinScheduler {
|
||||
|
||||
DEFINE_QDISC_CAST(DRR, DeficitRoundRobinScheduler);
|
||||
extern const QDiscVTable drr_vtable;
|
||||
|
||||
typedef struct DeficitRoundRobinSchedulerClass {
|
||||
TClass meta;
|
||||
|
||||
uint32_t quantum;
|
||||
} DeficitRoundRobinSchedulerClass;
|
||||
|
||||
DEFINE_TCLASS_CAST(DRR, DeficitRoundRobinSchedulerClass);
|
||||
extern const TClassVTable drr_tclass_vtable;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_drr_size);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "tclass.h"
|
||||
|
||||
const TClassVTable * const tclass_vtable[_TCLASS_KIND_MAX] = {
|
||||
[TCLASS_KIND_DRR] = &drr_tclass_vtable,
|
||||
[TCLASS_KIND_HTB] = &htb_tclass_vtable,
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "tc.h"
|
||||
|
||||
typedef enum TClassKind {
|
||||
TCLASS_KIND_DRR,
|
||||
TCLASS_KIND_HTB,
|
||||
_TCLASS_KIND_MAX,
|
||||
_TCLASS_KIND_INVALID = -1,
|
||||
@ -64,4 +65,5 @@ DEFINE_TC_CAST(TCLASS, TClass);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_tclass_parent);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_tclass_classid);
|
||||
|
||||
#include "drr.h"
|
||||
#include "htb.h"
|
||||
|
@ -377,3 +377,7 @@ PacketLimit=
|
||||
[DeficitRoundRobinScheduler]
|
||||
Parent=
|
||||
Handle=
|
||||
[DeficitRoundRobinSchedulerClass]
|
||||
Parent=
|
||||
ClassId=
|
||||
Quantum=
|
||||
|
Loading…
x
Reference in New Issue
Block a user