bugfixing [VOL-3713], [VOL-3706], [VOL-3683]: uniVlanConfig related processing corrections
Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: Ic520c517efd8d6738a8eac2b797686f0be63d80e
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 5ad398f..b0908f0 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -162,8 +162,8 @@
//metrics *pmmetrics.PmMetrics
stopCollector chan bool
stopHeartbeatCheck chan bool
- activePorts sync.Map
uniEntityMap map[uint32]*onuUniPort
+ lockVlanConfig sync.Mutex
UniVlanConfigFsmMap map[uint8]*UniVlanConfigFsm
reconciling bool
ReadyForSpecificOmciConfig bool
@@ -187,9 +187,9 @@
dh.stopCollector = make(chan bool, 2)
dh.stopHeartbeatCheck = make(chan bool, 2)
//dh.metrics = pmmetrics.NewPmMetrics(cloned.Id, pmmetrics.Frequency(150), pmmetrics.FrequencyOverride(false), pmmetrics.Grouped(false), pmmetrics.Metrics(pmNames))
- dh.activePorts = sync.Map{}
//TODO initialize the support classes.
dh.uniEntityMap = make(map[uint32]*onuUniPort)
+ dh.lockVlanConfig = sync.Mutex{}
dh.UniVlanConfigFsmMap = make(map[uint8]*UniVlanConfigFsm)
dh.reconciling = false
dh.ReadyForSpecificOmciConfig = false
@@ -2196,6 +2196,11 @@
}
logger.Debugw(ctx, "flow-add vlan-set", log.Fields{"device-id": dh.deviceID})
}
+
+ //mutex protection as the update_flow rpc maybe running concurrently for different flows, perhaps also activities
+ dh.lockVlanConfig.Lock()
+ defer dh.lockVlanConfig.Unlock()
+ logger.Debugw(ctx, "flow-add got lock", log.Fields{"device-id": dh.deviceID})
if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
return dh.UniVlanConfigFsmMap[apUniPort.uniID].SetUniFlowParams(ctx, loTpID, loCookieSlice,
loMatchVlan, loSetVlan, loSetPcp)
@@ -2233,6 +2238,9 @@
} //for all OfbFields
*/
+ //mutex protection as the update_flow rpc maybe running concurrently for different flows, perhaps also activities
+ dh.lockVlanConfig.Lock()
+ defer dh.lockVlanConfig.Unlock()
if _, exist := dh.UniVlanConfigFsmMap[apUniPort.uniID]; exist {
return dh.UniVlanConfigFsmMap[apUniPort.uniID].RemoveUniFlowParams(ctx, loCookie)
}
@@ -2246,6 +2254,7 @@
}
// createVlanFilterFsm initializes and runs the VlanFilter FSM to transfer OMCI related VLAN config
+// if this function is called from possibly concurrent processes it must be mutex-protected from the caller!
func (dh *deviceHandler) createVlanFilterFsm(ctx context.Context, apUniPort *onuUniPort, aTpID uint8, aCookieSlice []uint64,
aMatchVlan uint16, aSetVlan uint16, aSetPcp uint8, aDevEvent OnuDeviceEvent) error {
chVlanFilterFsm := make(chan Message, 2048)