diff options
author | Petr Machata <petrm@nvidia.com> | 2022-04-22 10:30:52 +0200 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2022-04-27 20:12:42 -0600 |
commit | 54d82b0699a07b1af32a46e229ed37331e38d3a2 (patch) | |
tree | aaa0d802215dcb6b9b3110348941431a9e6a6151 | |
parent | 5520cf1603bacdc9fdafa119e8bf4a35ad57fefc (diff) | |
download | iproute2-54d82b0699a07b1af32a46e229ed37331e38d3a2.tar.gz |
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@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r-- | ip/Makefile | 3 | ||||
-rw-r--r-- | ip/ip.c | 1 | ||||
-rw-r--r-- | ip/ip_common.h | 1 | ||||
-rw-r--r-- | ip/ipstats.c | 31 |
4 files changed, 35 insertions, 1 deletions
diff --git a/ip/Makefile b/ip/Makefile index e06a7c846..6c2e07204 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 @@ -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 51a7edc71..53866d7ac 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 000000000..099e18a21 --- /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; +} |