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 const QDiscVTable drr_vtable
= {
14 .object_size
= sizeof(DeficitRoundRobinScheduler
),
18 static int drr_class_fill_message(Link
*link
, TClass
*tclass
, sd_netlink_message
*req
) {
19 DeficitRoundRobinSchedulerClass
*drr
;
26 drr
= TCLASS_TO_DRR(tclass
);
28 r
= sd_netlink_message_open_container_union(req
, TCA_OPTIONS
, "drr");
30 return log_link_error_errno(link
, r
, "Could not open container TCA_OPTIONS: %m");
32 if (drr
->quantum
> 0) {
33 r
= sd_netlink_message_append_u32(req
, TCA_DRR_QUANTUM
, drr
->quantum
);
35 return log_link_error_errno(link
, r
, "Could not append TCA_DRR_QUANTUM, attribute: %m");
38 r
= sd_netlink_message_close_container(req
);
40 return log_link_error_errno(link
, r
, "Could not close container TCA_OPTIONS: %m");
45 int config_parse_drr_size(
50 unsigned section_line
,
57 _cleanup_(tclass_free_or_set_invalidp
) TClass
*tclass
= NULL
;
58 DeficitRoundRobinSchedulerClass
*drr
;
59 Network
*network
= data
;
68 r
= tclass_new_static(TCLASS_KIND_DRR
, network
, filename
, section_line
, &tclass
);
70 return log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
71 "Failed to create traffic control class, ignoring assignment: %m");
73 drr
= TCLASS_TO_DRR(tclass
);
75 if (isempty(rvalue
)) {
82 r
= parse_size(rvalue
, 1024, &u
);
84 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
85 "Failed to parse '%s=', ignoring assignment: %s",
90 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid '%s=', ignoring assignment: %s",
95 drr
->quantum
= (uint32_t) u
;
101 const TClassVTable drr_tclass_vtable
= {
102 .object_size
= sizeof(DeficitRoundRobinSchedulerClass
),
104 .fill_message
= drr_class_fill_message
,