[VOL-2245]:fix to handle failure scenarios for flows without metadata
Change-Id: I77b1535c4e2e2d5e480945ace7b721a33bc5e265
diff --git a/adaptercore/openolt_flowmgr.go b/adaptercore/openolt_flowmgr.go
index f1c0639..d391616 100644
--- a/adaptercore/openolt_flowmgr.go
+++ b/adaptercore/openolt_flowmgr.go
@@ -1225,7 +1225,11 @@
gemPortID int32, flowID uint32, flowDirection string,
portNum uint32, updatedFlows []rsrcMgr.FlowInfo) error {
- tpID := getTpIDFromFlow(flow)
+ tpID, err := getTpIDFromFlow(flow)
+ if err != nil {
+ log.Error("metadata-is-not-present-invalid-flow-to-process", log.Fields{"pon": Intf, "onuID": onuID, "uniID": uniID})
+ return err
+ }
if len(updatedFlows) >= 0 {
// There are still flows referencing the same flow_id.
@@ -1432,8 +1436,11 @@
f.deviceHandler.AddUniPortToOnu(intfID, onuID, portNo)
f.resourceMgr.AddUniPortToOnuInfo(intfID, onuID, portNo)
- TpID := getTpIDFromFlow(flow)
-
+ TpID, err := getTpIDFromFlow(flow)
+ if err != nil {
+ log.Error("metadata-is-not-present-invalid-flow-to-process", log.Fields{"pon": intfID, "onuID": onuID, "uniID": uniID})
+ return
+ }
log.Debugw("TPID for this subcriber", log.Fields{"TpId": TpID, "pon": intfID, "onuID": onuID, "uniID": uniID})
if IsUpstream(actionInfo[Output].(uint32)) {
UsMeterID = flows.GetMeterIdFromFlow(flow)
@@ -1951,7 +1958,7 @@
return nil
}
-func getTpIDFromFlow(flow *ofp.OfpFlowStats) uint32 {
+func getTpIDFromFlow(flow *ofp.OfpFlowStats) (uint32, error) {
/* Metadata 8 bytes:
Most Significant 2 Bytes = Inner VLAN
Next 2 Bytes = Tech Profile ID(TPID)
@@ -1961,11 +1968,11 @@
*/
metadata := flows.GetMetadataFromWriteMetadataAction(flow)
if metadata == 0 {
- log.Error("Metadata is not present in flow which is mandatory")
- return 0
+ log.Error("metadata-is-not-present-in-flow-which-is-mandatory")
+ return 0, errors.New("metadata-is-not-present-in-flow-which-is-mandatory")
}
TpID := flows.GetTechProfileIDFromWriteMetaData(metadata)
- return uint32(TpID)
+ return uint32(TpID), nil
}
func appendUnique(slice []uint32, item uint32) []uint32 {