[VOL-3022] Fix core crash on flow revert without meters
Change-Id: Ia0af44f5c9a810c8b8ca1931f5f577bcf521be03
diff --git a/rw_core/core/device/logical_agent.go b/rw_core/core/device/logical_agent.go
index 6a977b1..dd40863 100644
--- a/rw_core/core/device/logical_agent.go
+++ b/rw_core/core/device/logical_agent.go
@@ -984,11 +984,13 @@
}
lDevice.Flows = &ofp.Flows{Items: clonedFlows}
- // Revert meters
- meters := cloneMeters(lDevice.Meters.Items)
- changedMeterStats := agent.updateFlowCountOfMeterStats(mod, meters, addedFlow, true)
- if changedMeterStats {
- lDevice.Meters = &ofp.Meters{Items: meters}
+ // Revert meters, if necessary
+ if lDevice.Meters != nil && len(lDevice.Meters.Items) > 0 {
+ meters := cloneMeters(lDevice.Meters.Items)
+ changedMeterStats := agent.updateFlowCountOfMeterStats(mod, meters, addedFlow, true)
+ if changedMeterStats {
+ lDevice.Meters = &ofp.Meters{Items: meters}
+ }
}
// Update the model