ofp-util: Fix table features decoding of match and mask.
authorBen Pfaff <blp@nicira.com>
Mon, 4 Aug 2014 16:02:15 +0000 (09:02 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 11 Aug 2014 19:24:59 +0000 (12:24 -0700)
The call to parse_oxms() inside ofputil_decode_table_features() sets only
one bit in either 'match' or 'mask' for a given field that is matchable:
in 'mask' if the field is arbitrarily maskable or in 'match' otherwise.
The code at the end of ofputil_decode_table_features() mishandled this,
assuming that an arbitrarily matchable field would have that bit set in
both.  This meant that arbitrarily matchable fields were being
misinterpreted as not matchable at all.  This commit fixes the problem.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
lib/ofp-util.c

index 4c2c011..d835416 100644 (file)
@@ -4760,15 +4760,17 @@ ofputil_decode_table_features(struct ofpbuf *msg,
 
     /* Fix inconsistencies:
      *
-     *     - Turn off 'mask' and 'wildcard' bits that are not in 'match',
-     *       because a field must be matchable to be masked or wildcarded.
+     *     - Turn on 'match' bits that are set in 'mask', because maskable
+     *       fields are matchable.
      *
      *     - Turn on 'wildcard' bits that are set in 'mask', because a field
-     *       that is arbitrarily maskable can be wildcarded entirely. */
-    bitmap_and(tf->mask.bm, tf->match.bm, MFF_N_IDS);
-    bitmap_and(tf->wildcard.bm, tf->match.bm, MFF_N_IDS);
-
+     *       that is arbitrarily maskable can be wildcarded entirely.
+     *
+     *     - Turn off 'wildcard' bits that are not in 'match', because a field
+     *       must be matchable for it to be meaningfully wildcarded. */
+    bitmap_or(tf->match.bm, tf->mask.bm, MFF_N_IDS);
     bitmap_or(tf->wildcard.bm, tf->mask.bm, MFF_N_IDS);
+    bitmap_and(tf->wildcard.bm, tf->match.bm, MFF_N_IDS);
 
     return 0;
 }