2 * iplink_stats.c Extended statistics commands
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: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
15 #include <linux/if_link.h>
16 #include <netinet/ether.h>
19 #include "ip_common.h"
21 static void print_explain(FILE *f
)
23 fprintf(f
, "Usage: ... xstats type TYPE [ ARGS ]\n");
26 int iplink_ifla_xstats(int argc
, char **argv
)
28 struct link_util
*lu
= NULL
;
32 fprintf(stderr
, "xstats: missing argument\n");
36 if (matches(*argv
, "type") == 0) {
38 lu
= get_link_kind(*argv
);
40 invarg("invalid type", *argv
);
41 } else if (matches(*argv
, "help") == 0) {
42 print_explain(stdout
);
45 invarg("unknown argument", *argv
);
49 print_explain(stderr
);
53 if (!lu
->print_ifla_xstats
) {
54 fprintf(stderr
, "xstats: link type %s doesn't support xstats\n",
59 if (lu
->parse_ifla_xstats
&&
60 lu
->parse_ifla_xstats(lu
, argc
-1, argv
+1))
63 if (strstr(lu
->id
, "_slave"))
64 filt_mask
= IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE
);
66 filt_mask
= IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS
);
68 if (rtnl_statsdump_req_filter(&rth
, AF_UNSPEC
, filt_mask
) < 0) {
69 perror("Cannont send dump request");
74 if (rtnl_dump_filter(&rth
, lu
->print_ifla_xstats
, stdout
) < 0) {
76 fprintf(stderr
, "Dump terminated\n");