Skip to content

Commit

Permalink
ovs-ofctl: Encode cookies in OXM-compliant manner.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: YAMAMOTO Takashi <[email protected]>
  • Loading branch information
blp committed Oct 7, 2014
1 parent 099c06e commit ba5cc06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/nx-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba5cc06

Please sign in to comment.