Following Open vSwitch, introduce "dp_hash" OXM for testing.

>From their commit log: (commit 508a933809f8a8ede4fb93f1c1e3212799efc16a)
> Testing experimenter OXM is tricky because I do not know of any in
> widespread use.  Two ONF proposals use experimenter OXMs: EXT-256 and
> EXT-233.  EXT-256 is not suitable to implement for testing because its use
> of experimenter OXM is wrong and will be changed.  EXT-233 is not suitable
> to implement for testing because it requires adding a new field to struct
> flow and I am not yet convinced that that field and the feature that it
> supports is worth having in Open vSwitch.  Thus, this commit assigns an
> experimenter OXM code point to an existing OVS field that is currently
> restricted from use by controllers, "dp_hash", and uses that for testing.
> Because controllers cannot use it, this leaves future versions of OVS free
> to drop the support for the experimenter OXM for this field without causing
> backward compatibility problems.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/ofproto/ofproto_v1_3.py        |  6 ++++++
 ryu/ofproto/oxm_fields.py          |  4 ++++
 ryu/tests/unit/ofproto/test_oxm.py | 19 +++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index 16c4797..4a6dcfe 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 ab33cdd..0004f86 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 b333667..a2047f8 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 = (
-- 
2.1.0


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to