Skip to content

ip stats: A new front-end for RTM_GETSTATS / RTM_SETSTATS

Petr Machata netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11libnetlink: Add filtering to rtnl_statsdump_req_filter()bridge/vlan.c include/libnetlink.h ip/iplink.c +3 more+33 -110 replies
2/11ip: Publish functions for stats formattingip/ip_common.h ip/ipaddress.c+25 -110 replies
3/11ip: Add a new family of commands, "stats"ip/Makefile ip/ip.c ip/ip_common.h +1 more+35 -10 replies
4/11ipstats: Add a "set" commandip/ipstats.c+78 -00 replies
5/11ipstats: Add a shell of "show" commandip/ip_common.h ip/ipstats.c+638 -20 replies
6/11ipstats: Add a group "link"ip/ipstats.c+90 -04 replies
7/11ipstats: Add a group "offload", subgroup "cpu_hit"ip/ipstats.c+37 -00 replies
8/11ipstats: Add offload subgroup "hw_stats_info"ip/ipstats.c+217 -00 replies
9/11ipstats: Add offload subgroup "l3_stats"ip/ipstats.c+158 -00 replies
10/11ipmonitor: Add monitoring support for stats eventsip/ip_common.h ip/ipmonitor.c ip/ipstats.c+36 -10 replies
11/11man: Add man pages for the "stats" functionsman/man8/ip-monitor.8 man/man8/ip-stats.8 man/man8/ip.8+167 -20 replies

Reviews trailers per patch

All 11 patches have a Reviewed-by or Acked-by.

PatchIdo Schimmel
1/11R-b
2/11R-b
3/11R-b
4/11R-b
5/11R-b
6/11R-b
7/11R-b
8/11R-b
9/11R-b
10/11R-b
11/11R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

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

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
Signature · 1 line
2.31.1