Compare commits
9 Commits
da1b880a3a
...
eae1ef076d
Author | SHA1 | Date |
---|---|---|
Christian Ehrhardt | eae1ef076d | |
Shengjing Zhu | 679ecd3616 | |
Lennart Poettering | 3e761fe2c9 | |
Yu Watanabe | 3d85f19ced | |
Yu Watanabe | dd1e09971b | |
Yu Watanabe | 21a925a4ac | |
Yu Watanabe | 0baddbd5ee | |
Susant Sahani | 7234b91596 | |
Yu Watanabe | eb34f4b3d2 |
|
@ -2450,6 +2450,14 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>FairQueueTrafficPolicingPacketLimit=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the hard limit on the real queue size. When this limit is reached, incoming packets are
|
||||
dropped. Defaults to unset and kernel's default is used.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
|
|
@ -734,14 +734,18 @@ static const NLTypeSystem rtnl_nexthop_type_system = {
|
|||
.types = rtnl_nexthop_types,
|
||||
};
|
||||
|
||||
static const NLType rtnl_tca_option_data_tbf_types[] = {
|
||||
[TCA_TBF_PARMS] = { .size = sizeof(struct tc_tbf_qopt) },
|
||||
[TCA_TBF_RTAB] = { .size = TC_RTAB_SIZE },
|
||||
[TCA_TBF_PTAB] = { .size = TC_RTAB_SIZE },
|
||||
[TCA_TBF_RATE64] = { .type = NETLINK_TYPE_U64 },
|
||||
[TCA_TBF_PRATE64] = { .type = NETLINK_TYPE_U64 },
|
||||
[TCA_TBF_BURST] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_TBF_PBURST] = { .type = NETLINK_TYPE_U32 },
|
||||
static const NLType rtnl_tca_option_data_fq_types[] = {
|
||||
[TCA_FQ_PLIMIT] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_FLOW_PLIMIT] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_QUANTUM] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_INITIAL_QUANTUM] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_RATE_ENABLE] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_FLOW_MAX_RATE] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_BUCKETS_LOG] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_FLOW_REFILL_DELAY] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_LOW_RATE_THRESHOLD] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_FQ_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType rtnl_tca_option_data_fq_codel_types[] = {
|
||||
|
@ -756,18 +760,31 @@ static const NLType rtnl_tca_option_data_fq_codel_types[] = {
|
|||
[TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType rtnl_tca_option_data_tbf_types[] = {
|
||||
[TCA_TBF_PARMS] = { .size = sizeof(struct tc_tbf_qopt) },
|
||||
[TCA_TBF_RTAB] = { .size = TC_RTAB_SIZE },
|
||||
[TCA_TBF_PTAB] = { .size = TC_RTAB_SIZE },
|
||||
[TCA_TBF_RATE64] = { .type = NETLINK_TYPE_U64 },
|
||||
[TCA_TBF_PRATE64] = { .type = NETLINK_TYPE_U64 },
|
||||
[TCA_TBF_BURST] = { .type = NETLINK_TYPE_U32 },
|
||||
[TCA_TBF_PBURST] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const char* const nl_union_tca_option_data_table[] = {
|
||||
[NL_UNION_TCA_OPTION_DATA_TBF] = "tbf",
|
||||
[NL_UNION_TCA_OPTION_DATA_FQ] = "fq",
|
||||
[NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = "fq_codel",
|
||||
[NL_UNION_TCA_OPTION_DATA_TBF] = "tbf",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(nl_union_tca_option_data, NLUnionTCAOptionData);
|
||||
|
||||
static const NLTypeSystem rtnl_tca_option_data_type_systems[] = {
|
||||
[NL_UNION_TCA_OPTION_DATA_TBF] = { .count = ELEMENTSOF(rtnl_tca_option_data_tbf_types),
|
||||
.types = rtnl_tca_option_data_tbf_types },
|
||||
[NL_UNION_TCA_OPTION_DATA_FQ] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_types),
|
||||
.types = rtnl_tca_option_data_fq_types },
|
||||
[NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_codel_types),
|
||||
.types = rtnl_tca_option_data_fq_codel_types },
|
||||
[NL_UNION_TCA_OPTION_DATA_TBF] = { .count = ELEMENTSOF(rtnl_tca_option_data_tbf_types),
|
||||
.types = rtnl_tca_option_data_tbf_types },
|
||||
};
|
||||
|
||||
static const NLTypeSystemUnion rtnl_tca_option_data_type_system_union = {
|
||||
|
|
|
@ -92,8 +92,9 @@ const char *nl_union_link_info_data_to_string(NLUnionLinkInfoData p) _const_;
|
|||
NLUnionLinkInfoData nl_union_link_info_data_from_string(const char *p) _pure_;
|
||||
|
||||
typedef enum NLUnionTCAOptionData {
|
||||
NL_UNION_TCA_OPTION_DATA_TBF,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ_CODEL,
|
||||
NL_UNION_TCA_OPTION_DATA_TBF,
|
||||
_NL_UNION_TCA_OPTION_DATA_MAX,
|
||||
_NL_UNION_TCA_OPTION_DATA_INVALID = -1,
|
||||
} NLUnionTCAOptionData;
|
||||
|
|
|
@ -574,7 +574,7 @@ static int parse_netmask_or_prefixlen(int family, const char **value, unsigned c
|
|||
|
||||
static int parse_cmdline_ip_address(Context *context, int family, const char *value) {
|
||||
union in_addr_union addr = {}, peer = {}, gateway = {};
|
||||
const char *hostname, *ifname, *dhcp_type, *dns, *p;
|
||||
const char *hostname = NULL, *ifname, *dhcp_type, *dns, *p;
|
||||
unsigned char prefixlen;
|
||||
int r;
|
||||
|
||||
|
@ -599,9 +599,11 @@ static int parse_cmdline_ip_address(Context *context, int family, const char *va
|
|||
if (!p)
|
||||
return -EINVAL;
|
||||
|
||||
if (p != value) {
|
||||
hostname = strndupa(value, p - value);
|
||||
if (!hostname_is_valid(hostname, false))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
value = p + 1;
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ sources = files('''
|
|||
networkd-util.h
|
||||
networkd-wifi.c
|
||||
networkd-wifi.h
|
||||
tc/fq.c
|
||||
tc/fq.h
|
||||
tc/fq-codel.c
|
||||
tc/fq-codel.h
|
||||
tc/netem.c
|
||||
|
|
|
@ -259,6 +259,7 @@ TrafficControlQueueingDiscipline.TokenBufferFilterPeakRate, con
|
|||
TrafficControlQueueingDiscipline.TokenBufferFilterLatencySec, config_parse_tc_token_buffer_filter_latency, 0, 0
|
||||
TrafficControlQueueingDiscipline.StochasticFairnessQueueingPerturbPeriodSec, config_parse_tc_stochastic_fairness_queueing_perturb_period, 0, 0
|
||||
TrafficControlQueueingDiscipline.FairQueuingControlledDelayPacketLimit, config_parse_tc_fair_queuing_controlled_delay_limit, 0, 0
|
||||
TrafficControlQueueingDiscipline.FairQueueTrafficPolicingPacketLimit, config_parse_tc_fair_queue_traffic_policing_packet_limit, 0, 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)
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+
|
||||
* Copyright © 2019 VMware, Inc. */
|
||||
|
||||
#include <linux/pkt_sched.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "fq.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
static int fair_queue_traffic_policing_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) {
|
||||
FairQueueTrafficPolicing *fq;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(qdisc);
|
||||
assert(req);
|
||||
|
||||
fq = FQ(qdisc);
|
||||
|
||||
r = sd_netlink_message_open_container_union(req, TCA_OPTIONS, "fq");
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not open container TCA_OPTIONS: %m");
|
||||
|
||||
r = sd_netlink_message_append_u32(req, TCA_FQ_PLIMIT, fq->limit);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append TCA_FQ_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_tc_fair_queue_traffic_policing_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;
|
||||
FairQueueTrafficPolicing *fq;
|
||||
Network *network = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = qdisc_new_static(QDISC_KIND_FQ, 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");
|
||||
|
||||
fq = FQ(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
fq->limit = 0;
|
||||
|
||||
qdisc = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = safe_atou32(rvalue, &fq->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 fq_vtable = {
|
||||
.object_size = sizeof(FairQueueTrafficPolicing),
|
||||
.tca_kind = "fq",
|
||||
.fill_message = fair_queue_traffic_policing_fill_message,
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+
|
||||
* Copyright © 2019 VMware, Inc. */
|
||||
#pragma once
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "qdisc.h"
|
||||
|
||||
typedef struct FairQueueTrafficPolicing {
|
||||
QDisc meta;
|
||||
|
||||
uint32_t limit;
|
||||
} FairQueueTrafficPolicing;
|
||||
|
||||
DEFINE_QDISC_CAST(FQ, FairQueueTrafficPolicing);
|
||||
extern const QDiscVTable fq_vtable;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_tc_fair_queue_traffic_policing_packet_limit);
|
|
@ -14,6 +14,7 @@
|
|||
#include "string-util.h"
|
||||
|
||||
const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
|
||||
[QDISC_KIND_FQ] = &fq_vtable,
|
||||
[QDISC_KIND_FQ_CODEL] = &fq_codel_vtable,
|
||||
[QDISC_KIND_NETEM] = &netem_vtable,
|
||||
[QDISC_KIND_SFQ] = &sfq_vtable,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "networkd-util.h"
|
||||
|
||||
typedef enum QDiscKind {
|
||||
QDISC_KIND_FQ,
|
||||
QDISC_KIND_FQ_CODEL,
|
||||
QDISC_KIND_NETEM,
|
||||
QDISC_KIND_SFQ,
|
||||
|
@ -62,6 +63,7 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(QDisc, qdisc_free);
|
|||
CONFIG_PARSER_PROTOTYPE(config_parse_tc_qdiscs_parent);
|
||||
|
||||
#include "fq-codel.h"
|
||||
#include "fq.h"
|
||||
#include "netem.h"
|
||||
#include "sfq.h"
|
||||
#include "tbf.h"
|
||||
|
|
|
@ -1562,13 +1562,13 @@ static int verify_arguments(void) {
|
|||
if (arg_userns_chown && arg_volatile_mode != VOLATILE_NO)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--volatile= and --private-users-chown may not be combined.");
|
||||
|
||||
/* If --network-namespace-path is given with any other network-related option, we need to error out,
|
||||
* to avoid conflicts between different network options. */
|
||||
/* If --network-namespace-path is given with any other network-related option (except --private-network),
|
||||
* we need to error out, to avoid conflicts between different network options. */
|
||||
if (arg_network_namespace_path &&
|
||||
(arg_network_interfaces || arg_network_macvlan ||
|
||||
arg_network_ipvlan || arg_network_veth_extra ||
|
||||
arg_network_bridge || arg_network_zone ||
|
||||
arg_network_veth || arg_private_network))
|
||||
arg_network_veth))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--network-namespace-path= cannot be combined with other network options.");
|
||||
|
||||
if (arg_network_bridge && arg_network_zone)
|
||||
|
|
|
@ -4,7 +4,7 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
|
|||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=180
|
||||
QEMU_TIMEOUT=300
|
||||
FSTYPE=ext4
|
||||
|
||||
test_setup() {
|
||||
|
|
|
@ -4,7 +4,7 @@ TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
|
|||
TEST_NO_NSPAWN=1
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
QEMU_TIMEOUT=180
|
||||
QEMU_TIMEOUT=300
|
||||
|
||||
test_setup() {
|
||||
create_empty_image_rootdir
|
||||
|
|
|
@ -150,7 +150,8 @@ function run {
|
|||
return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --private-network -b; then
|
||||
# allow combination of --network-namespace-path and --private-network
|
||||
if ! SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" --private-network -b; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Automatically generated by systemd-network-generator
|
||||
|
||||
[Match]
|
||||
Name=enp3s0
|
||||
|
||||
[Link]
|
||||
|
||||
[Network]
|
||||
DHCP=no
|
||||
|
||||
[DHCP]
|
||||
|
||||
[Address]
|
||||
Address=10.99.37.44/16
|
||||
|
||||
[Route]
|
||||
Gateway=10.99.10.1
|
|
@ -0,0 +1 @@
|
|||
root=/dev/nfs nfsroot=10.99.37.240:/srv/netroot,v3,tcp ip=10.99.37.44::10.99.10.1:255.255.0.0::enp3s0:off
|
|
@ -279,3 +279,4 @@ TokenBufferFilterPeakRate=
|
|||
TokenBufferFilterLatencySec=
|
||||
StochasticFairnessQueueingPerturbPeriodSec=
|
||||
FairQueuingControlledDelayPacketLimit=
|
||||
FairQueueTrafficPolicingPacketLimit=
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
[Match]
|
||||
Name=dummy98
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.1.2.3/16
|
||||
|
||||
[TrafficControlQueueingDiscipline]
|
||||
Parent=root
|
||||
FairQueueTrafficPolicingPacketLimit=1000
|
|
@ -1509,6 +1509,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
|||
'25-neighbor-ip-dummy.network',
|
||||
'25-neighbor-ip.network',
|
||||
'25-nexthop.network',
|
||||
'25-qdisc-fq.network',
|
||||
'25-qdisc-netem-and-fqcodel.network',
|
||||
'25-qdisc-tbf-and-sfq.network',
|
||||
'25-route-ipv6-src.network',
|
||||
|
@ -2102,6 +2103,17 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
|||
self.assertRegex(output, 'qdisc sfq')
|
||||
self.assertRegex(output, 'perturb 5sec')
|
||||
|
||||
def test_qdisc2(self):
|
||||
copy_unit_to_networkd_unit_path('25-qdisc-fq.network', '12-dummy.netdev')
|
||||
start_networkd()
|
||||
|
||||
self.wait_online(['dummy98:routable'])
|
||||
|
||||
output = check_output('tc qdisc show dev dummy98')
|
||||
print(output)
|
||||
self.assertRegex(output, 'qdisc fq')
|
||||
self.assertRegex(output, 'limit 1000p')
|
||||
|
||||
class NetworkdStateFileTests(unittest.TestCase, Utilities):
|
||||
links = [
|
||||
'dummy98',
|
||||
|
|
Loading…
Reference in New Issue