1 /* SPDX-License-Identifier: GPL-2.0 */
3 * q_log.c plug scheduler
5 * Copyright (C) 2019 Paolo Abeni <pabeni@redhat.com>
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
20 static void explain(void)
22 fprintf(stderr
, "Usage: ... plug [block | release | release_indefinite | limit NUMBER]\n");
25 static int plug_parse_opt(struct qdisc_util
*qu
, int argc
, char **argv
,
26 struct nlmsghdr
*n
, const char *dev
)
28 struct tc_plug_qopt opt
= {};
32 if (strcmp(*argv
, "block") == 0) {
33 opt
.action
= TCQ_PLUG_BUFFER
;
35 } else if (strcmp(*argv
, "release") == 0) {
36 opt
.action
= TCQ_PLUG_RELEASE_ONE
;
38 } else if (strcmp(*argv
, "release_indefinite") == 0) {
39 opt
.action
= TCQ_PLUG_RELEASE_INDEFINITE
;
41 } else if (strcmp(*argv
, "limit") == 0) {
42 opt
.action
= TCQ_PLUG_LIMIT
;
44 if (get_size(&opt
.limit
, *argv
)) {
45 fprintf(stderr
, "Illegal value for \"limit\": \"%s\"\n", *argv
);
49 } else if (strcmp(*argv
, "help") == 0) {
53 fprintf(stderr
, "%s: unknown parameter \"%s\"\n", qu
->id
, *argv
);
61 addattr_l(n
, 1024, TCA_OPTIONS
, &opt
, sizeof(opt
));
65 static int plug_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
67 /* dummy implementation as sch_plug does not implement a dump op */
72 struct qdisc_util plug_qdisc_util
= {
74 .parse_qopt
= plug_parse_opt
,
75 .print_qopt
= plug_print_opt
,