test_ofctl: Add unit test for masked ipv6_exthdr match field
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
109d2bb2fd
commit
d299339991
@ -62,8 +62,8 @@ def _to_match_ip(value):
|
|||||||
return value, None
|
return value, None
|
||||||
|
|
||||||
|
|
||||||
def _to_match_metadata(value):
|
def _to_match_masked_int(value):
|
||||||
if '/' in value:
|
if isinstance(value, str) and '/' in value:
|
||||||
value = value.split('/')
|
value = value.split('/')
|
||||||
return _str_to_int(value[0]), _str_to_int(value[1])
|
return _str_to_int(value[0]), _str_to_int(value[1])
|
||||||
else:
|
else:
|
||||||
@ -270,17 +270,17 @@ class Test_ofctl(unittest.TestCase):
|
|||||||
elif key == 'vlan_vid':
|
elif key == 'vlan_vid':
|
||||||
eq_(expected_value['vlan_vid'][value]['to_match'], field_value)
|
eq_(expected_value['vlan_vid'][value]['to_match'], field_value)
|
||||||
return
|
return
|
||||||
elif key == 'metadata':
|
elif key == 'metadata' or key == 'ipv6_exthdr':
|
||||||
# Metadata
|
# Metadata or IPv6 Extension Header pseudo-field
|
||||||
meta, mask = _to_match_metadata(value)
|
value, mask = _to_match_masked_int(value)
|
||||||
if mask is not None:
|
if mask is not None:
|
||||||
# with mask
|
# with mask
|
||||||
meta &= mask
|
value &= mask
|
||||||
eq_(meta, field_value[0])
|
eq_(value, field_value[0])
|
||||||
eq_(mask, field_value[1])
|
eq_(mask, field_value[1])
|
||||||
else:
|
else:
|
||||||
# without mask
|
# without mask
|
||||||
eq_(meta, field_value)
|
eq_(value, field_value)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
eq_(value, field_value)
|
eq_(value, field_value)
|
||||||
@ -348,18 +348,18 @@ class Test_ofctl(unittest.TestCase):
|
|||||||
elif key == 'dl_vlan':
|
elif key == 'dl_vlan':
|
||||||
eq_(expected_value['vlan_vid'][value]['to_str'], field_value)
|
eq_(expected_value['vlan_vid'][value]['to_str'], field_value)
|
||||||
return
|
return
|
||||||
elif key == 'metadata':
|
elif key == 'metadata' or key == 'ipv6_exthdr':
|
||||||
# Metadata
|
# Metadata or IPv6 Extension Header pseudo-field
|
||||||
meta, mask = _to_match_metadata(value)
|
value, mask = _to_match_masked_int(value)
|
||||||
if mask is not None:
|
if mask is not None:
|
||||||
# with mask
|
# with mask
|
||||||
field_value = field_value.split('/')
|
field_value = field_value.split('/')
|
||||||
meta &= mask
|
value &= mask
|
||||||
eq_(str(meta), field_value[0])
|
eq_(str(value), field_value[0])
|
||||||
eq_(str(mask), field_value[1])
|
eq_(str(mask), field_value[1])
|
||||||
else:
|
else:
|
||||||
# without mask
|
# without mask
|
||||||
eq_(str(meta), field_value)
|
eq_(str(value), field_value)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
eq_(value, field_value)
|
eq_(value, field_value)
|
||||||
@ -617,6 +617,8 @@ class test_data_v1_3(test_data_v1_2):
|
|||||||
{'pbb_isid': 5, 'eth_type': 0x88E7},
|
{'pbb_isid': 5, 'eth_type': 0x88E7},
|
||||||
{'tunnel_id': 7},
|
{'tunnel_id': 7},
|
||||||
{'ipv6_exthdr': 3, 'eth_type': 0x86dd},
|
{'ipv6_exthdr': 3, 'eth_type': 0x86dd},
|
||||||
|
{'ipv6_exthdr': "0x40", 'eth_type': 0x86dd},
|
||||||
|
{'ipv6_exthdr': "0x40/0x1F0", 'eth_type': 0x86dd},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user