Compare commits

...

4 Commits

Author SHA1 Message Date
Yu Watanabe c09f335744
Merge pull request #14584 from ssahani/tc-handle
network:tc add support for qdisc handle
2020-02-11 06:17:48 +09:00
Yu Watanabe 38d1255a52 test-network: add tests for qdisc Handle= 2020-02-10 17:49:02 +09:00
Susant Sahani d8b2396d34 network: add support for qdisc handle 2020-02-10 17:48:53 +09:00
Yu Watanabe bfcdc87260 network: fix indentation 2020-02-10 15:55:04 +09:00
10 changed files with 147 additions and 14 deletions

View File

@ -2282,6 +2282,14 @@
or <literal>ingress</literal>. This is mandatory.</para> or <literal>ingress</literal>. This is mandatory.</para>
</listitem> </listitem>
</varlistentry> </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>
</variablelist> </variablelist>
</refsect1> </refsect1>
@ -2301,6 +2309,14 @@
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>DelaySec=</varname></term> <term><varname>DelaySec=</varname></term>
<listitem> <listitem>
@ -2357,6 +2373,14 @@
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>LatencySec=</varname></term> <term><varname>LatencySec=</varname></term>
<listitem> <listitem>
@ -2436,6 +2460,14 @@
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>PerturbPeriodSec=</varname></term> <term><varname>PerturbPeriodSec=</varname></term>
<listitem> <listitem>
@ -2459,6 +2491,14 @@
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>PacketLimit=</varname></term> <term><varname>PacketLimit=</varname></term>
<listitem> <listitem>
@ -2515,6 +2555,14 @@
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>PacketLimit=</varname></term> <term><varname>PacketLimit=</varname></term>
<listitem> <listitem>
@ -2597,6 +2645,14 @@
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>PacketLimit=</varname></term> <term><varname>PacketLimit=</varname></term>
<listitem> <listitem>
@ -2690,6 +2746,15 @@
<literal>clsact</literal> or <literal>ingress</literal>. Defaults to <literal>root</literal>.</para> <literal>clsact</literal> or <literal>ingress</literal>. Defaults to <literal>root</literal>.</para>
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><varname>Id=</varname></term> <term><varname>Id=</varname></term>
<listitem> <listitem>

View File

@ -252,23 +252,27 @@ CAN.SamplePoint, config_parse_permille,
CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us) CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us)
CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling) CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling)
QDisc.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0 QDisc.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0
QDisc.Handle, config_parse_qdisc_handle, _QDISC_KIND_INVALID, 0
ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0 ControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_CODEL, 0
ControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_CODEL, 0
ControlledDelay.PacketLimit, config_parse_controlled_delay_u32, 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 ControlledDelay.TargetSec, config_parse_controlled_delay_usec, QDISC_KIND_CODEL, 0
ControlledDelay.IntervalSec, config_parse_controlled_delay_usec, QDISC_KIND_CODEL, 0 ControlledDelay.IntervalSec, config_parse_controlled_delay_usec, QDISC_KIND_CODEL, 0
ControlledDelay.CEThresholdSec, config_parse_controlled_delay_usec, QDISC_KIND_CODEL, 0 ControlledDelay.CEThresholdSec, config_parse_controlled_delay_usec, QDISC_KIND_CODEL, 0
ControlledDelay.ECN, config_parse_controlled_delay_bool, QDISC_KIND_CODEL, 0 ControlledDelay.ECN, config_parse_controlled_delay_bool, QDISC_KIND_CODEL, 0
FairQueueing.Parent, config_parse_qdisc_parent, QDISC_KIND_FQ, 0 FairQueueing.Parent, config_parse_qdisc_parent, QDISC_KIND_FQ, 0
FairQueueing.PacketLimit, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0 FairQueueing.Handle, config_parse_qdisc_handle, QDISC_KIND_FQ, 0
FairQueueing.FlowLimit, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0 FairQueueing.PacketLimit, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0
FairQueueing.Quantum, config_parse_fair_queueing_size, QDISC_KIND_FQ, 0 FairQueueing.FlowLimit, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0
FairQueueing.InitialQuantum, config_parse_fair_queueing_size, QDISC_KIND_FQ, 0 FairQueueing.Quantum, config_parse_fair_queueing_size, QDISC_KIND_FQ, 0
FairQueueing.MaximumRate, config_parse_fair_queueing_max_rate, QDISC_KIND_FQ, 0 FairQueueing.InitialQuantum, config_parse_fair_queueing_size, QDISC_KIND_FQ, 0
FairQueueing.Buckets, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0 FairQueueing.MaximumRate, config_parse_fair_queueing_max_rate, QDISC_KIND_FQ, 0
FairQueueing.OrphanMask, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0 FairQueueing.Buckets, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0
FairQueueing.Pacing, config_parse_fair_queueing_bool, QDISC_KIND_FQ, 0 FairQueueing.OrphanMask, config_parse_fair_queueing_u32, QDISC_KIND_FQ, 0
FairQueueing.CEThresholdSec, config_parse_fair_queueing_usec, QDISC_KIND_FQ, 0 FairQueueing.Pacing, config_parse_fair_queueing_bool, QDISC_KIND_FQ, 0
FairQueueing.CEThresholdSec, config_parse_fair_queueing_usec, QDISC_KIND_FQ, 0
FairQueueingControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_FQ_CODEL, 0 FairQueueingControlledDelay.Parent, config_parse_qdisc_parent, QDISC_KIND_FQ_CODEL, 0
FairQueueingControlledDelay.Handle, config_parse_qdisc_handle, QDISC_KIND_FQ_CODEL, 0
FairQueueingControlledDelay.PacketLimit, config_parse_fair_queueing_controlled_delay_u32, QDISC_KIND_FQ_CODEL, 0 FairQueueingControlledDelay.PacketLimit, config_parse_fair_queueing_controlled_delay_u32, QDISC_KIND_FQ_CODEL, 0
FairQueueingControlledDelay.MemoryLimit, config_parse_fair_queueing_controlled_delay_size, QDISC_KIND_FQ_CODEL, 0 FairQueueingControlledDelay.MemoryLimit, config_parse_fair_queueing_controlled_delay_size, QDISC_KIND_FQ_CODEL, 0
FairQueueingControlledDelay.Flows, config_parse_fair_queueing_controlled_delay_u32, QDISC_KIND_FQ_CODEL, 0 FairQueueingControlledDelay.Flows, config_parse_fair_queueing_controlled_delay_u32, QDISC_KIND_FQ_CODEL, 0
@ -278,14 +282,17 @@ FairQueueingControlledDelay.IntervalSec, config_parse_fair_queueing_controll
FairQueueingControlledDelay.CEThresholdSec, config_parse_fair_queueing_controlled_delay_usec, QDISC_KIND_FQ_CODEL, 0 FairQueueingControlledDelay.CEThresholdSec, config_parse_fair_queueing_controlled_delay_usec, QDISC_KIND_FQ_CODEL, 0
FairQueueingControlledDelay.ECN, config_parse_fair_queueing_controlled_delay_bool, QDISC_KIND_FQ_CODEL, 0 FairQueueingControlledDelay.ECN, config_parse_fair_queueing_controlled_delay_bool, QDISC_KIND_FQ_CODEL, 0
NetworkEmulator.Parent, config_parse_qdisc_parent, QDISC_KIND_NETEM, 0 NetworkEmulator.Parent, config_parse_qdisc_parent, QDISC_KIND_NETEM, 0
NetworkEmulator.Handle, config_parse_qdisc_handle, QDISC_KIND_NETEM, 0
NetworkEmulator.DelaySec, config_parse_network_emulator_delay, QDISC_KIND_NETEM, 0 NetworkEmulator.DelaySec, config_parse_network_emulator_delay, QDISC_KIND_NETEM, 0
NetworkEmulator.DelayJitterSec, config_parse_network_emulator_delay, QDISC_KIND_NETEM, 0 NetworkEmulator.DelayJitterSec, config_parse_network_emulator_delay, QDISC_KIND_NETEM, 0
NetworkEmulator.LossRate, config_parse_network_emulator_rate, QDISC_KIND_NETEM, 0 NetworkEmulator.LossRate, config_parse_network_emulator_rate, QDISC_KIND_NETEM, 0
NetworkEmulator.DuplicateRate, 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 NetworkEmulator.PacketLimit, config_parse_network_emulator_packet_limit, QDISC_KIND_NETEM, 0
StochasticFairnessQueueing.Parent, config_parse_qdisc_parent, QDISC_KIND_SFQ, 0 StochasticFairnessQueueing.Parent, config_parse_qdisc_parent, QDISC_KIND_SFQ, 0
StochasticFairnessQueueing.Handle, config_parse_qdisc_handle, QDISC_KIND_SFQ, 0
StochasticFairnessQueueing.PerturbPeriodSec, config_parse_stochastic_fairness_queueing_perturb_period, QDISC_KIND_SFQ, 0 StochasticFairnessQueueing.PerturbPeriodSec, config_parse_stochastic_fairness_queueing_perturb_period, QDISC_KIND_SFQ, 0
TokenBucketFilter.Parent, config_parse_qdisc_parent, QDISC_KIND_TBF, 0 TokenBucketFilter.Parent, config_parse_qdisc_parent, QDISC_KIND_TBF, 0
TokenBucketFilter.Handle, config_parse_qdisc_handle, QDISC_KIND_TBF, 0
TokenBucketFilter.Rate, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0 TokenBucketFilter.Rate, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0
TokenBucketFilter.Burst, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0 TokenBucketFilter.Burst, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0
TokenBucketFilter.LimitSize, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0 TokenBucketFilter.LimitSize, config_parse_token_bucket_filter_size, QDISC_KIND_TBF, 0
@ -294,6 +301,7 @@ TokenBucketFilter.MPUBytes, config_parse_token_bucket_filter_si
TokenBucketFilter.PeakRate, 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 TokenBucketFilter.LatencySec, config_parse_token_bucket_filter_latency, QDISC_KIND_TBF, 0
TrivialLinkEqualizer.Parent, config_parse_qdisc_parent, QDISC_KIND_TEQL, 0 TrivialLinkEqualizer.Parent, config_parse_qdisc_parent, QDISC_KIND_TEQL, 0
TrivialLinkEqualizer.Handle, config_parse_qdisc_handle, QDISC_KIND_TEQL, 0
TrivialLinkEqualizer.Id, config_parse_trivial_link_equalizer_id, 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 */ /* backwards compatibility: do not add new entries to this section */
Network.IPv4LL, config_parse_ipv4ll, 0, offsetof(Network, link_local) Network.IPv4LL, config_parse_ipv4ll, 0, offsetof(Network, link_local)

View File

@ -270,7 +270,8 @@ int config_parse_qdisc_parent(
if (streq(rvalue, "root")) { if (streq(rvalue, "root")) {
qdisc->parent = TC_H_ROOT; qdisc->parent = TC_H_ROOT;
qdisc->handle = TC_H_UNSPEC; if (qdisc->handle == 0)
qdisc->handle = TC_H_UNSPEC;
} else if (streq(rvalue, "clsact")) { } else if (streq(rvalue, "clsact")) {
qdisc->parent = TC_H_CLSACT; qdisc->parent = TC_H_CLSACT;
qdisc->handle = TC_H_MAKE(TC_H_CLSACT, 0); qdisc->handle = TC_H_MAKE(TC_H_CLSACT, 0);
@ -296,3 +297,49 @@ int config_parse_qdisc_parent(
return 0; return 0;
} }
int config_parse_qdisc_handle(
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;
Network *network = data;
uint16_t n;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r < 0)
return r;
if (isempty(rvalue)) {
qdisc->handle = TC_H_UNSPEC;
qdisc = NULL;
return 0;
}
r = safe_atou16_full(rvalue, 16, &n);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse 'Handle=', ignoring assignment: %s",
rvalue);
return 0;
}
qdisc->handle = (uint32_t) n << 16;
qdisc = NULL;
return 0;
}

View File

@ -66,6 +66,7 @@ int qdisc_section_verify(QDisc *qdisc, bool *has_root, bool *has_clsact);
DEFINE_NETWORK_SECTION_FUNCTIONS(QDisc, qdisc_free); DEFINE_NETWORK_SECTION_FUNCTIONS(QDisc, qdisc_free);
CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_parent); CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_parent);
CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle);
#include "codel.h" #include "codel.h"
#include "fq-codel.h" #include "fq-codel.h"

View File

@ -272,8 +272,10 @@ Id=
Gateway= Gateway=
[QDisc] [QDisc]
Parent= Parent=
Handle=
[NetworkEmulator] [NetworkEmulator]
Parent= Parent=
Handle=
DelaySec= DelaySec=
DelayJitterSec= DelayJitterSec=
LossRate= LossRate=
@ -281,6 +283,7 @@ DuplicateRate=
PacketLimit= PacketLimit=
[TokenBucketFilter] [TokenBucketFilter]
Parent= Parent=
Handle=
Rate= Rate=
Burst= Burst=
LimitSize= LimitSize=
@ -290,9 +293,11 @@ PeakRate=
LatencySec= LatencySec=
[StochasticFairnessQueueing] [StochasticFairnessQueueing]
Parent= Parent=
Handle=
PerturbPeriodSec= PerturbPeriodSec=
[FairQueueingControlledDelay] [FairQueueingControlledDelay]
Parent= Parent=
Handle=
PacketLimit= PacketLimit=
MemoryLimit= MemoryLimit=
Flows= Flows=
@ -303,6 +308,7 @@ CEThresholdSec=
ECN= ECN=
[FairQueueing] [FairQueueing]
Parent= Parent=
Handle=
PacketLimit= PacketLimit=
FlowLimit= FlowLimit=
Quantum= Quantum=
@ -314,6 +320,7 @@ Pacing=
CEThresholdSec= CEThresholdSec=
[ControlledDelay] [ControlledDelay]
Parent= Parent=
Handle=
PacketLimit= PacketLimit=
TargetSec= TargetSec=
IntervalSec= IntervalSec=
@ -328,4 +335,5 @@ NetworkEmulatorDuplicateRate=
NetworkEmulatorPacketLimit= NetworkEmulatorPacketLimit=
[TrivialLinkEqualizer] [TrivialLinkEqualizer]
Parent= Parent=
Handle=
Id= Id=

View File

@ -7,6 +7,7 @@ Address=10.1.2.3/16
[FairQueueing] [FairQueueing]
Parent=root Parent=root
Handle=0003
PacketLimit=1000 PacketLimit=1000
FlowLimit=200 FlowLimit=200
Quantum=1500 Quantum=1500

View File

@ -7,6 +7,7 @@ Address=10.1.2.3/16
[NetworkEmulator] [NetworkEmulator]
Parent=root Parent=root
Handle=001f
DelaySec=50ms DelaySec=50ms
DelayJitterSec=10ms DelayJitterSec=10ms
LossRate=20% LossRate=20%

View File

@ -7,6 +7,7 @@ Address=10.1.2.4/16
[TokenBucketFilter] [TokenBucketFilter]
Parent=root Parent=root
Handle=003f
Rate=1G Rate=1G
Burst=5K Burst=5K
LatencySec=70msec LatencySec=70msec

View File

@ -7,4 +7,5 @@ Address=10.1.2.3/16
[TrivialLinkEqualizer] [TrivialLinkEqualizer]
Parent=root Parent=root
Handle=0002
Id=1 Id=1

View File

@ -2243,13 +2243,13 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
output = check_output('tc qdisc show dev dummy98') output = check_output('tc qdisc show dev dummy98')
print(output) print(output)
self.assertRegex(output, 'qdisc netem') self.assertRegex(output, 'qdisc netem 1f:')
self.assertRegex(output, 'limit 100 delay 50.0ms 10.0ms loss 20%') self.assertRegex(output, 'limit 100 delay 50.0ms 10.0ms loss 20%')
self.assertRegex(output, 'qdisc fq_codel') self.assertRegex(output, 'qdisc fq_codel')
self.assertRegex(output, 'limit 20480p flows 2048 quantum 1400 target 10.0ms ce_threshold 100.0ms interval 200.0ms memory_limit 64Mb ecn') self.assertRegex(output, 'limit 20480p flows 2048 quantum 1400 target 10.0ms ce_threshold 100.0ms interval 200.0ms memory_limit 64Mb ecn')
output = check_output('tc qdisc show dev test1') output = check_output('tc qdisc show dev test1')
print(output) print(output)
self.assertRegex(output, 'qdisc tbf') self.assertRegex(output, 'qdisc tbf 3f:')
self.assertRegex(output, 'rate 1Gbit burst 5000b peakrate 100Gbit minburst 987500b lat 70.0ms') self.assertRegex(output, 'rate 1Gbit burst 5000b peakrate 100Gbit minburst 987500b lat 70.0ms')
self.assertRegex(output, 'qdisc sfq') self.assertRegex(output, 'qdisc sfq')
self.assertRegex(output, 'perturb 5sec') self.assertRegex(output, 'perturb 5sec')
@ -2263,7 +2263,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
output = check_output('tc qdisc show dev dummy98') output = check_output('tc qdisc show dev dummy98')
print(output) print(output)
self.assertRegex(output, 'qdisc fq') self.assertRegex(output, 'qdisc fq 3:')
self.assertRegex(output, 'limit 1000p flow_limit 200p buckets 512 orphan_mask 511') self.assertRegex(output, 'limit 1000p flow_limit 200p buckets 512 orphan_mask 511')
self.assertRegex(output, 'quantum 1500') self.assertRegex(output, 'quantum 1500')
self.assertRegex(output, 'initial_quantum 13000') self.assertRegex(output, 'initial_quantum 13000')
@ -2299,7 +2299,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
output = check_output('tc qdisc show dev dummy98') output = check_output('tc qdisc show dev dummy98')
print(output) print(output)
self.assertRegex(output, 'qdisc teql1') self.assertRegex(output, 'qdisc teql1 2:')
class NetworkdStateFileTests(unittest.TestCase, Utilities): class NetworkdStateFileTests(unittest.TestCase, Utilities):
links = [ links = [