]>
git.proxmox.com Git - mirror_iproute2.git/blob - tc/tc_stab.c
2 * tc_stab.c "tc qdisc ... stab *".
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: Jussi Kivilinna, <jussi.kivilinna@mbnet.fi>
19 #include <sys/socket.h>
20 #include <netinet/in.h>
21 #include <arpa/inet.h>
28 #include "tc_common.h"
30 static void stab_help(void)
33 "Usage: ... stab [ mtu BYTES ] [ tsize SLOTS ] [ mpu BYTES ] \n"
34 " [ overhead BYTES ] [ linklayer TYPE ] ...\n"
35 " mtu : max packet size we create rate map for {2047}\n"
36 " tsize : how many slots should size table have {512}\n"
37 " mpu : minimum packet size used in rate computations\n"
38 " overhead : per-packet size overhead used in rate computations\n"
39 " linklayer : adapting to a linklayer e.g. atm\n"
40 "Example: ... stab overhead 20 linklayer atm\n");
45 int check_size_table_opts(struct tc_sizespec
*s
)
47 return s
->linklayer
>= LINKLAYER_ETHERNET
|| s
->mpu
!= 0 ||
51 int parse_size_table(int *argcp
, char ***argvp
, struct tc_sizespec
*sp
)
57 memset(&s
, 0, sizeof(s
));
60 if (matches(*argv
, "help") == 0) {
65 if (matches(*argv
, "mtu") == 0) {
69 if (get_u32(&s
.mtu
, *argv
, 10)) {
70 invarg("mtu", "invalid mtu");
73 } else if (matches(*argv
, "mpu") == 0) {
77 if (get_u32(&s
.mpu
, *argv
, 10)) {
78 invarg("mpu", "invalid mpu");
81 } else if (matches(*argv
, "overhead") == 0) {
84 duparg("overhead", *argv
);
85 if (get_integer(&s
.overhead
, *argv
, 10)) {
86 invarg("overhead", "invalid overhead");
89 } else if (matches(*argv
, "tsize") == 0) {
92 duparg("tsize", *argv
);
93 if (get_u32(&s
.tsize
, *argv
, 10)) {
94 invarg("tsize", "invalid table size");
97 } else if (matches(*argv
, "linklayer") == 0) {
99 if (s
.linklayer
!= LINKLAYER_UNSPEC
)
100 duparg("linklayer", *argv
);
101 if (get_linklayer(&s
.linklayer
, *argv
)) {
102 invarg("linklayer", "invalid linklayer");
110 if (!check_size_table_opts(&s
))
119 void print_size_table(FILE *fp
, const char *prefix
, struct rtattr
*rta
)
121 struct rtattr
*tb
[TCA_STAB_MAX
+ 1];
124 parse_rtattr_nested(tb
, TCA_STAB_MAX
, rta
);
126 if (tb
[TCA_STAB_BASE
]) {
127 struct tc_sizespec s
= {0};
128 memcpy(&s
, RTA_DATA(tb
[TCA_STAB_BASE
]),
129 MIN(RTA_PAYLOAD(tb
[TCA_STAB_BASE
]), sizeof(s
)));
131 fprintf(fp
, "%s", prefix
);
133 fprintf(fp
, "linklayer %s ",
134 sprint_linklayer(s
.linklayer
, b1
));
136 fprintf(fp
, "overhead %d ", s
.overhead
);
138 fprintf(fp
, "mpu %u ", s
.mpu
);
140 fprintf(fp
, "mtu %u ", s
.mtu
);
142 fprintf(fp
, "tsize %u ", s
.tsize
);
146 if (tb
[TCA_STAB_DATA
]) {
148 __u16
*data
= RTA_DATA(tb
[TCA_STAB_DATA
]);
149 dlen
= RTA_PAYLOAD(tb
[TCA_STAB_DATA
]) / sizeof(__u16
);
151 fprintf(fp
, "\n%sstab data:", prefix
);
152 for (i
= 0; i
< dlen
/12; i
++) {
153 fprintf(fp
, "\n%s %3u:", prefix
, i
* 12);
154 for (j
= 0; i
* 12 + j
< dlen
; j
++)
155 fprintf(fp
, " %05x", data
[i
* 12 + j
]);