diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py index 16c47976..4a6dcfef 100644 --- a/ryu/ofproto/ofproto_v1_3.py +++ b/ryu/ofproto/ofproto_v1_3.py @@ -1179,6 +1179,12 @@ oxm_types = [ oxm_fields.ONFExperimenter('pbb_uca', 2560, oxm_fields.Int1), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, oxm_fields.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, oxm_fields.IPv4Addr), + + # The following definition is merely for testing 64-bit experimenter OXMs. + # Following Open vSwitch, we use dp_hash for this purpose. + # Prefix the name with '_' to indicate this is not intended to be used + # in wild. + oxm_fields.NiciraExperimenter('_dp_hash', 0, oxm_fields.Int4), ] oxm_fields.generate(__name__) diff --git a/ryu/ofproto/oxm_fields.py b/ryu/ofproto/oxm_fields.py index ab33cddb..0004f86b 100644 --- a/ryu/ofproto/oxm_fields.py +++ b/ryu/ofproto/oxm_fields.py @@ -150,6 +150,10 @@ class ONFExperimenter(_Experimenter): self.exp_type = num +class NiciraExperimenter(_Experimenter): + experimenter_id = ofproto_common.NX_EXPERIMENTER_ID + + class NiciraExtended0(_OxmClass): """Nicira Extended Match (NXM_0) diff --git a/ryu/tests/unit/ofproto/test_oxm.py b/ryu/tests/unit/ofproto/test_oxm.py index b3336675..a2047f8b 100644 --- a/ryu/tests/unit/ofproto/test_oxm.py +++ b/ryu/tests/unit/ofproto/test_oxm.py @@ -75,6 +75,25 @@ class Test_OXM(unittest.TestCase): ) self._test(user, on_wire, 4) + def test_exp_nomask(self): + user = ('_dp_hash', 0x12345678) + on_wire = ( + b'\xff\xff\x00\x08' + b'\x00\x00\x23\x20' # Nicira + b'\x12\x34\x56\x78' + ) + self._test(user, on_wire, 8) + + def test_exp_mask(self): + user = ('_dp_hash', (0x12345678, 0x7fffffff)) + on_wire = ( + b'\xff\xff\x01\x0c' + b'\x00\x00\x23\x20' # Nicira + b'\x12\x34\x56\x78' + b'\x7f\xff\xff\xff' + ) + self._test(user, on_wire, 8) + def test_nxm_1_nomask(self): user = ('tun_ipv4_src', '192.0.2.1') on_wire = (