The parse_ofp_str() function wouldn't allow any cookie mask to be supplied for an "add" command. This commit allows a mask to be supplied as long as it's exact-match (ie, -1).
Signed-off-by: Justin Pettit <jpet...@nicira.com> --- lib/ofp-parse.c | 8 +++++--- tests/ofproto.at | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index 3f7a021..c1344aa 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -644,12 +644,14 @@ parse_ofp_str(struct ofputil_flow_mod *fm, int command, const char *str_, } else if (!strcmp(name, "cookie")) { char *mask = strchr(value, '/'); if (mask) { - if (command == OFPFC_ADD) { + *mask = '\0'; + fm->cookie_mask = htonll(str_to_u64(mask+1)); + + if (command == OFPFC_ADD + && fm->cookie_mask != htonll(UINT64_MAX)) { ofp_fatal(str_, verbose, "flow additions cannot use " "a cookie mask"); } - *mask = '\0'; - fm->cookie_mask = htonll(str_to_u64(mask+1)); } else { fm->cookie_mask = htonll(UINT64_MAX); } diff --git a/tests/ofproto.at b/tests/ofproto.at index 696b43f..5dc2aae 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -167,6 +167,28 @@ NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2 OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([ofproto - add flow with cookie mask]) +# Adding a flow with a cookie mask other than exact-match (-1) doesn't +# make sense. +OVS_VSWITCHD_START +AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1/-1,in_port=1,actions=0]) +AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl + cookie=0x1, in_port=1 actions=output:0 +NXST_FLOW reply: +]) + +AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2/0,in_port=2,actions=0], [1], +[], [stderr]) +AT_CHECK([head -n 1 stderr], [0], + [ovs-ofctl: flow additions cannot use a cookie mask +]) +AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl + cookie=0x1, in_port=1 actions=output:0 +NXST_FLOW reply: +]) +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 -- 1.7.5.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev