sw test tool: Fix to compare OFPMatch using masks without byte boundary
Mask lengths without byte boundary are fixed as follows: - VLAN_VID, from 16 bits (2 bytes) to 12 + 1 bits - IPV6_EXTHDR, from 16 bits (2 bytes) to 9 bits Reported-by: Arne Goetje <arne_goetje@accton.com> Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
660c8e68b4
commit
51ec3d2d7b
@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import binascii
|
||||
import inspect
|
||||
import json
|
||||
import logging
|
||||
@ -782,6 +783,8 @@ class OfTester(app_manager.RyuApp):
|
||||
|
||||
def __reasm_match(match):
|
||||
""" reassemble match_fields. """
|
||||
mask_lengths = {'vlan_vid': 12 + 1,
|
||||
'ipv6_exthdr': 9}
|
||||
match_fields = list()
|
||||
for key, united_value in match.iteritems():
|
||||
if isinstance(united_value, tuple):
|
||||
@ -789,12 +792,18 @@ class OfTester(app_manager.RyuApp):
|
||||
# look up oxm_fields.TypeDescr to get mask length.
|
||||
for ofb in ofproto_v1_3.oxm_types:
|
||||
if ofb.name == key:
|
||||
mbytes = ofb.type.from_user(mask)
|
||||
# create all one bits mask
|
||||
mask_len = mask_lengths.get(
|
||||
key, ofb.type.size * 8)
|
||||
all_one_bits = 2 ** mask_len - 1
|
||||
# convert mask to integer
|
||||
mask_bytes = ofb.type.from_user(mask)
|
||||
oxm_mask = int(binascii.hexlify(mask_bytes), 16)
|
||||
# when mask is all one bits, remove mask
|
||||
if mbytes == '\xff' * ofb.type.size:
|
||||
if oxm_mask & all_one_bits == all_one_bits:
|
||||
united_value = value
|
||||
# when mask is all zero bits, remove field.
|
||||
elif mbytes == '\x00' * ofb.type.size:
|
||||
elif oxm_mask & all_one_bits == 0:
|
||||
united_value = None
|
||||
break
|
||||
if united_value is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user