blob: a7e42572db19d44a81ab10d9176ff85cced1d846 [file] [log] [blame]
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +00001/*
2 * tc_util.c Misc TC utility functions.
3 *
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.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 */
12
13#include <stdio.h>
14#include <stdlib.h>
15#include <unistd.h>
16#include <syslog.h>
17#include <fcntl.h>
18#include <sys/socket.h>
19#include <netinet/in.h>
20#include <arpa/inet.h>
21#include <string.h>
22#include <math.h>
23
24#include "utils.h"
25#include "tc_util.h"
26
osdl.org!shemmingerdbd90dc2004-06-02 20:22:08 +000027int get_qdisc_handle(__u32 *h, const char *str)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +000028{
29 __u32 maj;
30 char *p;
31
32 maj = TC_H_UNSPEC;
33 if (strcmp(str, "none") == 0)
34 goto ok;
35 maj = strtoul(str, &p, 16);
36 if (p == str)
37 return -1;
38 maj <<= 16;
39 if (*p != ':' && *p!=0)
40 return -1;
41ok:
42 *h = maj;
43 return 0;
44}
45
osdl.org!shemmingerdbd90dc2004-06-02 20:22:08 +000046int get_tc_classid(__u32 *h, const char *str)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +000047{
48 __u32 maj, min;
49 char *p;
50
51 maj = TC_H_ROOT;
52 if (strcmp(str, "root") == 0)
53 goto ok;
54 maj = TC_H_UNSPEC;
55 if (strcmp(str, "none") == 0)
56 goto ok;
57 maj = strtoul(str, &p, 16);
58 if (p == str) {
59 maj = 0;
60 if (*p != ':')
61 return -1;
62 }
63 if (*p == ':') {
osdl.net!shemmingera8b303c2005-02-07 18:16:29 +000064 if (maj >= (1<<16))
65 return -1;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +000066 maj <<= 16;
67 str = p+1;
68 min = strtoul(str, &p, 16);
69 if (*p != 0)
70 return -1;
osdl.net!shemmingera8b303c2005-02-07 18:16:29 +000071 if (min >= (1<<16))
72 return -1;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +000073 maj |= min;
74 } else if (*p != 0)
75 return -1;
76
77ok:
78 *h = maj;
79 return 0;
80}
81
82int print_tc_classid(char *buf, int len, __u32 h)
83{
84 if (h == TC_H_ROOT)
85 sprintf(buf, "root");
86 else if (h == TC_H_UNSPEC)
87 snprintf(buf, len, "none");
88 else if (TC_H_MAJ(h) == 0)
89 snprintf(buf, len, ":%x", TC_H_MIN(h));
90 else if (TC_H_MIN(h) == 0)
91 snprintf(buf, len, "%x:", TC_H_MAJ(h)>>16);
92 else
93 snprintf(buf, len, "%x:%x", TC_H_MAJ(h)>>16, TC_H_MIN(h));
94 return 0;
95}
96
97char * sprint_tc_classid(__u32 h, char *buf)
98{
99 if (print_tc_classid(buf, SPRINT_BSIZE-1, h))
100 strcpy(buf, "???");
101 return buf;
102}
103
osdl.net!shemminger26ab0b12004-08-13 23:23:46 +0000104/* See http://physics.nist.gov/cuu/Units/binary.html */
105static const struct rate_suffix {
106 const char *name;
107 double scale;
108} suffixes[] = {
109 { "bit", 1. },
110 { "Kibit", 1024. },
111 { "kbit", 1000. },
112 { "mibit", 1024.*1024. },
113 { "mbit", 1000000. },
114 { "gibit", 1024.*1024.*1024. },
115 { "gbit", 1000000000. },
116 { "tibit", 1024.*1024.*1024.*1024. },
117 { "tbit", 1000000000000. },
118 { "Bps", 8. },
119 { "KiBps", 8.*1024. },
120 { "KBps", 8000. },
121 { "MiBps", 8.*1024*1024. },
122 { "MBps", 8000000. },
123 { "GiBps", 8.*1024.*1024.*1024. },
124 { "GBps", 8000000000. },
125 { "TiBps", 8.*1024.*1024.*1024.*1024. },
126 { "TBps", 8000000000000. },
127 { NULL }
128};
129
130
osdl.org!shemmingerdbd90dc2004-06-02 20:22:08 +0000131int get_rate(unsigned *rate, const char *str)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000132{
133 char *p;
134 double bps = strtod(str, &p);
osdl.net!shemminger26ab0b12004-08-13 23:23:46 +0000135 const struct rate_suffix *s;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000136
137 if (p == str)
138 return -1;
139
osdl.net!shemminger26ab0b12004-08-13 23:23:46 +0000140 if (*p == '\0') {
141 *rate = bps / 8.; /* assume bytes/sec */
142 return 0;
143 }
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000144
osdl.net!shemminger26ab0b12004-08-13 23:23:46 +0000145 for (s = suffixes; s->name; ++s) {
146 if (strcasecmp(s->name, p) == 0) {
147 *rate = (bps * s->scale) / 8.;
148 return 0;
149 }
150 }
151
152 return -1;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000153}
154
155int get_rate_and_cell(unsigned *rate, int *cell_log, char *str)
156{
157 char * slash = strchr(str, '/');
158
159 if (slash)
160 *slash = 0;
161
162 if (get_rate(rate, str))
163 return -1;
164
165 if (slash) {
166 int cell;
167 int i;
168
169 if (get_integer(&cell, slash+1, 0))
170 return -1;
171 *slash = '/';
172
173 for (i=0; i<32; i++) {
174 if ((1<<i) == cell) {
175 *cell_log = i;
176 return 0;
177 }
178 }
179 return -1;
180 }
181 return 0;
182}
183
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000184void print_rate(char *buf, int len, __u32 rate)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000185{
186 double tmp = (double)rate*8;
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000187 extern int use_iec;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000188
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000189 if (use_iec) {
osdl.net!shemmingerabf1d0b2004-10-19 19:51:41 +0000190 if (tmp >= 1000.0*1024.0*1024.0)
191 snprintf(buf, len, "%.0fMibit", tmp/1024.0*1024.0);
192 else if (tmp >= 1000.0*1024)
193 snprintf(buf, len, "%.0fKibit", tmp/1024);
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000194 else
osdl.net!shemmingerabf1d0b2004-10-19 19:51:41 +0000195 snprintf(buf, len, "%.0fbit", tmp);
196 } else {
197 if (tmp >= 1000.0*1000000.0)
198 snprintf(buf, len, "%.0fMbit", tmp/1000000.0);
199 else if (tmp >= 1000.0 * 1000.0)
200 snprintf(buf, len, "%.0fKbit", tmp/1000.0);
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000201 else
osdl.net!shemmingerabf1d0b2004-10-19 19:51:41 +0000202 snprintf(buf, len, "%.0fbit", tmp);
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000203 }
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000204}
205
206char * sprint_rate(__u32 rate, char *buf)
207{
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000208 print_rate(buf, SPRINT_BSIZE-1, rate);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000209 return buf;
210}
211
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100212int get_time(unsigned *time, const char *str)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000213{
214 double t;
215 char *p;
216
217 t = strtod(str, &p);
218 if (p == str)
219 return -1;
220
221 if (*p) {
222 if (strcasecmp(p, "s") == 0 || strcasecmp(p, "sec")==0 ||
223 strcasecmp(p, "secs")==0)
Patrick McHardyf0bda7e2007-03-04 20:14:59 +0100224 t *= TIME_UNITS_PER_SEC;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000225 else if (strcasecmp(p, "ms") == 0 || strcasecmp(p, "msec")==0 ||
226 strcasecmp(p, "msecs") == 0)
Patrick McHardyf0bda7e2007-03-04 20:14:59 +0100227 t *= TIME_UNITS_PER_SEC/1000;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000228 else if (strcasecmp(p, "us") == 0 || strcasecmp(p, "usec")==0 ||
229 strcasecmp(p, "usecs") == 0)
Patrick McHardyf0bda7e2007-03-04 20:14:59 +0100230 t *= TIME_UNITS_PER_SEC/1000000;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000231 else
232 return -1;
233 }
234
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100235 *time = t;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000236 return 0;
237}
238
239
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100240void print_time(char *buf, int len, __u32 time)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000241{
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100242 double tmp = time;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000243
Patrick McHardyf0bda7e2007-03-04 20:14:59 +0100244 if (tmp >= TIME_UNITS_PER_SEC)
245 snprintf(buf, len, "%.1fs", tmp/TIME_UNITS_PER_SEC);
246 else if (tmp >= TIME_UNITS_PER_SEC/1000)
247 snprintf(buf, len, "%.1fms", tmp/(TIME_UNITS_PER_SEC/1000));
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000248 else
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100249 snprintf(buf, len, "%uus", time);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000250}
251
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100252char * sprint_time(__u32 time, char *buf)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000253{
Patrick McHardy8f34caa2007-03-04 20:15:00 +0100254 print_time(buf, SPRINT_BSIZE-1, time);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000255 return buf;
256}
257
Patrick McHardybd29e352007-03-04 20:15:01 +0100258char * sprint_ticks(__u32 ticks, char *buf)
259{
260 return sprint_time(tc_core_tick2time(ticks), buf);
261}
262
osdl.org!shemmingerdbd90dc2004-06-02 20:22:08 +0000263int get_size(unsigned *size, const char *str)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000264{
265 double sz;
266 char *p;
267
268 sz = strtod(str, &p);
269 if (p == str)
270 return -1;
271
272 if (*p) {
273 if (strcasecmp(p, "kb") == 0 || strcasecmp(p, "k")==0)
274 sz *= 1024;
osdl.org!shemmingerdbd90dc2004-06-02 20:22:08 +0000275 else if (strcasecmp(p, "gb") == 0 || strcasecmp(p, "g")==0)
276 sz *= 1024*1024*1024;
277 else if (strcasecmp(p, "gbit") == 0)
278 sz *= 1024*1024*1024/8;
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000279 else if (strcasecmp(p, "mb") == 0 || strcasecmp(p, "m")==0)
280 sz *= 1024*1024;
281 else if (strcasecmp(p, "mbit") == 0)
282 sz *= 1024*1024/8;
283 else if (strcasecmp(p, "kbit") == 0)
284 sz *= 1024/8;
285 else if (strcasecmp(p, "b") != 0)
286 return -1;
287 }
288
289 *size = sz;
290 return 0;
291}
292
293int get_size_and_cell(unsigned *size, int *cell_log, char *str)
294{
295 char * slash = strchr(str, '/');
296
297 if (slash)
298 *slash = 0;
299
300 if (get_size(size, str))
301 return -1;
302
303 if (slash) {
304 int cell;
305 int i;
306
307 if (get_integer(&cell, slash+1, 0))
308 return -1;
309 *slash = '/';
310
311 for (i=0; i<32; i++) {
312 if ((1<<i) == cell) {
313 *cell_log = i;
314 return 0;
315 }
316 }
317 return -1;
318 }
319 return 0;
320}
321
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000322void print_size(char *buf, int len, __u32 sz)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000323{
324 double tmp = sz;
325
326 if (sz >= 1024*1024 && fabs(1024*1024*rint(tmp/(1024*1024)) - sz) < 1024)
327 snprintf(buf, len, "%gMb", rint(tmp/(1024*1024)));
328 else if (sz >= 1024 && fabs(1024*rint(tmp/1024) - sz) < 16)
329 snprintf(buf, len, "%gKb", rint(tmp/1024));
330 else
331 snprintf(buf, len, "%ub", sz);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000332}
333
334char * sprint_size(__u32 size, char *buf)
335{
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000336 print_size(buf, SPRINT_BSIZE-1, size);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000337 return buf;
338}
339
osdl.net!shemminger25f86902004-08-24 18:54:49 +0000340static const double max_percent_value = 0xffffffff;
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000341
342int get_percent(__u32 *percent, const char *str)
343{
344 char *p;
osdl.net!shemminger25f86902004-08-24 18:54:49 +0000345 double per = strtod(str, &p) / 100.;
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000346
osdl.net!shemminger25f86902004-08-24 18:54:49 +0000347 if (per > 1. || per < 0)
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000348 return -1;
349 if (*p && strcmp(p, "%"))
350 return -1;
351
osdl.net!shemminger25f86902004-08-24 18:54:49 +0000352 *percent = (unsigned) rint(per * max_percent_value);
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000353 return 0;
354}
355
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000356void print_percent(char *buf, int len, __u32 per)
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000357{
osdl.net!shemminger25f86902004-08-24 18:54:49 +0000358 snprintf(buf, len, "%g%%", 100. * (double) per / max_percent_value);
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000359}
360
361char * sprint_percent(__u32 per, char *buf)
362{
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000363 print_percent(buf, SPRINT_BSIZE-1, per);
osdl.net!shemminger63e989f2004-06-25 20:59:28 +0000364 return buf;
365}
366
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000367void print_qdisc_handle(char *buf, int len, __u32 h)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000368{
369 snprintf(buf, len, "%x:", TC_H_MAJ(h)>>16);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000370}
371
372char * sprint_qdisc_handle(__u32 h, char *buf)
373{
osdl.net!shemmingerd40b38b2004-06-28 20:42:59 +0000374 print_qdisc_handle(buf, SPRINT_BSIZE-1, h);
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000375 return buf;
376}
377
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000378char * action_n2a(int action, char *buf, int len)
379{
380 switch (action) {
381 case -1:
382 return "continue";
383 break;
384 case TC_ACT_OK:
385 return "pass";
386 break;
387 case TC_ACT_SHOT:
388 return "drop";
389 break;
390 case TC_ACT_RECLASSIFY:
391 return "reclassify";
392 case TC_ACT_PIPE:
393 return "pipe";
394 case TC_ACT_STOLEN:
395 return "stolen";
396 default:
397 snprintf(buf, len, "%d", action);
398 return buf;
399 }
400}
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000401
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000402int action_a2n(char *arg, int *result)
403{
404 int res;
405
406 if (matches(arg, "continue") == 0)
407 res = -1;
408 else if (matches(arg, "drop") == 0)
409 res = TC_ACT_SHOT;
410 else if (matches(arg, "shot") == 0)
411 res = TC_ACT_SHOT;
412 else if (matches(arg, "pass") == 0)
413 res = TC_ACT_OK;
414 else if (strcmp(arg, "ok") == 0)
415 res = TC_ACT_OK;
416 else if (matches(arg, "reclassify") == 0)
417 res = TC_ACT_RECLASSIFY;
418 else {
419 char dummy;
420 if (sscanf(arg, "%d%c", &res, &dummy) != 1)
421 return -1;
422 }
423 *result = res;
424 return 0;
425}
426
osdl.net!shemminger6dc9f012004-08-31 17:45:21 +0000427void print_tm(FILE * f, const struct tcf_t *tm)
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000428{
net[shemminger]!shemminger5e8bc632005-03-14 18:44:54 +0000429 int hz = get_user_hz();
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000430 if (tm->install != 0)
osdl.net!shemminger63ae25d2005-03-10 19:04:17 +0000431 fprintf(f, " installed %u sec", (unsigned)(tm->install/hz));
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000432 if (tm->lastuse != 0)
osdl.net!shemminger63ae25d2005-03-10 19:04:17 +0000433 fprintf(f, " used %u sec", (unsigned)(tm->lastuse/hz));
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000434 if (tm->expires != 0)
osdl.net!shemminger63ae25d2005-03-10 19:04:17 +0000435 fprintf(f, " expires %u sec", (unsigned)(tm->expires/hz));
osdl.net!shemminger2373fde2004-08-13 23:54:55 +0000436}
ch[shemminger]!tgrafe5879dc2004-12-07 23:52:52 +0000437
438void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats)
439{
440 SPRINT_BUF(b1);
14!tgraf7d69fd92005-01-18 22:11:58 +0000441 struct rtattr *tbs[TCA_STATS_MAX + 1];
ch[shemminger]!tgrafe5879dc2004-12-07 23:52:52 +0000442
14!tgraf7d69fd92005-01-18 22:11:58 +0000443 parse_rtattr_nested(tbs, TCA_STATS_MAX, rta);
ch[shemminger]!tgrafe5879dc2004-12-07 23:52:52 +0000444
445 if (tbs[TCA_STATS_BASIC]) {
446 struct gnet_stats_basic bs = {0};
447 memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]), sizeof(bs)));
448 fprintf(fp, "%sSent %llu bytes %u pkt",
net[shemminger]!shemmingerb9062432005-01-17 23:28:16 +0000449 prefix, (unsigned long long) bs.bytes, bs.packets);
ch[shemminger]!tgrafe5879dc2004-12-07 23:52:52 +0000450 }
451
452 if (tbs[TCA_STATS_QUEUE]) {
453 struct gnet_stats_queue q = {0};
454 memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
455 fprintf(fp, " (dropped %u, overlimits %u requeues %u) ",
456 q.drops, q.overlimits, q.requeues);
457 }
Stephen Hemmingerae665a52006-12-05 10:10:22 -0800458
ch[shemminger]!tgrafe5879dc2004-12-07 23:52:52 +0000459 if (tbs[TCA_STATS_RATE_EST]) {
460 struct gnet_stats_rate_est re = {0};
461 memcpy(&re, RTA_DATA(tbs[TCA_STATS_RATE_EST]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_RATE_EST]), sizeof(re)));
462 fprintf(fp, "\n%srate %s %upps ",
463 prefix, sprint_rate(re.bps, b1), re.pps);
464 }
465
466 if (tbs[TCA_STATS_QUEUE]) {
467 struct gnet_stats_queue q = {0};
468 memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
469 if (!tbs[TCA_STATS_RATE_EST])
470 fprintf(fp, "\n%s", prefix);
471 fprintf(fp, "backlog %s %up requeues %u ",
472 sprint_size(q.backlog, b1), q.qlen, q.requeues);
473 }
474
475 if (xstats)
476 *xstats = tbs[TCA_STATS_APP] ? : NULL;
477}
478
479void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats)
480{
481 SPRINT_BUF(b1);
482
483 if (tb[TCA_STATS2]) {
484 print_tcstats2_attr(fp, tb[TCA_STATS2], prefix, xstats);
485 if (xstats && NULL == *xstats)
486 goto compat_xstats;
487 return;
488 }
489 /* backward compatibility */
490 if (tb[TCA_STATS]) {
491 struct tc_stats st;
492
493 /* handle case where kernel returns more/less than we know about */
494 memset(&st, 0, sizeof(st));
495 memcpy(&st, RTA_DATA(tb[TCA_STATS]), MIN(RTA_PAYLOAD(tb[TCA_STATS]), sizeof(st)));
496
497 fprintf(fp, "%sSent %llu bytes %u pkts (dropped %u, overlimits %u) ",
Stephen Hemmingerae665a52006-12-05 10:10:22 -0800498 prefix, (unsigned long long)st.bytes, st.packets, st.drops,
ch[shemminger]!tgrafe5879dc2004-12-07 23:52:52 +0000499 st.overlimits);
500
501 if (st.bps || st.pps || st.qlen || st.backlog) {
502 fprintf(fp, "\n%s", prefix);
503 if (st.bps || st.pps) {
504 fprintf(fp, "rate ");
505 if (st.bps)
506 fprintf(fp, "%s ", sprint_rate(st.bps, b1));
507 if (st.pps)
508 fprintf(fp, "%upps ", st.pps);
509 }
510 if (st.qlen || st.backlog) {
511 fprintf(fp, "backlog ");
512 if (st.backlog)
513 fprintf(fp, "%s ", sprint_size(st.backlog, b1));
514 if (st.qlen)
515 fprintf(fp, "%up ", st.qlen);
516 }
517 }
518 }
519
520compat_xstats:
521 if (tb[TCA_XSTATS] && xstats)
522 *xstats = tb[TCA_XSTATS];
523}
524