ovs-ofctl: Encode cookies in OXM-compliant manner.
authorBen Pfaff <blp@nicira.com>
Fri, 5 Sep 2014 00:02:35 +0000 (17:02 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 7 Oct 2014 22:34:36 +0000 (15:34 -0700)
NXM/OXM are only supposed to put 1-bits in a value if the corresponding bit
in the mask is a 1-bit, but in the case of cookie matching, e.g.
    ovs-ofctl del-flows br0 cookie=0x3/0x1
ovs-ofctl would encode a bad OXM.  This fixes the problem.

(The test "ofproto - del flows based on cookie mask" in the OVS testsuite
tickles this bug.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
lib/nx-match.c
lib/ofp-util.c

index 6537601..4b9a9c4 100644 (file)
@@ -743,7 +743,7 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match,
                 flow->metadata, match->wc.masks.metadata);
 
     /* Cookie. */
-    nxm_put_64m(b, NXM_NX_COOKIE, cookie, cookie_mask);
+    nxm_put_64m(b, NXM_NX_COOKIE, cookie & cookie_mask, cookie_mask);
 
     match_len = ofpbuf_size(b) - start_len;
     return match_len;
index c8d38e8..ff84abb 100644 (file)
@@ -2229,7 +2229,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
             || fm->command == OFPFC_ADD) {
             ofm->cookie = fm->new_cookie;
         } else {
-            ofm->cookie = fm->cookie;
+            ofm->cookie = fm->cookie & fm->cookie_mask;
         }
         ofm->cookie_mask = fm->cookie_mask;
         if (fm->table_id != OFPTT_ALL