4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
26 static void explain(void)
28 fprintf(stderr, "Usage: ... prio bands NUMBER priomap P1 P2...[multiqueue]\n");
31 #define usage() return(-1)
33 static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
38 struct tc_prio_qopt opt={3,{ 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }};
43 if (strcmp(*argv, "bands") == 0) {
47 if (get_integer(&opt.bands, *argv, 10)) {
48 fprintf(stderr, "Illegal \"bands\"\n");
52 } else if (strcmp(*argv, "priomap") == 0) {
54 fprintf(stderr, "Error: duplicate priomap\n");
58 } else if (strcmp(*argv, "multiqueue") == 0) {
60 } else if (strcmp(*argv, "help") == 0) {
66 fprintf(stderr, "What is \"%s\"?\n", *argv);
70 if (get_unsigned(&band, *argv, 10)) {
71 fprintf(stderr, "Illegal \"priomap\" element\n");
74 if (band > opt.bands) {
75 fprintf(stderr, "\"priomap\" element is out of bands\n");
78 if (idx > TC_PRIO_MAX) {
79 fprintf(stderr, "\"priomap\" index > TC_PRIO_MAX=%u\n", TC_PRIO_MAX);
82 opt.priomap[idx++] = band;
89 for (; idx < TC_PRIO_MAX; idx++)
90 opt.priomap[idx] = opt.priomap[TC_PRIO_BESTEFFORT];
93 nest = addattr_nest_compat(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
95 addattr_l(n, 1024, TCA_PRIO_MQ, NULL, 0);
96 addattr_nest_compat_end(n, nest);
100 int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
103 struct tc_prio_qopt *qopt;
104 struct rtattr *tb[TCA_PRIO_MAX+1];
109 if (parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt,
113 fprintf(f, "bands %u priomap ", qopt->bands);
114 for (i=0; i<=TC_PRIO_MAX; i++)
115 fprintf(f, " %d", qopt->priomap[i]);
118 fprintf(f, " multiqueue: %s ",
119 *(unsigned char *)RTA_DATA(tb[TCA_PRIO_MQ]) ? "on" : "off");
124 struct qdisc_util prio_qdisc_util = {
126 .parse_qopt = prio_parse_opt,
127 .print_qopt = prio_print_opt,