ofproto: Do not add flow on flow mod if new_cookie is UINT64_MAX
authorSimon Horman <horms@verge.net.au>
Fri, 12 Oct 2012 00:26:28 +0000 (09:26 +0900)
committerBen Pfaff <blp@nicira.com>
Fri, 12 Oct 2012 17:22:48 +0000 (10:22 -0700)
Internally a new_cookie value UINT64_MAX is used for
an OpenFlow 1.2 flow mod whose command is not Add.
Open Flow 1.2 does not permit adding flows for such commands.
Also, UINT64_MAX is a prohibited cookie value, and the
existing code created a flow with that value as for the cookie.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index a128a6d..9d25a13 100644 (file)
@@ -3080,6 +3080,17 @@ modify_flows__(struct ofproto *ofproto, struct ofconn *ofconn,
     return error;
 }
 
+static enum ofperr
+modify_flows_add(struct ofproto *ofproto, struct ofconn *ofconn,
+                 const struct ofputil_flow_mod *fm,
+                 const struct ofp_header *request)
+{
+    if (fm->cookie_mask != htonll(0) || fm->new_cookie == htonll(UINT64_MAX)) {
+        return 0;
+    }
+    return add_flow(ofproto, ofconn, fm, request);
+}
+
 /* Implements OFPFC_MODIFY.  Returns 0 on success or an OpenFlow error code on
  * failure.
  *
@@ -3099,7 +3110,7 @@ modify_flows_loose(struct ofproto *ofproto, struct ofconn *ofconn,
     if (error) {
         return error;
     } else if (list_is_empty(&rules)) {
-        return fm->cookie_mask ? 0 : add_flow(ofproto, ofconn, fm, request);
+        return modify_flows_add(ofproto, ofconn, fm, request);
     } else {
         return modify_flows__(ofproto, ofconn, fm, request, &rules);
     }
@@ -3125,7 +3136,7 @@ modify_flow_strict(struct ofproto *ofproto, struct ofconn *ofconn,
     if (error) {
         return error;
     } else if (list_is_empty(&rules)) {
-        return fm->cookie_mask ? 0 : add_flow(ofproto, ofconn, fm, request);
+        return modify_flows_add(ofproto, ofconn, fm, request);
     } else {
         return list_is_singleton(&rules) ? modify_flows__(ofproto, ofconn,
                                                           fm, request, &rules)