- struct internal_dev *internal_dev = internal_dev_priv(netdev);
- struct net_device_stats *stats;
- int i;
-
- stats = &internal_dev->stats;
- stats->rx_bytes = internal_dev->extra_stats.rx_bytes;
- stats->rx_packets = internal_dev->extra_stats.rx_packets;
- stats->tx_bytes = internal_dev->extra_stats.tx_bytes;
- stats->tx_packets = internal_dev->extra_stats.tx_packets;
- for_each_possible_cpu(i) {
- const struct pcpu_lstats *lb_stats;
-
- lb_stats = per_cpu_ptr(internal_dev->lstats, i);
- stats->rx_bytes += lb_stats->rx_bytes;
- stats->rx_packets += lb_stats->rx_packets;
- stats->tx_bytes += lb_stats->tx_bytes;
- stats->tx_packets += lb_stats->tx_packets;
- }
+#else
+static struct net_device_stats *internal_dev_sys_stats(struct net_device *netdev)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+ struct net_device_stats *stats = &internal_dev_priv(netdev)->stats;
+#else
+ struct net_device_stats *stats = &netdev->stats;
+#endif
+#endif
+ struct vport *vport = internal_dev_get_vport(netdev);
+ struct ovs_vport_stats vport_stats;
+
+ vport_get_stats(vport, &vport_stats);
+
+ /* The tx and rx stats need to be swapped because the
+ * switch and host OS have opposite perspectives. */
+ stats->rx_packets = vport_stats.tx_packets;
+ stats->tx_packets = vport_stats.rx_packets;
+ stats->rx_bytes = vport_stats.tx_bytes;
+ stats->tx_bytes = vport_stats.rx_bytes;
+ stats->rx_errors = vport_stats.tx_errors;
+ stats->tx_errors = vport_stats.rx_errors;
+ stats->rx_dropped = vport_stats.tx_dropped;
+ stats->tx_dropped = vport_stats.rx_dropped;
+