mbox series

[iproute2-next,00/11] ip stats: A new front-end for RTM_GETSTATS / RTM_SETSTATS

Message ID cover.1650615982.git.petrm@nvidia.com (mailing list archive)
Headers show
Series ip stats: A new front-end for RTM_GETSTATS / RTM_SETSTATS | expand

Message

Petr Machata April 22, 2022, 8:30 a.m. UTC
A new rtnetlink message, RTM_SETSTATS, has been added recently in kernel
commit ca0a53dcec94 ("Merge branch 'net-hw-counters-for-soft-devices'").

At the same time, RTM_GETSTATS has been around for a while. The users of
this API are spread in a couple different places: "ip link xstats" reads
stats from the IFLA_STATS_LINK_XSTATS and _XSTATS_SLAVE subgroups, "ip
link afstats" then reads IFLA_STATS_AF_SPEC.

Finally, to read IFLA_STATS_LINK_OFFLOAD_XSTATS, one would use ifstats.
This does not seem to be a good fit for IFLA_OFFLOAD_XSTATS_HW_S_INFO in
particular.

The obvious place to expose all these offload stats suites would be
under a new link subcommand "ip link offload_xstats", or similar, which
would then have syntax for both showing stats and setting them.

However, this looks like a good opportunity to introduce a new top-level
command, "ip stats", that would be the go-to place to access anything
backed by RTM_GETSTATS and RTM_SETSTATS.

This patchset therefore does the following:

- It adds the new "stats" infrastructure

- It adds specifically the ability to toggle and show the suites that
  were recently added to Linux, IFLA_OFFLOAD_XSTATS_HW_S_INFO and
  IFLA_OFFLOAD_XSTATS_L3_STATS.

- It adds support to dump IFLA_OFFLOAD_XSTATS_CPU_HIT, which was not
  available under "ip" at all.

- Does all this in a way that is easy to extend for new stats suites.

The patchset proceeds as follows:

- Patches #1 and #2 lay some groundwork and tweak existing code.

- Patch #3 adds the shell of the new "ip stats" command.

- Patch #4 adds "ip stats set" and the ability to toggle l3_stats in
  particular.

- Patch #5 adds "ip stats show", but no actual stats suites.

- Patches #6-#9 add support for showing individual stats suites:
  respectively, IFLA_STATS_LINK_64, IFLA_OFFLOAD_XSTATS_CPU_HIT,
  IFLA_OFFLOAD_XSTATS_HW_S_INFO and IFLA_OFFLOAD_XSTATS_L3_STATS.

- Patch #10 adds support for monitoring stats events to "ip monitor".

- Patch #11 adds man page verbiage for the above.

The plan is to contribute support for afstats and xstats in a follow-up
patch set.

Petr Machata (11):
  libnetlink: Add filtering to rtnl_statsdump_req_filter()
  ip: Publish functions for stats formatting
  ip: Add a new family of commands, "stats"
  ipstats: Add a "set" command
  ipstats: Add a shell of "show" command
  ipstats: Add a group "link"
  ipstats: Add a group "offload", subgroup "cpu_hit"
  ipstats: Add offload subgroup "hw_stats_info"
  ipstats: Add offload subgroup "l3_stats"
  ipmonitor: Add monitoring support for stats events
  man: Add man pages for the "stats" functions

 bridge/vlan.c         |    6 +-
 include/libnetlink.h  |   11 +-
 ip/Makefile           |    3 +-
 ip/ip.c               |    1 +
 ip/ip_common.h        |   31 +
 ip/ipaddress.c        |   33 +-
 ip/iplink.c           |    3 +-
 ip/iplink_xstats.c    |    3 +-
 ip/ipmonitor.c        |   16 +-
 ip/ipstats.c          | 1241 +++++++++++++++++++++++++++++++++++++++++
 lib/libnetlink.c      |   19 +-
 man/man8/ip-monitor.8 |    2 +-
 man/man8/ip-stats.8   |  160 ++++++
 man/man8/ip.8         |    7 +-
 misc/ifstat.c         |    2 +-
 15 files changed, 1512 insertions(+), 26 deletions(-)
 create mode 100644 ip/ipstats.c
 create mode 100644 man/man8/ip-stats.8

Comments

patchwork-bot+netdevbpf@kernel.org April 28, 2022, 2:20 a.m. UTC | #1
Hello:

This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Fri, 22 Apr 2022 10:30:49 +0200 you wrote:
> A new rtnetlink message, RTM_SETSTATS, has been added recently in kernel
> commit ca0a53dcec94 ("Merge branch 'net-hw-counters-for-soft-devices'").
> 
> At the same time, RTM_GETSTATS has been around for a while. The users of
> this API are spread in a couple different places: "ip link xstats" reads
> stats from the IFLA_STATS_LINK_XSTATS and _XSTATS_SLAVE subgroups, "ip
> link afstats" then reads IFLA_STATS_AF_SPEC.
> 
> [...]

Here is the summary with links:
  - [iproute2-next,01/11] libnetlink: Add filtering to rtnl_statsdump_req_filter()
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=a463d6b19107
  - [iproute2-next,02/11] ip: Publish functions for stats formatting
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=5520cf1603ba
  - [iproute2-next,03/11] ip: Add a new family of commands, "stats"
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=54d82b0699a0
  - [iproute2-next,04/11] ipstats: Add a "set" command
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=82f6444f83c7
  - [iproute2-next,05/11] ipstats: Add a shell of "show" command
    (no matching commit)
  - [iproute2-next,06/11] ipstats: Add a group "link"
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=0517a2fd66ae
  - [iproute2-next,07/11] ipstats: Add a group "offload", subgroup "cpu_hit"
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=af5e7955273e
  - [iproute2-next,08/11] ipstats: Add offload subgroup "hw_stats_info"
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=179030fa6bc7
  - [iproute2-next,09/11] ipstats: Add offload subgroup "l3_stats"
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=0f1fd40cc9e8
  - [iproute2-next,10/11] ipmonitor: Add monitoring support for stats events
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=a05a27c07cbf
  - [iproute2-next,11/11] man: Add man pages for the "stats" functions
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=b28eb051b321

You are awesome, thank you!