1 /* SPDX-License-Identifier: LGPL-2.1+
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"
13 static int pie_fill_message(Link
*link
, QDisc
*qdisc
, sd_netlink_message
*req
) {
14 ProportionalIntegralControllerEnhanced
*pie
;
23 r
= sd_netlink_message_open_container_union(req
, TCA_OPTIONS
, "pie");
25 return log_link_error_errno(link
, r
, "Could not open container TCA_OPTIONS: %m");
27 if (pie
->packet_limit
> 0) {
28 r
= sd_netlink_message_append_u32(req
, TCA_PIE_LIMIT
, pie
->packet_limit
);
30 return log_link_error_errno(link
, r
, "Could not append TCA_PIE_PLIMIT attribute: %m");
33 r
= sd_netlink_message_close_container(req
);
35 return log_link_error_errno(link
, r
, "Could not close container TCA_OPTIONS: %m");
40 int config_parse_pie_packet_limit(
45 unsigned section_line
,
52 _cleanup_(qdisc_free_or_set_invalidp
) QDisc
*qdisc
= NULL
;
53 ProportionalIntegralControllerEnhanced
*pie
;
54 Network
*network
= data
;
62 r
= qdisc_new_static(QDISC_KIND_PIE
, network
, filename
, section_line
, &qdisc
);
66 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
67 "More than one kind of queueing discipline, ignoring assignment: %m");
73 if (isempty(rvalue
)) {
74 pie
->packet_limit
= 0;
80 r
= safe_atou32(rvalue
, &pie
->packet_limit
);
82 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
83 "Failed to parse '%s=', ignoring assignment: %s",
93 const QDiscVTable pie_vtable
= {
94 .object_size
= sizeof(ProportionalIntegralControllerEnhanced
),
96 .fill_message
= pie_fill_message
,