summaryrefslogtreecommitdiff
path: root/lib/netdev-linux.c
diff options
context:
space:
mode:
authorAndy Zhou <azhou@nicira.com>2014-04-28 15:46:30 -0700
committerAndy Zhou <azhou@nicira.com>2014-05-02 18:10:46 -0700
commit04c881eb6441fff2e91c9b9e23502bc554c0f437 (patch)
treefe4bea5ecc98e55039b724eb68f45d87b0dea09d /lib/netdev-linux.c
parent41ca1e0afb4b261a217c9fdaf672ef606e8434f9 (diff)
downloadopenvswitch-04c881eb6441fff2e91c9b9e23502bc554c0f437.tar.gz
netdev-linux: favor netlink stats for physical ports
Currently physical ports stats are collected from kernel datapath. However, those counter do not reflect actual wire packet counters when GSO, TSO or GRO are enabled by the NIC. In the meantime, the stats collected form routing stack does. While both stats are valid, Reporting kernel netdev stats for packet counts and byte counts make it easier to correlate those numbers with external measurements. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netdev-linux.c')
-rw-r--r--lib/netdev-linux.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 5c7065fe1..c1d93237e 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1563,9 +1563,17 @@ netdev_linux_get_stats(const struct netdev *netdev_,
error = 0;
}
} else if (netdev->vport_stats_error) {
- /* stats not available from OVS then use ioctl stats. */
+ /* stats not available from OVS then use netdev stats. */
*stats = dev_stats;
} else {
+ /* Use kernel netdev's packet and byte counts since vport's counters
+ * do not reflect packet counts on the wire when GSO, TSO or GRO are
+ * enabled. */
+ stats->rx_packets = dev_stats.rx_packets;
+ stats->rx_bytes = dev_stats.rx_bytes;
+ stats->tx_packets = dev_stats.tx_packets;
+ stats->tx_bytes = dev_stats.tx_bytes;
+
stats->rx_errors += dev_stats.rx_errors;
stats->tx_errors += dev_stats.tx_errors;
stats->rx_dropped += dev_stats.rx_dropped;
@@ -1629,6 +1637,14 @@ netdev_tap_get_stats(const struct netdev *netdev_, struct netdev_stats *stats)
stats->tx_heartbeat_errors = 0;
stats->tx_window_errors = 0;
} else {
+ /* Use kernel netdev's packet and byte counts since vport counters
+ * do not reflect packet counts on the wire when GSO, TSO or GRO
+ * are enabled. */
+ stats->rx_packets = dev_stats.tx_packets;
+ stats->rx_bytes = dev_stats.tx_bytes;
+ stats->tx_packets = dev_stats.rx_packets;
+ stats->tx_bytes = dev_stats.rx_bytes;
+
stats->rx_dropped += dev_stats.tx_dropped;
stats->tx_dropped += dev_stats.rx_dropped;