]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink: add support for xstats subcommand
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Sun, 19 Feb 2017 00:35:32 +0000 (16:35 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 19 Feb 2017 00:36:01 +0000 (16:36 -0800)
This patch adds support for a new xstats link subcommand which uses the
specified link type's new parse/print_ifla_xstats callbacks to display
extended statistics.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/Makefile
ip/ip_common.h
ip/iplink.c
man/man8/ip-link.8.in

index 1928489e7f9095affe0425396b088a0a6d546efc..4276a34b529e3f2565b5ddcf67ddd07a3f8dbdbe 100644 (file)
@@ -8,7 +8,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
     link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
     iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
     iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
-    ipvrf.o
+    ipvrf.o iplink_xstats.o
 
 RTMONOBJ=rtmon.o
 
index e8642a184f393b438f4b1ae756b3a2d03f709a5d..e046b57e92210e51e9d25c0b4454134d90736a8e 100644 (file)
@@ -62,6 +62,7 @@ void vrf_reset(void);
 int netns_identify_pid(const char *pidstr, char *name, int len);
 
 int iplink_get(unsigned int flags, char *name, __u32 filt_mask);
+int iplink_ifla_xstats(int argc, char **argv);
 
 static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
 {
@@ -85,9 +86,13 @@ struct link_util {
        void                    (*print_opt)(struct link_util *, FILE *,
                                             struct rtattr *[]);
        void                    (*print_xstats)(struct link_util *, FILE *,
-                                            struct rtattr *);
+                                               struct rtattr *);
        void                    (*print_help)(struct link_util *, int, char **,
-                                            FILE *);
+                                             FILE *);
+       int                     (*parse_ifla_xstats)(struct link_util *,
+                                                    int, char **);
+       int                     (*print_ifla_xstats)(const struct sockaddr_nl *,
+                                                    struct nlmsghdr *, void *);
 };
 
 struct link_util *get_link_kind(const char *kind);
index 2638408c23b878292cea9c162da6e0b861f617c4..00fed9006ea6f50105c5f16ad3a0134258a70da6 100644 (file)
@@ -98,6 +98,8 @@ void iplink_usage(void)
                "\n"
                "       ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]\n");
 
+       fprintf(stderr, "\n       ip link xstats type TYPE [ ARGS ]\n");
+
        if (iplink_have_newlink()) {
                fprintf(stderr,
                        "\n"
@@ -1411,6 +1413,9 @@ int do_iplink(int argc, char **argv)
            matches(*argv, "list") == 0)
                return ipaddr_list_link(argc-1, argv+1);
 
+       if (matches(*argv, "xstats") == 0)
+               return iplink_ifla_xstats(argc-1, argv+1);
+
        if (matches(*argv, "help") == 0) {
                do_help(argc-1, argv+1);
                return 0;
index 651a255370e6d62f5504edfac03f1ff1f210af8b..f2e182bdaff716c1dfa652de83d462ac4f947e65 100644 (file)
@@ -168,6 +168,11 @@ ip-link \- network device configuration
 .B vrf
 .IR NAME " ]"
 
+.ti -8
+.B ip link xstats
+.BI type " TYPE"
+.RI "[ " ARGS " ]"
+
 .ti -8
 .B ip link help
 .RI "[ " TYPE " ]"
@@ -1616,6 +1621,13 @@ interface list by comparing it with the relevant attribute in case the kernel
 didn't filter already. Therefore any string is accepted, but may lead to empty
 output.
 
+.SS  ip link xstats - display extended statistics
+
+.TP
+.BI type " TYPE "
+.I TYPE
+specifies the type of devices to display extended statistics for.
+
 .SS  ip link help - display help
 
 .PP