Skip to content

Commit 267c255

Browse files
author
Nicolas Bouliane
committed
ovs: fix ct_state parsing when only one flag is specified
1 parent 9ca022d commit 267c255

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ovs/matchparser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ func parseCTState(value string) (Match, error) {
257257
value = strings.ReplaceAll(value, "-", " -")
258258
value = strings.Trim(value, " ")
259259
} else {
260-
// There are only two valid format for ct_state:
261-
// `ct_state=+est+trk` and `ct_state=est|trk`
262-
return nil, errors.New("ct_state format is invalid")
260+
// Assume only one state is specified: "ct_state=trk"
261+
// "trk" => "+trk"
262+
value = "+" + value
263263
}
264264

265265
states := strings.Fields(value)

ovs/matchparser_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ func Test_parseMatch(t *testing.T) {
7373
UnsetState(CTStateNew),
7474
),
7575
},
76+
{
77+
s: "ct_state=trk",
78+
m: ConnectionTrackingState("+trk"),
79+
skipMarshal: true,
80+
},
7681
{
7782
s: "ct_state=est|trk",
7883
m: ConnectionTrackingState("+est", "+trk"),

0 commit comments

Comments
 (0)