device: reset device-stats in update_stats() on missing link

First of all, we don't expect missing NMPlatformLink instances.
If that actually happens, just reset the counters to zero.
This commit is contained in:
Thomas Haller 2016-08-15 23:30:45 +02:00
parent 9c5405eba4
commit fc2f1d9cb8

View file

@ -49,13 +49,16 @@ update_stats (gpointer user_data)
pllink = nm_platform_link_get (NM_PLATFORM_GET, ifindex);
if (pllink) {
_LOGT ("{RX} %"PRIu64" packets %"PRIu64" bytes {TX} %"PRIu64" packets %"PRIu64" bytes",
pllink->rx_packets, pllink->rx_bytes, pllink->tx_packets, pllink->tx_bytes);
_LOGT ("ifindex %d: {RX} %"PRIu64" packets %"PRIu64" bytes {TX} %"PRIu64" packets %"PRIu64" bytes",
ifindex, pllink->rx_packets, pllink->rx_bytes, pllink->tx_packets, pllink->tx_bytes);
nm_device_set_tx_bytes (self->device, pllink->tx_bytes);
nm_device_set_rx_bytes (self->device, pllink->rx_bytes);
} else
_LOGE ("error no stats available");
} else {
_LOGT ("error no stats available for ifindex %d", ifindex);
nm_device_set_tx_bytes (self->device, 0);
nm_device_set_rx_bytes (self->device, 0);
}
/* Keep polling */
nm_platform_link_refresh (NM_PLATFORM_GET, ifindex);