From: Ido Schimmel <idosch@idosch.org>
To: Petr Machata <petrm@nvidia.com>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH iproute2-next 06/11] ipstats: Add a group "link"
Date: Sun, 1 May 2022 17:52:03 +0300 [thread overview]
Message-ID: <Ym6ek66a6kMH3ZEu@shredder> (raw)
In-Reply-To: <c361fce0960093e31aabbc0b45bb0c870896339e.1650615982.git.petrm@nvidia.com>
On Fri, Apr 22, 2022 at 10:30:55AM +0200, Petr Machata wrote:
> +#define IPSTATS_RTA_PAYLOAD(TYPE, AT) \
> + ({ \
> + const struct rtattr *__at = (AT); \
> + TYPE *__ret = NULL; \
> + \
> + if (__at != NULL && \
> + __at->rta_len - RTA_LENGTH(0) >= sizeof(TYPE)) \
> + __ret = RTA_DATA(__at); \
> + __ret; \
> + })
> +
> +static int ipstats_show_64(struct ipstats_stat_show_attrs *attrs,
> + unsigned int group, unsigned int subgroup)
> +{
> + struct rtnl_link_stats64 *stats;
> + const struct rtattr *at;
> + int err;
> +
> + at = ipstats_stat_show_get_attr(attrs, group, subgroup, &err);
> + if (at == NULL)
> + return err;
> +
> + stats = IPSTATS_RTA_PAYLOAD(struct rtnl_link_stats64, at);
> + if (stats == NULL) {
> + fprintf(stderr, "Error: attribute payload too short");
When I tested this on 5.15 / 5.16 everything was fine, but now I get:
$ ip stats show dev lo group link
1: lo: group link
Error: attribute payload too short
Payload on 5.16:
recvmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=224, nlmsg_type=RTM_NEWSTATS, nlmsg_flags=0, nlmsg_seq=1651407379, nlmsg_pid=330213}, {family=AF_UNSPEC, ifindex=if_nametoindex("lo"), filter_mask=1<<IFLA_STATS_UNSPEC}, [{nla_len=196, nla_type=IFLA_STATS_LINK_64}, {rx_packets=321113, tx_packets=321113, rx_bytes=322735996, tx_bytes=322735996, rx_errors=0, tx_errors=0, rx_dropped=0, tx_dropped=0, multicast=0, collisions=0, rx_length_errors=0, rx_over_errors=0, rx_crc_errors=0, rx_frame_errors=0, rx_fifo_errors=0, rx_missed_errors=0, tx_aborted_errors=0, tx_carrier_errors=0, tx_fifo_errors=0, tx_heartbeat_errors=0, tx_window_errors=0, rx_compressed=0, tx_compressed=0, rx_nohandler=0}]], iov_len=32768}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 224
1: lo: group link
Error: attribute payload too short+++ exited with 22 +++
Payload on net-next:
recvmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=232, nlmsg_type=RTM_NEWSTATS, nlmsg_flags=0, nlmsg_seq=1651407411, nlmsg_pid=198}, {family=AF_UNSPEC, ifindex=if_nametoindex("lo"), filter_mask=1<<IFLA_STATS_UNSPEC}, [{nla_len=204, nla_type=IFLA_STATS_LINK_64}, {rx_packets=0, tx_packets=0, rx_bytes=0, tx_bytes=0, rx_errors=0, tx_errors=0, rx_dropped=0, tx_dropped=0, multicast=0, collisions=0, rx_length_errors=0, rx_over_errors=0, rx_crc_errors=0, rx_frame_errors=0, rx_fifo_errors=0, rx_missed_errors=0, tx_aborted_errors=0, tx_carrier_errors=0, tx_fifo_errors=0, tx_heartbeat_errors=0, tx_window_errors=0, rx_compressed=0, tx_compressed=0, rx_nohandler=0}]], iov_len=32768}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 232
1: lo: group link
RX: bytes packets errors dropped missed mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
+++ exited with 0 +++
Note the difference in size of IFLA_STATS_LINK_64 which carries struct
rtnl_link_stats64: 196 bytes vs. 204 bytes
The 8 byte difference is most likely from the addition of
rx_otherhost_dropped at the end:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=794c24e9921f32ded4422833a990ccf11dc3c00e
I guess it worked for me because I didn't have this member in my copy of
the uAPI file, but it's now in iproute2-next:
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=bba95837524d09ee2f0efdf6350b83a985f4b2f8
I was under the impression that such a size increase in a uAPI struct is
forbidden, which is why we usually avoid passing structs over netlink.
> + return -EINVAL;
> + }
> +
> + open_json_object("stats64");
> + print_stats64(stdout, stats, NULL, NULL);
> + close_json_object();
> + return 0;
> +}
next prev parent reply other threads:[~2022-05-01 14:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 8:30 [PATCH iproute2-next 00/11] ip stats: A new front-end for RTM_GETSTATS / RTM_SETSTATS Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 01/11] libnetlink: Add filtering to rtnl_statsdump_req_filter() Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 02/11] ip: Publish functions for stats formatting Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 03/11] ip: Add a new family of commands, "stats" Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 04/11] ipstats: Add a "set" command Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 05/11] ipstats: Add a shell of "show" command Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 06/11] ipstats: Add a group "link" Petr Machata
2022-05-01 14:52 ` Ido Schimmel [this message]
2022-05-02 4:56 ` David Ahern
2022-05-02 6:19 ` Ido Schimmel
2022-05-02 9:37 ` Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 07/11] ipstats: Add a group "offload", subgroup "cpu_hit" Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 08/11] ipstats: Add offload subgroup "hw_stats_info" Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 09/11] ipstats: Add offload subgroup "l3_stats" Petr Machata
2022-04-22 8:30 ` [PATCH iproute2-next 10/11] ipmonitor: Add monitoring support for stats events Petr Machata
2022-04-22 8:31 ` [PATCH iproute2-next 11/11] man: Add man pages for the "stats" functions Petr Machata
2022-04-28 2:20 ` [PATCH iproute2-next 00/11] ip stats: A new front-end for RTM_GETSTATS / RTM_SETSTATS patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ym6ek66a6kMH3ZEu@shredder \
--to=idosch@idosch.org \
--cc=dsahern@gmail.com \
--cc=idosch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox