Skip to content

Commit 953ccd8

Browse files
author
Nicolas Bouliane
committed
change default behavior of parseMatch to skip unknown tokens
1 parent b94211b commit 953ccd8

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

ovs/flow.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,11 @@ func (f *Flow) UnmarshalText(b []byte) error {
394394
if err != nil {
395395
return err
396396
}
397-
f.Matches = append(f.Matches, match)
397+
// The keyword will be skipped if unknown,
398+
// don't add a nil value
399+
if match != nil {
400+
f.Matches = append(f.Matches, match)
401+
}
398402
}
399403

400404
// Parse all actions from the flow.

ovs/matchparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func parseMatch(key string, value string) (Match, error) {
112112
return parseTunID(value)
113113
}
114114

115-
return nil, fmt.Errorf("no match parser found for %s=%s", key, value)
115+
return nil, nil
116116
}
117117

118118
// parseClampInt calls strconv.Atoi on s, and then ensures that s is less than

ovs/matchparser_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func Test_parseMatch(t *testing.T) {
3030
invalid bool
3131
skipMarshal bool
3232
}{
33+
{
34+
s: "random_token=random_value",
35+
invalid: true,
36+
},
3337
{
3438
s: "foo=bar",
3539
invalid: true,

ovs/proto_trace.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ func (df *DataPathFlows) UnmarshalText(b []byte) error {
124124
if err != nil {
125125
return err
126126
}
127-
128-
df.Matches = append(df.Matches, m)
127+
// The keyword will be skipped if unknown,
128+
// don't add a nil value
129+
if m != nil {
130+
df.Matches = append(df.Matches, m)
131+
}
129132
}
130133

131134
return nil

0 commit comments

Comments
 (0)