mirror of
https://github.com/systemd/systemd.git
synced 2025-03-04 20:58:28 +03:00
Merge pull request #14784 from yuwata/network-rename-qdisc-follow-up
network: introduce [QDisc] section to support Parent=ingress or clsact
This commit is contained in:
commit
43e8a22aab
@ -2270,6 +2270,21 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[QDisc] Section Options</title>
|
||||
<para>The <literal>[QDisc]</literal> section manages the traffic control queueing discipline (qdisc).</para>
|
||||
|
||||
<variablelist class='network-directives'>
|
||||
<varlistentry>
|
||||
<term><varname>Parent=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the parent Queueing Discipline (qdisc). Takes one of <literal>clsact</literal>
|
||||
or <literal>ingress</literal>. This is mandatory.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[NetworkEmulator] Section Options</title>
|
||||
<para>The <literal>[NetworkEmulator]</literal> section manages the queueing discipline (qdisc) of
|
||||
@ -2662,6 +2677,31 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[TrivialLinkEqualizer] Section Options</title>
|
||||
<para>The <literal>[TrivialLinkEqualizer]</literal> section manages the queueing discipline (qdisc) of
|
||||
trivial link equalizer (teql).</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>Id=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the interface ID <literal>N</literal> of teql. Defaults to <literal>0</literal>.
|
||||
Note that when teql is used, currently, the module <constant>sch_teql</constant> with
|
||||
<constant>max_equalizers=N+1</constant> option must be loaded before
|
||||
<command>systemd-networkd</command> is started.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[BridgeVLAN] Section Options</title>
|
||||
<para>The <literal>[BridgeVLAN]</literal> section manages the VLAN ID configuration of a bridge port and accepts
|
||||
|
@ -123,6 +123,8 @@ sources = files('''
|
||||
tc/tbf.h
|
||||
tc/tc-util.c
|
||||
tc/tc-util.h
|
||||
tc/teql.c
|
||||
tc/teql.h
|
||||
'''.split())
|
||||
|
||||
systemd_networkd_sources = files('networkd.c')
|
||||
|
@ -4305,5 +4305,10 @@ int log_link_message_full_errno(Link *link, sd_netlink_message *m, int level, in
|
||||
const char *err_msg = NULL;
|
||||
|
||||
(void) sd_netlink_message_read_string(m, NLMSGERR_ATTR_MSG, &err_msg);
|
||||
return log_link_full(link, level, err, "%s: %s%s%m", msg, strempty(err_msg), err_msg ? " " : "");
|
||||
return log_link_full(link, level, err,
|
||||
"%s: %s%s%s%m",
|
||||
msg,
|
||||
strempty(err_msg),
|
||||
err_msg && !endswith(err_msg, ".") ? "." : "",
|
||||
err_msg ? " " : "");
|
||||
}
|
||||
|
@ -251,6 +251,7 @@ CAN.BitRate, config_parse_si_uint64,
|
||||
CAN.SamplePoint, config_parse_permille, 0, offsetof(Network, can_sample_point)
|
||||
CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us)
|
||||
CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling)
|
||||
QDisc.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0
|
||||
ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0
|
||||
ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, QDISC_KIND_CODEL, 0
|
||||
ControlledDelay.TargetSec, config_parse_controlled_delay_usec, QDISC_KIND_CODEL, 0
|
||||
@ -292,6 +293,8 @@ TokenBucketFilter.MTUBytes, config_parse_token_bucket_filter_si
|
||||
TokenBucketFilter.MPUBytes, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0
|
||||
TokenBucketFilter.PeakRate, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0
|
||||
TokenBucketFilter.LatencySec, config_parse_token_bucket_filter_latency, QDISC_KIND_TBF, 0
|
||||
TrivialLinkEqualizer.Parent, config_parse_qdisc_parent, QDISC_KIND_TEQL, 0
|
||||
TrivialLinkEqualizer.Id, config_parse_trivial_link_equalizer_id, QDISC_KIND_TEQL, 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)
|
||||
@ -320,7 +323,7 @@ DHCP.RapidCommit, config_parse_bool,
|
||||
DHCP.ForceDHCPv6PDOtherInformation, config_parse_bool, 0, offsetof(Network, dhcp6_force_pd_other_information)
|
||||
DHCPv4.UseDomainName, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains)
|
||||
DHCPv4.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical)
|
||||
TrafficControlQueueingDiscipline.Parent, config_parse_qdisc_parent, QDISC_KIND_NETEM, 0
|
||||
TrafficControlQueueingDiscipline.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0
|
||||
TrafficControlQueueingDiscipline.NetworkEmulatorDelaySec, config_parse_network_emulator_delay, 0, 0
|
||||
TrafficControlQueueingDiscipline.NetworkEmulatorDelayJitterSec, config_parse_network_emulator_delay, 0, 0
|
||||
TrafficControlQueueingDiscipline.NetworkEmulatorLossRate, config_parse_network_emulator_rate, 0, 0
|
||||
|
@ -482,12 +482,14 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
"IPv6RoutePrefix\0"
|
||||
"TrafficControlQueueingDiscipline\0"
|
||||
"CAN\0"
|
||||
"QDisc\0"
|
||||
"ControlledDelay\0"
|
||||
"FairQueueing\0"
|
||||
"FairQueueingControlledDelay\0"
|
||||
"NetworkEmulator\0"
|
||||
"StochasticFairnessQueueing\0"
|
||||
"TokenBucketFilter\0",
|
||||
"TokenBucketFilter\0"
|
||||
"TrivialLinkEqualizer\0",
|
||||
config_item_perf_lookup, network_network_gperf_lookup,
|
||||
CONFIG_PARSE_WARN, network);
|
||||
if (r < 0)
|
||||
|
@ -20,6 +20,7 @@ const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
|
||||
[QDISC_KIND_NETEM] = &netem_vtable,
|
||||
[QDISC_KIND_SFQ] = &sfq_vtable,
|
||||
[QDISC_KIND_TBF] = &tbf_vtable,
|
||||
[QDISC_KIND_TEQL] = &teql_vtable,
|
||||
};
|
||||
|
||||
static int qdisc_new(QDiscKind kind, QDisc **ret) {
|
||||
@ -138,7 +139,7 @@ static int qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
|
||||
r = sd_netlink_message_get_errno(m);
|
||||
if (r < 0 && r != -EEXIST) {
|
||||
log_link_message_error_errno(link, m, r, "Could not set QDisc: %m");
|
||||
log_link_message_error_errno(link, m, r, "Could not set QDisc");
|
||||
link_enter_failed(link);
|
||||
return 1;
|
||||
}
|
||||
@ -176,13 +177,21 @@ int qdisc_configure(Link *link, QDisc *qdisc) {
|
||||
}
|
||||
|
||||
if (QDISC_VTABLE(qdisc)) {
|
||||
r = sd_netlink_message_append_string(req, TCA_KIND, QDISC_VTABLE(qdisc)->tca_kind);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append TCA_KIND attribute: %m");
|
||||
if (QDISC_VTABLE(qdisc)->fill_tca_kind) {
|
||||
r = QDISC_VTABLE(qdisc)->fill_tca_kind(link, qdisc, req);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
r = sd_netlink_message_append_string(req, TCA_KIND, QDISC_VTABLE(qdisc)->tca_kind);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append TCA_KIND attribute: %m");
|
||||
}
|
||||
|
||||
r = QDISC_VTABLE(qdisc)->fill_message(link, qdisc, req);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (QDISC_VTABLE(qdisc)->fill_message) {
|
||||
r = QDISC_VTABLE(qdisc)->fill_message(link, qdisc, req);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
} else {
|
||||
r = sd_netlink_message_append_string(req, TCA_KIND, qdisc->tca_kind);
|
||||
if (r < 0)
|
||||
@ -218,15 +227,15 @@ int qdisc_section_verify(QDisc *qdisc, bool *has_root, bool *has_clsact) {
|
||||
if (qdisc->parent == TC_H_ROOT) {
|
||||
if (*has_root)
|
||||
return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s: More than one root TrafficControlQueueingDiscipline sections are defined. "
|
||||
"Ignoring [TrafficControlQueueingDiscipline] section from line %u.",
|
||||
"%s: More than one root qdisc section is defined. "
|
||||
"Ignoring the qdisc section from line %u.",
|
||||
qdisc->section->filename, qdisc->section->line);
|
||||
*has_root = true;
|
||||
} else if (qdisc->parent == TC_H_CLSACT) { /* TC_H_CLSACT == TC_H_INGRESS */
|
||||
if (*has_clsact)
|
||||
return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s: More than one clsact or ingress TrafficControlQueueingDiscipline sections are defined. "
|
||||
"Ignoring [TrafficControlQueueingDiscipline] section from line %u.",
|
||||
"%s: More than one clsact or ingress qdisc section is defined. "
|
||||
"Ignoring the qdisc section from line %u.",
|
||||
qdisc->section->filename, qdisc->section->line);
|
||||
*has_clsact = true;
|
||||
}
|
||||
@ -254,7 +263,6 @@ int config_parse_qdisc_parent(
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
assert(ltype >= 0 && ltype < _QDISC_KIND_MAX);
|
||||
|
||||
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
|
||||
if (r < 0)
|
||||
|
@ -14,6 +14,7 @@ typedef enum QDiscKind {
|
||||
QDISC_KIND_NETEM,
|
||||
QDISC_KIND_SFQ,
|
||||
QDISC_KIND_TBF,
|
||||
QDISC_KIND_TEQL,
|
||||
_QDISC_KIND_MAX,
|
||||
_QDISC_KIND_INVALID = -1,
|
||||
} QDiscKind;
|
||||
@ -35,6 +36,7 @@ typedef struct QDiscVTable {
|
||||
const char *tca_kind;
|
||||
/* called in qdisc_new() */
|
||||
int (*init)(QDisc *qdisc);
|
||||
int (*fill_tca_kind)(Link *link, QDisc *qdisc, sd_netlink_message *m);
|
||||
int (*fill_message)(Link *link, QDisc *qdisc, sd_netlink_message *m);
|
||||
int (*verify)(QDisc *qdisc);
|
||||
} QDiscVTable;
|
||||
@ -71,3 +73,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_parent);
|
||||
#include "netem.h"
|
||||
#include "sfq.h"
|
||||
#include "tbf.h"
|
||||
#include "teql.h"
|
||||
|
90
src/network/tc/teql.c
Normal file
90
src/network/tc/teql.c
Normal file
@ -0,0 +1,90 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "macro.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
#include "teql.h"
|
||||
|
||||
static int trivial_link_equalizer_fill_tca_kind(Link *link, QDisc *qdisc, sd_netlink_message *req) {
|
||||
char kind[STRLEN("teql") + DECIMAL_STR_MAX(unsigned)];
|
||||
TrivialLinkEqualizer *teql;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(qdisc);
|
||||
assert(req);
|
||||
|
||||
teql = TEQL(qdisc);
|
||||
|
||||
xsprintf(kind, "teql%u", teql->id);
|
||||
r = sd_netlink_message_append_string(req, TCA_KIND, kind);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append TCA_KIND attribute: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const QDiscVTable teql_vtable = {
|
||||
.object_size = sizeof(TrivialLinkEqualizer),
|
||||
.fill_tca_kind = trivial_link_equalizer_fill_tca_kind,
|
||||
};
|
||||
|
||||
int config_parse_trivial_link_equalizer_id(
|
||||
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;
|
||||
TrivialLinkEqualizer *teql;
|
||||
Network *network = data;
|
||||
unsigned id;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = qdisc_new_static(QDISC_KIND_TEQL, 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");
|
||||
|
||||
teql = TEQL(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
teql->id = 0;
|
||||
|
||||
qdisc = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = safe_atou(rvalue, &id);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (id > INT_MAX) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
"'%s=' is too large, ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
}
|
||||
|
||||
teql->id = id;
|
||||
|
||||
qdisc = NULL;
|
||||
return 0;
|
||||
}
|
16
src/network/tc/teql.h
Normal file
16
src/network/tc/teql.h
Normal file
@ -0,0 +1,16 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "qdisc.h"
|
||||
|
||||
typedef struct TrivialLinkEqualizer {
|
||||
QDisc meta;
|
||||
|
||||
unsigned id;
|
||||
} TrivialLinkEqualizer;
|
||||
|
||||
DEFINE_QDISC_CAST(TEQL, TrivialLinkEqualizer);
|
||||
extern const QDiscVTable teql_vtable;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_trivial_link_equalizer_id);
|
@ -270,6 +270,8 @@ SendOption=
|
||||
[NextHop]
|
||||
Id=
|
||||
Gateway=
|
||||
[QDisc]
|
||||
Parent=
|
||||
[NetworkEmulator]
|
||||
Parent=
|
||||
DelaySec=
|
||||
@ -324,3 +326,6 @@ NetworkEmulatorDelayJitterSec=
|
||||
NetworkEmulatorLossRate=
|
||||
NetworkEmulatorDuplicateRate=
|
||||
NetworkEmulatorPacketLimit=
|
||||
[TrivialLinkEqualizer]
|
||||
Parent=
|
||||
Id=
|
||||
|
12
test/test-network/conf/25-qdisc-clsact-root-compat.network
Normal file
12
test/test-network/conf/25-qdisc-clsact-root-compat.network
Normal file
@ -0,0 +1,12 @@
|
||||
[Match]
|
||||
Name=dummy98
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.1.2.3/16
|
||||
|
||||
#[TrafficControlQueueingDiscipline]
|
||||
#Parent=root
|
||||
|
||||
[TrafficControlQueueingDiscipline]
|
||||
Parent=clsact
|
16
test/test-network/conf/25-qdisc-ingress-netem-compat.network
Normal file
16
test/test-network/conf/25-qdisc-ingress-netem-compat.network
Normal file
@ -0,0 +1,16 @@
|
||||
[Match]
|
||||
Name=test1
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.1.2.4/16
|
||||
|
||||
[TrafficControlQueueingDiscipline]
|
||||
Parent=root
|
||||
NetworkEmulatorDelaySec=50ms
|
||||
NetworkEmulatorDelayJitterSec=10ms
|
||||
NetworkEmulatorLossRate=20%
|
||||
NetworkEmulatorPacketLimit=100
|
||||
|
||||
[TrafficControlQueueingDiscipline]
|
||||
Parent=ingress
|
12
test/test-network/conf/25-qdisc-ingress-root.network
Normal file
12
test/test-network/conf/25-qdisc-ingress-root.network
Normal file
@ -0,0 +1,12 @@
|
||||
[Match]
|
||||
Name=test1
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.1.2.4/16
|
||||
|
||||
#[QDisc]
|
||||
#Parent=root
|
||||
|
||||
[QDisc]
|
||||
Parent=ingress
|
10
test/test-network/conf/25-qdisc-teql.network
Normal file
10
test/test-network/conf/25-qdisc-teql.network
Normal file
@ -0,0 +1,10 @@
|
||||
[Match]
|
||||
Name=dummy98
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.1.2.3/16
|
||||
|
||||
[TrivialLinkEqualizer]
|
||||
Parent=root
|
||||
Id=1
|
@ -1616,9 +1616,13 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
'25-neighbor-ip-dummy.network',
|
||||
'25-neighbor-ip.network',
|
||||
'25-nexthop.network',
|
||||
'25-qdisc-clsact-root-compat.network',
|
||||
'25-qdisc-fq-codel.network',
|
||||
'25-qdisc-ingress-netem-compat.network',
|
||||
'25-qdisc-ingress-root.network',
|
||||
'25-qdisc-netem-and-fqcodel.network',
|
||||
'25-qdisc-tbf-and-sfq.network',
|
||||
'25-qdisc-teql.network',
|
||||
'25-route-ipv6-src.network',
|
||||
'25-route-static.network',
|
||||
'25-gateway-static.network',
|
||||
@ -2248,10 +2252,11 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
self.assertRegex(output, 'perturb 5sec')
|
||||
|
||||
def test_qdisc2(self):
|
||||
copy_unit_to_networkd_unit_path('25-qdisc-fq-codel.network', '12-dummy.netdev')
|
||||
copy_unit_to_networkd_unit_path('25-qdisc-fq-codel.network', '12-dummy.netdev',
|
||||
'25-qdisc-ingress-root.network', '11-dummy.netdev')
|
||||
start_networkd()
|
||||
|
||||
self.wait_online(['dummy98:routable'])
|
||||
self.wait_online(['dummy98:routable', 'test1:routable'])
|
||||
|
||||
output = check_output('tc qdisc show dev dummy98')
|
||||
print(output)
|
||||
@ -2262,6 +2267,36 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
||||
self.assertRegex(output, 'maxrate 1Mbit')
|
||||
self.assertRegex(output, 'qdisc codel')
|
||||
self.assertRegex(output, 'limit 2000p target 10.0ms ce_threshold 100.0ms interval 50.0ms ecn')
|
||||
output = check_output('tc qdisc show dev test1')
|
||||
print(output)
|
||||
self.assertRegex(output, 'qdisc ingress')
|
||||
|
||||
def test_qdisc3(self):
|
||||
copy_unit_to_networkd_unit_path('25-qdisc-clsact-root-compat.network', '12-dummy.netdev',
|
||||
'25-qdisc-ingress-netem-compat.network', '11-dummy.netdev')
|
||||
start_networkd()
|
||||
|
||||
self.wait_online(['dummy98:routable', 'test1:routable'])
|
||||
|
||||
output = check_output('tc qdisc show dev dummy98')
|
||||
print(output)
|
||||
self.assertRegex(output, 'qdisc clsact')
|
||||
output = check_output('tc qdisc show dev test1')
|
||||
print(output)
|
||||
self.assertRegex(output, 'qdisc netem')
|
||||
self.assertRegex(output, 'limit 100 delay 50.0ms 10.0ms loss 20%')
|
||||
self.assertRegex(output, 'qdisc ingress')
|
||||
|
||||
def test_qdisc4(self):
|
||||
copy_unit_to_networkd_unit_path('25-qdisc-teql.network', '12-dummy.netdev')
|
||||
check_output('modprobe sch_teql max_equalizers=2')
|
||||
start_networkd()
|
||||
|
||||
self.wait_online(['dummy98:routable'])
|
||||
|
||||
output = check_output('tc qdisc show dev dummy98')
|
||||
print(output)
|
||||
self.assertRegex(output, 'qdisc teql1')
|
||||
|
||||
class NetworkdStateFileTests(unittest.TestCase, Utilities):
|
||||
links = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user