diff options
author | Thomas Haller <thaller@redhat.com> | 2016-08-15 23:30:45 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-08-17 16:08:21 +0200 |
commit | fc2f1d9cb87a0df904e1f7ff0aaac5d8b9d807d2 (patch) | |
tree | 18b82a3372cb00d8a3f866406ac2a308da35d922 | |
parent | 9c5405eba4a2f34383af293f9b0b0a83c6b6405f (diff) | |
download | NetworkManager-fc2f1d9cb87a0df904e1f7ff0aaac5d8b9d807d2.tar.gz |
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.
-rw-r--r-- | src/devices/nm-device-statistics.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/devices/nm-device-statistics.c b/src/devices/nm-device-statistics.c index 4c7c295c5f..12e595c941 100644 --- a/src/devices/nm-device-statistics.c +++ b/src/devices/nm-device-statistics.c @@ -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); |