From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger 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 Message-ID: <20180201153206.1e834816@xeon-e3> References: <1517514058-23596-1-git-send-email-serhe.popovych@gmail.com> <1517514058-23596-3-git-send-email-serhe.popovych@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Serhey Popovych Return-path: Received: from mail-pl0-f65.google.com ([209.85.160.65]:40313 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751450AbeBAXcJ (ORCPT ); Thu, 1 Feb 2018 18:32:09 -0500 Received: by mail-pl0-f65.google.com with SMTP id g18so4740826plo.7 for ; Thu, 01 Feb 2018 15:32:09 -0800 (PST) In-Reply-To: <1517514058-23596-3-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, 1 Feb 2018 21:40:54 +0200 Serhey Popovych 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.