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>
13 * Ole Husgaard <sparre@login.dknet.dk>: 990513: prio2band map was always reset.
14 * J Hadi Salim <hadi@cyberus.ca>: 990609: priomap fix.
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24 #include <arpa/inet.h>
30 static void explain(void)
32 fprintf(stderr
, "Usage: ... prio bands NUMBER priomap P1 P2...[multiqueue]\n");
35 #define usage() return(-1)
37 static int prio_parse_opt(struct qdisc_util
*qu
, int argc
, char **argv
, struct nlmsghdr
*n
)
42 struct tc_prio_qopt opt
={3,{ 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }};
47 if (strcmp(*argv
, "bands") == 0) {
51 if (get_integer(&opt
.bands
, *argv
, 10)) {
52 fprintf(stderr
, "Illegal \"bands\"\n");
56 } else if (strcmp(*argv
, "priomap") == 0) {
58 fprintf(stderr
, "Error: duplicate priomap\n");
62 } else if (strcmp(*argv
, "multiqueue") == 0) {
64 } else if (strcmp(*argv
, "help") == 0) {
70 fprintf(stderr
, "What is \"%s\"?\n", *argv
);
74 if (get_unsigned(&band
, *argv
, 10)) {
75 fprintf(stderr
, "Illegal \"priomap\" element\n");
78 if (band
> opt
.bands
) {
79 fprintf(stderr
, "\"priomap\" element is out of bands\n");
82 if (idx
> TC_PRIO_MAX
) {
83 fprintf(stderr
, "\"priomap\" index > TC_PRIO_MAX=%u\n", TC_PRIO_MAX
);
86 opt
.priomap
[idx
++] = band
;
93 for (; idx < TC_PRIO_MAX; idx++)
94 opt.priomap[idx] = opt.priomap[TC_PRIO_BESTEFFORT];
97 nest
= addattr_nest_compat(n
, 1024, TCA_OPTIONS
, &opt
, sizeof(opt
));
99 addattr_l(n
, 1024, TCA_PRIO_MQ
, NULL
, 0);
100 addattr_nest_compat_end(n
, nest
);
104 int prio_print_opt(struct qdisc_util
*qu
, FILE *f
, struct rtattr
*opt
)
107 struct tc_prio_qopt
*qopt
;
108 struct rtattr
*tb
[TCA_PRIO_MAX
+1];
113 if (parse_rtattr_nested_compat(tb
, TCA_PRIO_MAX
, opt
, qopt
,
117 fprintf(f
, "bands %u priomap ", qopt
->bands
);
118 for (i
=0; i
<=TC_PRIO_MAX
; i
++)
119 fprintf(f
, " %d", qopt
->priomap
[i
]);
122 fprintf(f
, " multiqueue: %s ",
123 *(unsigned char *)RTA_DATA(tb
[TCA_PRIO_MQ
]) ? "on" : "off");
128 struct qdisc_util prio_qdisc_util
= {
130 .parse_qopt
= prio_parse_opt
,
131 .print_qopt
= prio_print_opt
,