]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: Add a new family of commands, "stats"
authorPetr Machata <petrm@nvidia.com>
Fri, 22 Apr 2022 08:30:52 +0000 (10:30 +0200)
committerDavid Ahern <dsahern@kernel.org>
Thu, 28 Apr 2022 02:12:42 +0000 (20:12 -0600)
Add a core of a new frontend tool for interfacing with the RTM_*STATS
family of messages. The following patches will add subcommands for showing
and setting individual statistics suites.

Note that in this patch, "ip stats" is made to be an invalid command line.
This will be changed in later patches to default to "show" when that is
introduced.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/Makefile
ip/ip.c
ip/ip_common.h
ip/ipstats.c [new file with mode: 0644]

index e06a7c8460d43aa9e21a0c97a7462f1311c6cc5b..6c2e072049a2af9b49f54e38332b03c13ea27611 100644 (file)
@@ -12,7 +12,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
     iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
     ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \
     ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o ipioam6.o \
-    iplink_amt.o iplink_batadv.o iplink_gtp.o iplink_virt_wifi.o
+    iplink_amt.o iplink_batadv.o iplink_gtp.o iplink_virt_wifi.o \
+    ipstats.o
 
 RTMONOBJ=rtmon.o
 
diff --git a/ip/ip.c b/ip/ip.c
index c784f8191f795b8c25f570d15cfc1d6ba47cde69..82282babdcdb91bf7c15bbdbed5bcf6305224dff 100644 (file)
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -123,6 +123,7 @@ static const struct cmd {
        { "mptcp",      do_mptcp },
        { "ioam",       do_ioam6 },
        { "help",       do_help },
+       { "stats",      do_ipstats },
        { 0 }
 };
 
index 51a7edc71e150013f022f2a31111088c981badef..53866d7ac76f4c6d949b43af006d25ddfa27ca5b 100644 (file)
@@ -90,6 +90,7 @@ int do_seg6(int argc, char **argv);
 int do_ipnh(int argc, char **argv);
 int do_mptcp(int argc, char **argv);
 int do_ioam6(int argc, char **argv);
+int do_ipstats(int argc, char **argv);
 
 int iplink_get(char *name, __u32 filt_mask);
 int iplink_ifla_xstats(int argc, char **argv);
diff --git a/ip/ipstats.c b/ip/ipstats.c
new file mode 100644 (file)
index 0000000..099e18a
--- /dev/null
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include "utils.h"
+#include "ip_common.h"
+
+static int do_help(void)
+{
+       fprintf(stderr,
+               "Usage: ip stats help\n"
+               );
+
+       return 0;
+}
+
+int do_ipstats(int argc, char **argv)
+{
+       int rc;
+
+       if (argc == 0) {
+               do_help();
+               rc = -1;
+       } else if (strcmp(*argv, "help") == 0) {
+               do_help();
+               rc = 0;
+       } else {
+               fprintf(stderr, "Command \"%s\" is unknown, try \"ip stats help\".\n",
+                       *argv);
+               rc = -1;
+       }
+
+       return rc;
+}