Signed-off-by: Justin Pettit <[email protected]>
---
lib/ofp-util.c | 14 +++++++++++++-
tests/ofproto.at | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 90475f7..18367ff 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1540,7 +1540,19 @@ ofputil_flow_mod_usable_protocols(const struct
ofputil_flow_mod *fms,
if (fm->table_id != 0xff) {
usable_protocols &= OFPUTIL_P_TID;
}
- if (fm->command != OFPFC_ADD && fm->cookie_mask != htonll(0)) {
+
+ /* Wildcard matching of the cookie is only supported through
+ * NXM. However, NXM and OpenFlow 1.0 allow updating of the
+ * cookie for the modify commands, so allow an exact-match
+ * through for that case. Add commands always use an exact-match
+ * cookie mask. */
+ if (fm->cookie_mask == htonll(UINT64_MAX)) {
+ if (fm->command != OFPFC_ADD
+ && fm->command != OFPFC_MODIFY
+ && fm->command != OFPFC_MODIFY_STRICT) {
+ usable_protocols &= OFPUTIL_P_NXM_ANY;
+ }
+ } else if (fm->cookie_mask != htonll(0)) {
usable_protocols &= OFPUTIL_P_NXM_ANY;
}
}
diff --git a/tests/ofproto.at b/tests/ofproto.at
index fdc7215..02b6068 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -167,6 +167,43 @@ NXST_AGGREGATE reply: packet_count=0 byte_count=0
flow_count=2
OVS_VSWITCHD_STOP
AT_CLEANUP
+AT_SETUP([ofproto - mod flow with cookie change (NXM)])
+# In NXM, the modification of an existing flow should not update the
+# cookie. For OpenFlow, the behavior is different depending on the
+# version. See below.
+OVS_VSWITCHD_START
+AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=0])
+AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
+ cookie=0x1, in_port=1 actions=output:0
+NXST_FLOW reply:
+])
+
+AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=0])
+AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
+ cookie=0x2, in_port=1 actions=output:0
+NXST_FLOW reply:
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
+# In OpenFlow 1.0, the modification of an existing flow should update
+# the cookie. Beginning in OpenFlow 1.1, the cookie is not updated.
+OVS_VSWITCHD_START
+AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=0])
+AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
[dnl
+ cookie=0x1, in_port=1 actions=output:0
+OFPST_FLOW reply:
+])
+
+AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0
cookie=0x2,in_port=1,actions=0])
+AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
[dnl
+ cookie=0x2, in_port=1 actions=output:0
+OFPST_FLOW reply:
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
AT_SETUP([ofproto - del flows with cookie])
OVS_VSWITCHD_START
AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
--
1.7.5.4
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev