[VOL-2774] Allow not filtering the pbit values for the TT workflow
Change-Id: I64b991143b7654807af10359ba67fab0af7b76a1
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index f61c1f8..3ed7441 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -506,7 +506,7 @@
func (RsrcMgr *OpenOltResourceMgr) GetFlowID(ctx context.Context, ponIntfID uint32, ONUID int32, uniID int32,
gemportID uint32,
flowStoreCookie uint64,
- flowCategory string, vlanPcp ...uint32) (uint32, error) {
+ flowCategory string, vlanVid uint32, vlanPcp ...uint32) (uint32, error) {
var err error
FlowPath := fmt.Sprintf("%d,%d,%d", ponIntfID, ONUID, uniID)
@@ -519,8 +519,10 @@
logger.Debugw("Found flowId(s) for this ONU", log.Fields{"pon": ponIntfID, "ONUID": ONUID, "uniID": uniID, "KVpath": FlowPath})
for _, flowID := range FlowIDs {
FlowInfo := RsrcMgr.GetFlowIDInfo(ctx, ponIntfID, int32(ONUID), int32(uniID), uint32(flowID))
- er := getFlowIDFromFlowInfo(FlowInfo, flowID, gemportID, flowStoreCookie, flowCategory, vlanPcp...)
+ er := getFlowIDFromFlowInfo(FlowInfo, flowID, gemportID, flowStoreCookie, flowCategory, vlanVid, vlanPcp...)
if er == nil {
+ log.Debugw("Found flowid for the vlan, pcp, and gem",
+ log.Fields{"flowID": flowID, "vlanVid": vlanVid, "vlanPcp": vlanPcp, "gemPortID": gemportID})
return flowID, er
}
}
@@ -1017,14 +1019,16 @@
return nil
}
-func getFlowIDFromFlowInfo(FlowInfo *[]FlowInfo, flowID, gemportID uint32, flowStoreCookie uint64, flowCategory string, vlanPcp ...uint32) error {
+func getFlowIDFromFlowInfo(FlowInfo *[]FlowInfo, flowID, gemportID uint32, flowStoreCookie uint64, flowCategory string,
+ vlanVid uint32, vlanPcp ...uint32) error {
if FlowInfo != nil {
for _, Info := range *FlowInfo {
if int32(gemportID) == Info.Flow.GemportId && flowCategory != "" && Info.FlowCategory == flowCategory {
logger.Debug("Found flow matching with flow category", log.Fields{"flowId": flowID, "FlowCategory": flowCategory})
- if Info.FlowCategory == "HSIA_FLOW" && Info.Flow.Classifier.OPbits == vlanPcp[0] {
- logger.Debug("Found matching vlan pcp ", log.Fields{"flowId": flowID, "Vlanpcp": vlanPcp[0]})
- return nil
+ if Info.FlowCategory == "HSIA_FLOW" {
+ if err := checkVlanAndPbitEqualityForFlows(vlanVid, Info, vlanPcp[0]); err == nil {
+ return nil
+ }
}
}
if int32(gemportID) == Info.Flow.GemportId && flowStoreCookie != 0 && Info.FlowStoreCookie == flowStoreCookie {
@@ -1039,6 +1043,33 @@
return errors.New("invalid flow-info")
}
+func checkVlanAndPbitEqualityForFlows(vlanVid uint32, Info FlowInfo, vlanPcp uint32) error {
+ if err := checkVlanEqualityForFlows(vlanVid, Info); err != nil {
+ return err
+ }
+
+ //flow has remark action and pbits
+ if Info.Flow.Action.Cmd.RemarkInnerPbits || Info.Flow.Action.Cmd.RemarkOuterPbits {
+ if vlanPcp == Info.Flow.Action.OPbits || vlanPcp == Info.Flow.Action.IPbits {
+ return nil
+ }
+ } else if vlanPcp == Info.Flow.Classifier.OPbits {
+ //no remark action but flow has pbits
+ return nil
+ } else if vlanPcp == 0xff || Info.Flow.Classifier.OPbits == 0xff {
+ // no pbit found
+ return nil
+ }
+ return errors.New("not found in terms of pbit equality")
+}
+
+func checkVlanEqualityForFlows(vlanVid uint32, Info FlowInfo) error {
+ if vlanVid == Info.Flow.Action.OVid || vlanVid == Info.Flow.Classifier.IVid {
+ return nil
+ }
+ return errors.New("not found in terms of vlan_id equality")
+}
+
//AddGemToOnuGemInfo adds gemport to onugem info kvstore
func (RsrcMgr *OpenOltResourceMgr) AddGemToOnuGemInfo(ctx context.Context, intfID uint32, onuID uint32, gemPort uint32) error {
var onuGemData []OnuGemInfo
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index 4786940..18074cc 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -528,6 +528,7 @@
gemportID uint32
flowStoreCookie uint64
flowCategory string
+ vlanVid uint32
vlanPcp []uint32
}
tests := []struct {
@@ -538,14 +539,14 @@
wantErr error
}{
{"GetFlowID-1", getResMgr(), args{1, 2, 2, 2, 2,
- "HSIA", nil}, 0, errors.New("failed to get flows")},
+ "HSIA", 33, nil}, 0, errors.New("failed to get flows")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RsrcMgr := testResMgrObject(tt.fields)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- got, err := RsrcMgr.GetFlowID(ctx, tt.args.ponIntfID, tt.args.ONUID, tt.args.uniID, tt.args.gemportID, tt.args.flowStoreCookie, tt.args.flowCategory, tt.args.vlanPcp...)
+ got, err := RsrcMgr.GetFlowID(ctx, tt.args.ponIntfID, tt.args.ONUID, tt.args.uniID, tt.args.gemportID, tt.args.flowStoreCookie, tt.args.flowCategory, tt.args.vlanVid, tt.args.vlanPcp...)
if err != nil && reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) {
t.Errorf("GetFlowID() error = %v, wantErr %v", err, tt.wantErr)
return
@@ -969,6 +970,7 @@
gemportID uint32
flowStoreCookie uint64
flowCategory string
+ vlanVid uint32
vlanPcp []uint32
}
flowInfo := &[]FlowInfo{
@@ -978,7 +980,15 @@
GemportId: 1,
Classifier: &openolt.Classifier{
OPbits: 1,
- }},
+ OVid: 33,
+ },
+ Action: &openolt.Action{
+ Cmd: &openolt.ActionCmd{
+ AddOuterTag: true,
+ },
+ OVid: 7,
+ },
+ },
1,
"HSIA_FLOW",
2000,
@@ -986,6 +996,14 @@
{
&openolt.Flow{
GemportId: 1,
+ Classifier: &openolt.Classifier{
+ OVid: 0,
+ },
+ Action: &openolt.Action{
+ Cmd: &openolt.ActionCmd{
+ TrapToHost: true,
+ },
+ },
},
1,
"EAPOL",
@@ -999,13 +1017,13 @@
}{
{"getFlowIdFromFlowInfo-1", args{}, errors.New("invalid flow-info")},
{"getFlowIdFromFlowInfo-2", args{flowInfo, 1, 1, 1,
- "HSIA_FLOW", []uint32{1, 2}}, errors.New("invalid flow-info")},
+ "HSIA_FLOW", 33, []uint32{1, 2}}, errors.New("invalid flow-info")},
{"getFlowIdFromFlowInfo-2", args{flowInfo, 1, 1, 1,
- "EAPOL", []uint32{1, 2}}, errors.New("invalid flow-info")},
+ "EAPOL", 33, []uint32{1, 2}}, errors.New("invalid flow-info")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- err := getFlowIDFromFlowInfo(tt.args.FlowInfo, tt.args.flowID, tt.args.gemportID, tt.args.flowStoreCookie, tt.args.flowCategory, tt.args.vlanPcp...)
+ err := getFlowIDFromFlowInfo(tt.args.FlowInfo, tt.args.flowID, tt.args.gemportID, tt.args.flowStoreCookie, tt.args.flowCategory, tt.args.vlanVid, tt.args.vlanPcp...)
if reflect.TypeOf(err) != reflect.TypeOf(tt.wantErr) && err != nil {
t.Errorf("getFlowIDFromFlowInfo() error = %v, wantErr %v", err, tt.wantErr)
}