mirror of
https://github.com/systemd/systemd.git
synced 2025-01-23 17:03:39 +08:00
network tc: inroduce FQ - Fair Queue traffic policing
Please see http://man7.org/linux/man-pages/man8/tc-fq.8.html
This commit is contained in:
parent
eb34f4b3d2
commit
7234b91596
@ -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>
|
||||
|
||||
|
@ -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)
|
||||
|
93
src/network/tc/fq.c
Normal file
93
src/network/tc/fq.c
Normal file
@ -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,
|
||||
};
|
17
src/network/tc/fq.h
Normal file
17
src/network/tc/fq.h
Normal file
@ -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"
|
||||
|
@ -279,3 +279,4 @@ TokenBufferFilterPeakRate=
|
||||
TokenBufferFilterLatencySec=
|
||||
StochasticFairnessQueueingPerturbPeriodSec=
|
||||
FairQueuingControlledDelayPacketLimit=
|
||||
FairQueueTrafficPolicingPacketLimit=
|
||||
|
Loading…
Reference in New Issue
Block a user