diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-04-16 15:13:18 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-04-16 15:13:18 +0200 |
commit | e24215b47ad5cd6599973c3a76a375b99ad75d44 (patch) | |
tree | 773af3a27691137635132b5a9953458d36306bc1 /core | |
parent | df1b888a2bfadefadc7dbfce59d34f811ff002ec (diff) |
Fix crash in stats for removed interfaces/nodes
Change-Id: I36b4cd2625c7f0c5846fe402be7b2aeece4707f8
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/stats.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/stats.go b/core/stats.go index 4cbd9f2..48b516c 100644 --- a/core/stats.go +++ b/core/stats.go @@ -196,6 +196,9 @@ func (c *StatsConnection) GetNodeStats() (*api.NodeStats, error) { } } for i, v := range perNode { + if len(nodeStats.Nodes) <= i { + break + } nodeCounters := nodeStats.Nodes[i] fn(&nodeCounters, v) nodeStats.Nodes[i] = nodeCounters @@ -257,6 +260,9 @@ func (c *StatsConnection) GetInterfaceStats() (*api.InterfaceStats, error) { } } for i, v := range perIf { + if len(ifStats.Interfaces) <= i { + break + } ifCounters := ifStats.Interfaces[i] fn(&ifCounters, v) ifStats.Interfaces[i] = ifCounters |