When vid is OFPVID12_NONE, we should match only packets without vlan
tag. Before this commit we set vlan_tci to 0x0000/0x1fff which is fine
because it's only match packets without vlan tag too. But if we add flow
using:
ovs-ofctl -O OpenFlow10 add-flow br0 dl_vlan=0xffff,actions=drop
ovs-ofctl -O OpenFlow13 add-flow br0 dl_vlan=0xffff,actions=drop
, we get two flows:
ovs-ofctl -O OpenFlow10 dump-flows br0
cookie=0x0, duration=88.227s, table=0, n_packets=0, n_bytes=0,
idle_age=88, vlan_tci=0x0000 actions=drop
cookie=0x0, duration=67.503s, table=0, n_packets=0, n_bytes=0,
idle_age=67, vlan_tci=0x0000/0x1fff actions=drop
ovs-ofctl -O OpenFlow13 dump-flows br0
cookie=0x0, duration=36.657s, table=0, n_packets=0, n_bytes=0,
vlan_tci=0x0000/0x1fff actions=drop
cookie=0x0, duration=15.933s, table=0, n_packets=0, n_bytes=0,
vlan_tci=0x0000/0x1fff actions=drop
---
lib/match.c | 8 +++++++-
tests/ofp-print.at | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/match.c b/lib/match.c
index 58fa0e4..d83288a 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -445,7 +445,13 @@ match_set_dl_vlan(struct match *match, ovs_be16 dl_vlan)
void
match_set_vlan_vid(struct match *match, ovs_be16 vid)
{
- match_set_vlan_vid_masked(match, vid, htons(VLAN_VID_MASK | VLAN_CFI));
+ if (vid != OFPVID12_NONE) {
+ match_set_vlan_vid_masked(match, vid, htons(VLAN_VID_MASK | VLAN_CFI));
+ } else {
+ /* Match only packets without a VLAN tag. */
+ match->flow.vlan_tci = htons(0);
+ match->wc.masks.vlan_tci = OVS_BE16_MAX;
+ }
}
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 5871930..3513ab2 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -768,7 +768,7 @@ ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 \
00 01 00 00 00 00 00 00 00 04 00 18 00 00 00 00 \
00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 00 \
" 2], [0], [dnl
-OFPT_FLOW_MOD (OF1.2) (xid=0x2): ADD table:1
priority=65535,arp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2
actions=output:3
+OFPT_FLOW_MOD (OF1.2) (xid=0x2): ADD table:1
priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2
actions=output:3
], [dnl
])
AT_CLEANUP
@@ -806,7 +806,7 @@ ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 \
00 01 00 00 00 00 00 00 00 04 00 18 00 00 00 00 \
00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 00 \
" 2], [0], [dnl
-OFPT_FLOW_MOD (OF1.2) (xid=0x2): ADD table:1
priority=65535,arp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2
actions=output:3
+OFPT_FLOW_MOD (OF1.2) (xid=0x2): ADD table:1
priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2
actions=output:3
], [dnl
])
AT_CLEANUP
@@ -825,7 +825,7 @@ ff ff ff ff ff ff ff ff ff ff ff ff 00 1f 00 00 \
00 01 00 00 00 00 00 00 00 04 00 18 00 00 00 00 \
00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 00 \
" 2], [0], [dnl
-OFPT_FLOW_MOD (OF1.3) (xid=0x2): ADD table:1
priority=65535,arp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2
send_flow_rem check_overlap reset_counts no_packet_counts no_byte_counts
actions=output:3
+OFPT_FLOW_MOD (OF1.3) (xid=0x2): ADD table:1
priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2
send_flow_rem check_overlap reset_counts no_packet_counts no_byte_counts
actions=output:3
], [dnl
])
AT_CLEANUP
--
2.0.3
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev