File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,14 @@ func (f *Flow) MatchFlow() *MatchFlow {
437
437
}
438
438
}
439
439
440
+ // MatchFlowStrict converts Flow into a strict-matching-aware MatchFlow
441
+ func (f * Flow ) MatchFlowStrict () * MatchFlow {
442
+ mf := f .MatchFlow ()
443
+ mf .Priority = f .Priority
444
+ mf .Strict = true
445
+ return mf
446
+ }
447
+
440
448
// marshalActions marshals all provided Actions to their text form.
441
449
func marshalActions (aa []Action ) ([]string , error ) {
442
450
fns := make ([]func () ([]byte , error ), 0 , len (aa ))
Original file line number Diff line number Diff line change @@ -1203,6 +1203,18 @@ func TestFlowMatchFlow(t *testing.T) {
1203
1203
}
1204
1204
})
1205
1205
}
1206
+ for _ , tt := range tests {
1207
+ t .Run (tt .desc , func (t * testing.T ) {
1208
+ want , got := tt .m , tt .f .MatchFlowStrict ()
1209
+ wantStrict := & (* want )
1210
+ wantStrict .Strict = true
1211
+ wantStrict .Priority = tt .f .Priority
1212
+ if ! reflect .DeepEqual (wantStrict , got ) {
1213
+ t .Fatalf ("unexpected MatchFlowStrict:\n - want: %#v\n - got: %#v" ,
1214
+ wantStrict , got )
1215
+ }
1216
+ })
1217
+ }
1206
1218
}
1207
1219
1208
1220
// flowsEqual determines if two possible Flows are equal.
Original file line number Diff line number Diff line change 37
37
// A MatchFlow is an OpenFlow flow intended for flow deletion. It can be marshaled to its textual
38
38
// form for use with Open vSwitch.
39
39
type MatchFlow struct {
40
- Protocol Protocol
40
+ Strict bool
41
41
InPort int
42
+ Priority int
43
+ Protocol Protocol
42
44
Matches []Match
43
45
Table int
44
46
@@ -83,6 +85,11 @@ func (f *MatchFlow) MarshalText() ([]byte, error) {
83
85
84
86
var b []byte
85
87
88
+ if f .Strict {
89
+ b = append (b , priority + "=" ... )
90
+ b = strconv .AppendInt (b , int64 (f .Priority ), 10 )
91
+ b = append (b , ',' )
92
+ }
86
93
if f .Protocol != "" {
87
94
b = append (b , f .Protocol ... )
88
95
b = append (b , ',' )
You can’t perform that action at this time.
0 commit comments