Skip to content

Commit 4b28a97

Browse files
authored
Merge pull request #71 from ecbaldwin/parse-local
Parse the special LOCAL port correctly in ofproto/trace flows
2 parents 10882ec + c968033 commit 4b28a97

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

ovs/proto_trace.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ var (
3535
)
3636

3737
const (
38-
popvlan = "popvlan"
39-
pushvlan = "pushvlan"
40-
drop = "drop"
38+
popvlan = "popvlan"
39+
pushvlan = "pushvlan"
40+
drop = "drop"
41+
localPort = 65534
4142
)
4243

4344
// DataPathActions is a text unmarshaler for data path actions in ofproto/trace output
@@ -86,6 +87,15 @@ func (df *DataPathFlows) UnmarshalText(b []byte) error {
8687
return fmt.Errorf("unexpected match format for match %q", match)
8788
}
8889

90+
switch strings.TrimSpace(kv[0]) {
91+
case inPort:
92+
// Parse in_port=LOCAL into a new match.
93+
if strings.TrimSpace(kv[1]) == portLOCAL {
94+
df.Matches = append(df.Matches, InPortMatch(localPort))
95+
continue
96+
}
97+
}
98+
8999
m, err := parseMatch(kv[0], kv[1])
90100
if err != nil {
91101
return err

ovs/proto_trace_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ bridge("br0")
3838
3939
Final flow: unchanged
4040
Megaflow: recirc_id=0,tcp,in_port=3,nw_src=192.0.2.0/24,nw_frag=no,tp_dst=22
41+
Datapath actions: 1`,
42+
actions: NewDataPathActions("1"),
43+
},
44+
{
45+
name: "in_port is LOCAL",
46+
output: `Flow: tcp,in_port=LOCAL,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,nw_src=192.0.2.2,nw_dst=0.0.0.0,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=0,tp_dst=22,tcp_flags=0
47+
48+
bridge("br0")
49+
-------------
50+
0. ip,in_port=LOCAL,nw_src=192.0.2.0/24, priority 32768
51+
resubmit(,2)
52+
2. tcp,tp_dst=22, priority 32768
53+
output:1
54+
55+
Final flow: unchanged
56+
Megaflow: recirc_id=0,tcp,in_port=LOCAL,nw_src=192.0.2.0/24,nw_frag=no,tp_dst=22
4157
Datapath actions: 1`,
4258
actions: NewDataPathActions("1"),
4359
},

0 commit comments

Comments
 (0)