1 /* SPDX-License-Identifier: LGPL-2.1-or-later
2 * Copyright © 2020 VMware, Inc. */
4 #include <linux/pkt_sched.h>
6 #include "alloc-util.h"
7 #include "conf-parser.h"
9 #include "netlink-util.h"
10 #include "parse-util.h"
11 #include "string-util.h"
14 static int heavy_hitter_filter_fill_message(Link
*link
, QDisc
*qdisc
, sd_netlink_message
*req
) {
15 HeavyHitterFilter
*hhf
;
24 r
= sd_netlink_message_open_container_union(req
, TCA_OPTIONS
, "hhf");
26 return log_link_error_errno(link
, r
, "Could not open container TCA_OPTIONS: %m");
28 if (hhf
->packet_limit
> 0) {
29 r
= sd_netlink_message_append_u32(req
, TCA_HHF_BACKLOG_LIMIT
, hhf
->packet_limit
);
31 return log_link_error_errno(link
, r
, "Could not append TCA_HHF_BACKLOG_LIMIT attribute: %m");
34 r
= sd_netlink_message_close_container(req
);
36 return log_link_error_errno(link
, r
, "Could not close container TCA_OPTIONS: %m");
41 int config_parse_heavy_hitter_filter_packet_limit(
46 unsigned section_line
,
53 _cleanup_(qdisc_free_or_set_invalidp
) QDisc
*qdisc
= NULL
;
54 HeavyHitterFilter
*hhf
;
55 Network
*network
= data
;
63 r
= qdisc_new_static(QDISC_KIND_HHF
, network
, filename
, section_line
, &qdisc
);
67 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
68 "More than one kind of queueing discipline, ignoring assignment: %m");
74 if (isempty(rvalue
)) {
75 hhf
->packet_limit
= 0;
81 r
= safe_atou32(rvalue
, &hhf
->packet_limit
);
83 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
84 "Failed to parse '%s=', ignoring assignment: %s",
94 const QDiscVTable hhf_vtable
= {
95 .object_size
= sizeof(HeavyHitterFilter
),
97 .fill_message
= heavy_hitter_filter_fill_message
,