From fc2f1d9cb87a0df904e1f7ff0aaac5d8b9d807d2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 15 Aug 2016 23:30:45 +0200 Subject: [PATCH] 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. --- src/devices/nm-device-statistics.c | 11 +++++++---- 1 file 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);