mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-13 12:58:20 +03:00
network: TC introduce sfb - Stochastic Fair Blue
Please see https://www.systutorials.com/docs/linux/man/8-tc-sfb/
This commit is contained in:
parent
95edcf3fac
commit
982998b087
@ -2467,6 +2467,38 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[StochasticFairBlue] Section Options</title>
|
||||
<para>The <literal>[StochasticFairBlue]</literal> section manages the queueing discipline
|
||||
(qdisc) of stochastic fair blue (sfb).</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>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>
|
||||
<term><varname>PacketLimit=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the hard limit on the queue size in number of packets. When this limit is reached, incoming packets are
|
||||
dropped. An unsigned integer ranges 0 to 4294967294. Defaults to unset and kernel's default is used.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[StochasticFairnessQueueing] Section Options</title>
|
||||
<para>The <literal>[StochasticFairnessQueueing]</literal> section manages the queueing discipline
|
||||
|
@ -793,6 +793,10 @@ static const NLType rtnl_tca_option_data_htb_types[] = {
|
||||
[TCA_HTB_CEIL64] = { .type = NETLINK_TYPE_U64 },
|
||||
};
|
||||
|
||||
static const NLType rtnl_tca_option_data_sfb_types[] = {
|
||||
[TCA_SFB_PARMS] = { .size = sizeof(struct tc_sfb_qopt) },
|
||||
};
|
||||
|
||||
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 },
|
||||
@ -809,6 +813,7 @@ static const char* const nl_union_tca_option_data_table[] = {
|
||||
[NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = "fq_codel",
|
||||
[NL_UNION_TCA_OPTION_DATA_GRED] = "gred",
|
||||
[NL_UNION_TCA_OPTION_DATA_HTB] = "htb",
|
||||
[NL_UNION_TCA_OPTION_DATA_SFB] = "sfb",
|
||||
[NL_UNION_TCA_OPTION_DATA_TBF] = "tbf",
|
||||
};
|
||||
|
||||
@ -825,6 +830,8 @@ static const NLTypeSystem rtnl_tca_option_data_type_systems[] = {
|
||||
.types = rtnl_tca_option_data_gred_types },
|
||||
[NL_UNION_TCA_OPTION_DATA_HTB] = { .count = ELEMENTSOF(rtnl_tca_option_data_htb_types),
|
||||
.types = rtnl_tca_option_data_htb_types },
|
||||
[NL_UNION_TCA_OPTION_DATA_SFB] = { .count = ELEMENTSOF(rtnl_tca_option_data_sfb_types),
|
||||
.types = rtnl_tca_option_data_sfb_types },
|
||||
[NL_UNION_TCA_OPTION_DATA_TBF] = { .count = ELEMENTSOF(rtnl_tca_option_data_tbf_types),
|
||||
.types = rtnl_tca_option_data_tbf_types },
|
||||
};
|
||||
|
@ -97,6 +97,7 @@ typedef enum NLUnionTCAOptionData {
|
||||
NL_UNION_TCA_OPTION_DATA_FQ_CODEL,
|
||||
NL_UNION_TCA_OPTION_DATA_GRED,
|
||||
NL_UNION_TCA_OPTION_DATA_HTB,
|
||||
NL_UNION_TCA_OPTION_DATA_SFB,
|
||||
NL_UNION_TCA_OPTION_DATA_TBF,
|
||||
_NL_UNION_TCA_OPTION_DATA_MAX,
|
||||
_NL_UNION_TCA_OPTION_DATA_INVALID = -1,
|
||||
|
@ -123,6 +123,8 @@ sources = files('''
|
||||
tc/netem.h
|
||||
tc/qdisc.c
|
||||
tc/qdisc.h
|
||||
tc/sfb.c
|
||||
tc/sfb.h
|
||||
tc/sfq.c
|
||||
tc/sfq.h
|
||||
tc/tbf.c
|
||||
|
@ -305,6 +305,9 @@ NetworkEmulator.DelayJitterSec, config_parse_network_emulator_delay
|
||||
NetworkEmulator.LossRate, 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
|
||||
StochasticFairBlue.Parent, config_parse_qdisc_parent, QDISC_KIND_SFB, 0
|
||||
StochasticFairBlue.Handle, config_parse_qdisc_handle, QDISC_KIND_SFB, 0
|
||||
StochasticFairBlue.PacketLimit, config_parse_stochastic_fair_blue_u32, QDISC_KIND_SFB, 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
|
||||
|
@ -492,6 +492,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
"HierarchyTokenBucket\0"
|
||||
"HierarchyTokenBucketClass\0"
|
||||
"NetworkEmulator\0"
|
||||
"StochasticFairBlue\0"
|
||||
"StochasticFairnessQueueing\0"
|
||||
"TokenBucketFilter\0"
|
||||
"TrivialLinkEqualizer\0",
|
||||
|
@ -23,6 +23,7 @@ const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
|
||||
[QDISC_KIND_HTB] = &htb_vtable,
|
||||
[QDISC_KIND_NETEM] = &netem_vtable,
|
||||
[QDISC_KIND_PFIFO] = &pfifo_vtable,
|
||||
[QDISC_KIND_SFB] = &sfb_vtable,
|
||||
[QDISC_KIND_SFQ] = &sfq_vtable,
|
||||
[QDISC_KIND_TBF] = &tbf_vtable,
|
||||
[QDISC_KIND_TEQL] = &teql_vtable,
|
||||
|
@ -16,6 +16,7 @@ typedef enum QDiscKind {
|
||||
QDISC_KIND_HTB,
|
||||
QDISC_KIND_NETEM,
|
||||
QDISC_KIND_PFIFO,
|
||||
QDISC_KIND_SFB,
|
||||
QDISC_KIND_SFQ,
|
||||
QDISC_KIND_TBF,
|
||||
QDISC_KIND_TEQL,
|
||||
@ -83,6 +84,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle);
|
||||
#include "gred.h"
|
||||
#include "htb.h"
|
||||
#include "netem.h"
|
||||
#include "sfb.h"
|
||||
#include "sfq.h"
|
||||
#include "tbf.h"
|
||||
#include "teql.h"
|
||||
|
106
src/network/tc/sfb.c
Normal file
106
src/network/tc/sfb.c
Normal file
@ -0,0 +1,106 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+
|
||||
* Copyright © 2020 VMware, Inc. */
|
||||
|
||||
#include <linux/pkt_sched.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "qdisc.h"
|
||||
#include "sfb.h"
|
||||
#include "string-util.h"
|
||||
|
||||
static int stochastic_fair_blue_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) {
|
||||
StochasticFairBlue *sfb;
|
||||
struct tc_sfb_qopt opt = {
|
||||
.rehash_interval = 600*1000,
|
||||
.warmup_time = 60*1000,
|
||||
.penalty_rate = 10,
|
||||
.penalty_burst = 20,
|
||||
.increment = (SFB_MAX_PROB + 1000) / 2000,
|
||||
.decrement = (SFB_MAX_PROB + 10000) / 20000,
|
||||
.max = 25,
|
||||
.bin_size = 20,
|
||||
};
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(qdisc);
|
||||
assert(req);
|
||||
|
||||
sfb = SFB(qdisc);
|
||||
|
||||
opt.limit = sfb->packet_limit;
|
||||
|
||||
r = sd_netlink_message_open_container_union(req, TCA_OPTIONS, "sfb");
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not open container TCA_OPTIONS: %m");
|
||||
|
||||
r = sd_netlink_message_append_data(req, TCA_SFB_PARMS, &opt, sizeof(struct tc_sfb_qopt));
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append TCA_SFB_PARMS 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_stochastic_fair_blue_u32(
|
||||
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;
|
||||
StochasticFairBlue *sfb;
|
||||
Network *network = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = qdisc_new_static(QDISC_KIND_SFB, 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");
|
||||
|
||||
sfb = SFB(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
sfb->packet_limit = 0;
|
||||
|
||||
qdisc = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = safe_atou32(rvalue, &sfb->packet_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 sfb_vtable = {
|
||||
.object_size = sizeof(StochasticFairBlue),
|
||||
.tca_kind = "sfb",
|
||||
.fill_message = stochastic_fair_blue_fill_message,
|
||||
};
|
17
src/network/tc/sfb.h
Normal file
17
src/network/tc/sfb.h
Normal file
@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+
|
||||
* Copyright © 2020 VMware, Inc. */
|
||||
#pragma once
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "qdisc.h"
|
||||
|
||||
typedef struct StochasticFairBlue {
|
||||
QDisc meta;
|
||||
|
||||
uint32_t packet_limit;
|
||||
} StochasticFairBlue;
|
||||
|
||||
DEFINE_QDISC_CAST(SFB, StochasticFairBlue);
|
||||
extern const QDiscVTable sfb_vtable;
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_stochastic_fair_blue_u32);
|
@ -357,3 +357,7 @@ Handle=
|
||||
VirtualQueues=
|
||||
DefaultVirtualQueue=
|
||||
GenericRIO=
|
||||
[StochasticFairBlue]
|
||||
Parent=
|
||||
Handle=
|
||||
PacketLimit=
|
||||
|
Loading…
x
Reference in New Issue
Block a user