]> git.proxmox.com Git - mirror_iproute2.git/blame - tc/q_plug.c
Merge branch 'master' into next
[mirror_iproute2.git] / tc / q_plug.c
CommitLineData
c865c523
PA
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * q_log.c plug scheduler
4 *
5 * Copyright (C) 2019 Paolo Abeni <pabeni@redhat.com>
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <unistd.h>
11#include <fcntl.h>
12#include <sys/socket.h>
13#include <netinet/in.h>
14#include <arpa/inet.h>
15#include <string.h>
16
17#include "utils.h"
18#include "tc_util.h"
19
20static void explain(void)
21{
22 fprintf(stderr, "Usage: ... plug [block | release | release_indefinite | limit NUMBER]\n");
23}
24
25static int plug_parse_opt(struct qdisc_util *qu, int argc, char **argv,
26 struct nlmsghdr *n, const char *dev)
27{
28 struct tc_plug_qopt opt = {};
29 int ok = 0;
30
31 while (argc > 0) {
32 if (strcmp(*argv, "block") == 0) {
33 opt.action = TCQ_PLUG_BUFFER;
34 ok++;
35 } else if (strcmp(*argv, "release") == 0) {
36 opt.action = TCQ_PLUG_RELEASE_ONE;
37 ok++;
38 } else if (strcmp(*argv, "release_indefinite") == 0) {
39 opt.action = TCQ_PLUG_RELEASE_INDEFINITE;
40 ok++;
41 } else if (strcmp(*argv, "limit") == 0) {
42 opt.action = TCQ_PLUG_LIMIT;
43 NEXT_ARG();
44 if (get_size(&opt.limit, *argv)) {
45 fprintf(stderr, "Illegal value for \"limit\": \"%s\"\n", *argv);
46 return -1;
47 }
48 ok++;
49 } else if (strcmp(*argv, "help") == 0) {
50 explain();
51 return -1;
52 } else {
53 fprintf(stderr, "%s: unknown parameter \"%s\"\n", qu->id, *argv);
54 explain();
55 return -1;
56 }
57 argc--; argv++;
58 }
59
60 if (ok)
61 addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
62 return 0;
63}
64
65static int plug_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
66{
67 /* dummy implementation as sch_plug does not implement a dump op */
68 return 0;
69}
70
71
72struct qdisc_util plug_qdisc_util = {
73 .id = "plug",
74 .parse_qopt = plug_parse_opt,
75 .print_qopt = plug_print_opt,
76};