Skip to content

Commit 7f7b267

Browse files
yousongYousong Zhou
authored andcommitted
ovs: make MatchFlow --strict aware
1 parent cb908b2 commit 7f7b267

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ovs/flow.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ func (f *Flow) MatchFlow() *MatchFlow {
339339
}
340340
}
341341

342+
// MatchFlowStrict converts Flow into a strict-matching-aware MatchFlow
343+
func (f *Flow) MatchFlowStrict() *MatchFlow {
344+
mf := f.MatchFlow()
345+
mf.Strict = true
346+
return mf
347+
}
348+
342349
// marshalActions marshals all Actions in a Flow to their text form.
343350
func (f *Flow) marshalActions() ([]string, error) {
344351
fns := make([]func() ([]byte, error), 0, len(f.Actions))

ovs/matchflow.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ var (
3737
// A MatchFlow is an OpenFlow flow intended for flow deletion. It can be marshaled to its textual
3838
// form for use with Open vSwitch.
3939
type MatchFlow struct {
40-
Protocol Protocol
40+
Strict bool
4141
InPort int
42+
Priority int
43+
Protocol Protocol
4244
Matches []Match
4345
Table int
4446

@@ -83,6 +85,11 @@ func (f *MatchFlow) MarshalText() ([]byte, error) {
8385

8486
var b []byte
8587

88+
if f.Strict {
89+
b = append(b, priority+"="...)
90+
b = strconv.AppendInt(b, int64(f.Priority), 10)
91+
b = append(b, ',')
92+
}
8693
if f.Protocol != "" {
8794
b = append(b, f.Protocol...)
8895
b = append(b, ',')

0 commit comments

Comments
 (0)