[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe2cbab58f3114095afdc0780dee75a8b8156529.1650615982.git.petrm@nvidia.com>
Date: Fri, 22 Apr 2022 10:30:52 +0200
From: Petr Machata <petrm@...dia.com>
To: <netdev@...r.kernel.org>
CC: David Ahern <dsahern@...il.com>,
Stephen Hemminger <stephen@...workplumber.org>,
Ido Schimmel <idosch@...dia.com>,
Petr Machata <petrm@...dia.com>
Subject: [PATCH iproute2-next 03/11] ip: Add a new family of commands, "stats"
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@...dia.com>
Reviewed-by: Ido Schimmel <idosch@...dia.com>
---
ip/Makefile | 3 ++-
ip/ip.c | 1 +
ip/ip_common.h | 1 +
ip/ipstats.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 ip/ipstats.c
diff --git a/ip/Makefile b/ip/Makefile
index e06a7c84..6c2e0720 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -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 c784f819..82282bab 100644
--- 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 }
};
diff --git a/ip/ip_common.h b/ip/ip_common.h
index 51a7edc7..53866d7a 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -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
index 00000000..099e18a2
--- /dev/null
+++ b/ip/ipstats.c
@@ -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;
+}
--
2.31.1
Powered by blists - more mailing lists