From: Stephen Hemminger <stephen@networkplumber.org>
To: Serhey Popovych <serhe.popovych@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC][PATCH iproute2-next 2/6] ip: Introduce get_rtnl_link_stats_rta() to get link statistics
Date: Thu, 1 Feb 2018 15:32:06 -0800 [thread overview]
Message-ID: <20180201153206.1e834816@xeon-e3> (raw)
In-Reply-To: <1517514058-23596-3-git-send-email-serhe.popovych@gmail.com>
On Thu, 1 Feb 2018 21:40:54 +0200
Serhey Popovych <serhe.popovych@gmail.com> wrote:
> +/* Based on copy_rtnl_link_stats() from kernel at net/core/rtnetlink.c */
> +static void copy_rtnl_link_stats64(struct rtnl_link_stats64 *a,
> + const struct rtnl_link_stats *b)
> +{
> + a->rx_packets = b->rx_packets;
> + a->tx_packets = b->tx_packets;
> + a->rx_bytes = b->rx_bytes;
> + a->tx_bytes = b->tx_bytes;
> + a->rx_errors = b->rx_errors;
> + a->tx_errors = b->tx_errors;
> + a->rx_dropped = b->rx_dropped;
> + a->tx_dropped = b->tx_dropped;
> +
> + a->multicast = b->multicast;
> + a->collisions = b->collisions;
> +
> + a->rx_length_errors = b->rx_length_errors;
> + a->rx_over_errors = b->rx_over_errors;
> + a->rx_crc_errors = b->rx_crc_errors;
> + a->rx_frame_errors = b->rx_frame_errors;
> + a->rx_fifo_errors = b->rx_fifo_errors;
> + a->rx_missed_errors = b->rx_missed_errors;
> +
> + a->tx_aborted_errors = b->tx_aborted_errors;
> + a->tx_carrier_errors = b->tx_carrier_errors;
> + a->tx_fifo_errors = b->tx_fifo_errors;
> + a->tx_heartbeat_errors = b->tx_heartbeat_errors;
> + a->tx_window_errors = b->tx_window_errors;
> +
> + a->rx_compressed = b->rx_compressed;
> + a->tx_compressed = b->tx_compressed;
> +
> + a->rx_nohandler = b->rx_nohandler;
> +}
You could treat the two structures as arrays since all values are same size.
This avoids any possible skipping of values.
next prev parent reply other threads:[~2018-02-01 23:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 19:40 [RFC][PATCH iproute2-next 0/6] ip: Use netlink to walk through network device list Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 1/6] ipaddress: Unify print_link_stats() and print_link_stats64() Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 2/6] ip: Introduce get_rtnl_link_stats_rta() to get link statistics Serhey Popovych
2018-02-01 23:32 ` Stephen Hemminger [this message]
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 3/6] tunnel: Split statistic getting and printing Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 4/6] iptunnel/ip6tunnel: Code cleanups Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 5/6] iptunnel/ip6tunnel: Use netlink to walk through tunnels list Serhey Popovych
2018-02-01 19:40 ` [RFC][PATCH iproute2-next 6/6] tuntap: Use netlink to walk through tuntap list Serhey Popovych
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=20180201153206.1e834816@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=netdev@vger.kernel.org \
--cc=serhe.popovych@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).