Please see below merged patch

>From 1e3cf43f6cda27f91659c2fe7ad9d2692158a628 Mon Sep 17 00:00:00 2001
From: eran gampel <[email protected]>
Date: Sun, 14 Jun 2015 18:51:30 +0300
Subject: [PATCH]  Add support for the nicira extension mark
(NXM_NX_PKT_MARK),
  Add support for match and action set via NXAction ReMove This extension is
 important as it is the only mark that stay persistence across virtual
 switches Signed-off-by: Eran Gampel [email protected]

Signed-off-by: eran gampel <[email protected]>
---
 ryu/ofproto/nx_match.py                            | 26
+++++++++++++++++++++-
 ryu/ofproto/ofproto_parser.py                      |  1 -
 ryu/ofproto/ofproto_v1_0.py                        |  3 +++
 ryu/ofproto/ofproto_v1_3.py                        |  1 +
 ryu/ofproto/ofproto_v1_4.py                        |  1 +
 ryu/ofproto/ofproto_v1_5.py                        |  1 +
 .../json/of13/4-60-ofp_flow_mod.packet.json        |  7 ++++++
 7 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 38ce02b..b6af752 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -23,7 +23,6 @@ from ryu.lib import mac
 from ryu.lib.pack_utils import msg_pack_into
 from . import ofproto_v1_0
 from . import inet
-
 import logging
 LOG = logging.getLogger('ryu.ofproto.nx_match')

@@ -90,6 +89,7 @@ class Flow(object):
         self.nw_frag = 0
         self.regs = [0] * FLOW_N_REGS
         self.ipv6_label = 0
+        self.pkt_mark = 0


 class FlowWildcards(object):
@@ -111,6 +111,7 @@ class FlowWildcards(object):
         self.regs_bits = 0
         self.regs_mask = [0] * FLOW_N_REGS
         self.wildcards = ofproto_v1_0.OFPFW_ALL
+        self.pkt_mark_mask = 0


 class ClsRule(object):
@@ -291,6 +292,10 @@ class ClsRule(object):
         self.flow.regs[reg_idx] = value
         self.wc.regs_bits |= (1 << reg_idx)

+    def set_pkt_mark_masked(self, pkt_mark, mask):
+        self.flow.pkt_mark = pkt_mark
+        self.wc.pkt_mark_mask = mask
+
     def flow_format(self):From 1e3cf43f6cda27f91659c2fe7ad9d2692158a628
Mon Sep 17 00:00:00 2001
From: eran gampel <[email protected]>
Date: Sun, 14 Jun 2015 18:51:30 +0300
Subject: [PATCH]  Add support for the nicira extension mark
(NXM_NX_PKT_MARK),
  Add support for match and action set via NXAction ReMove This extension is
 important as it is the only mark that stay persistence across virtual
 switches Signed-off-by: Eran Gampel [email protected]

Signed-off-by: eran gampel <[email protected]>
---
 ryu/ofproto/nx_match.py                            | 26
+++++++++++++++++++++-
 ryu/ofproto/ofproto_parser.py                      |  1 -
 ryu/ofproto/ofproto_v1_0.py                        |  3 +++
 ryu/ofproto/ofproto_v1_3.py                        |  1 +
 ryu/ofproto/ofproto_v1_4.py                        |  1 +
 ryu/ofproto/ofproto_v1_5.py                        |  1 +
 .../json/of13/4-60-ofp_flow_mod.packet.json        |  7 ++++++
 7 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 38ce02b..b6af752 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -23,7 +23,6 @@ from ryu.lib import mac
 from ryu.lib.pack_utils import msg_pack_into
 from . import ofproto_v1_0
 from . import inet
-
 import logging
 LOG = logging.getLogger('ryu.ofproto.nx_match')

@@ -90,6 +89,7 @@ class Flow(object):
         self.nw_frag = 0
         self.regs = [0] * FLOW_N_REGS
         self.ipv6_label = 0
+        self.pkt_mark = 0


 class FlowWildcards(object):
@@ -111,6 +111,7 @@ class FlowWildcards(object):
         self.regs_bits = 0
         self.regs_mask = [0] * FLOW_N_REGS
         self.wildcards = ofproto_v1_0.OFPFW_ALL
+        self.pkt_mark_mask = 0


 class ClsRule(object):
@@ -291,6 +292,10 @@ class ClsRule(object):
         self.flow.regs[reg_idx] = value
         self.wc.regs_bits |= (1 << reg_idx)

+    def set_pkt_mark_masked(self, pkt_mark, mask):
+        self.flow.pkt_mark = pkt_mark
+        self.wc.pkt_mark_mask = mask
+
     def flow_format(self):
         # Tunnel ID is only supported by NXM
         if self.wc.tun_id_mask != 0:
@@ -913,6 +918,18 @@ class MFRegister(MFField):
                 else:
                     return self._put(buf, offset, rule.flow.regs[i])

+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_NX_PKT_MARK,
+                    ofproto_v1_0.NXM_NX_PKT_MARK_W])
+class MFPktMark(MFField):
+    @classmethod
+    def make(cls, header):
+        return cls(header, MF_PACK_STRING_BE32)
+
+    def put(self, buf, offset, rule):
+        return self.putm(buf, offset, rule.flow.pkt_mark,
+                rule.wc.pkt_mark_mask)
+

 def serialize_nxm_match(rule, buf, offset):
     old_offset = offset
@@ -1071,6 +1088,13 @@ def serialize_nxm_match(rule, buf, offset):
             header = ofproto_v1_0.NXM_NX_IP_FRAG_W
         offset += nxm_put(buf, offset, header, rule)

+    if rule.flow.pkt_mark != 0:
+        if rule.wc.pkt_mark_mask == UINT32_MAX:
+            header = ofproto_v1_0.NXM_NX_PKT_MARK
+        else:
+            header = ofproto_v1_0.NXM_NX_PKT_MARK_W
+        offset += nxm_put(buf, offset, header, rule)
+
     # Tunnel Id
     if rule.wc.tun_id_mask != 0:
         if rule.wc.tun_id_mask == UINT64_MAX:
diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py
index 8a1cebb..35adf04 100644
--- a/ryu/ofproto/ofproto_parser.py
+++ b/ryu/ofproto/ofproto_parser.py
@@ -26,7 +26,6 @@ from ryu import utils
 from ryu.lib import stringify

 from . import ofproto_common
-
 LOG = logging.getLogger('ryu.ofproto.ofproto_parser')


diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 8da9970..2b0e052 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -582,6 +582,9 @@ NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)

 NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)

+NXM_NX_PKT_MARK = nxm_header(0x0001, 33, 4)
+NXM_NX_PKT_MARK_W = nxm_header_w(0x0001, 33, 4)
+

 def nxm_nx_reg(idx):
     return nxm_header(0x0001, idx, 4)
diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index f6da98a..16b53e5 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -1192,6 +1192,7 @@ oxm_types = [
     oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
     oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
     oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+    oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
     oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),

     # The following definition is merely for testing 64-bit experimenter
OXMs.
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 6542b6f..19945fb 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -391,6 +391,7 @@ oxm_types = [
     oxm_fields.OpenFlowBasic('pbb_uca', 41, type_desc.Int1),
     oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
     oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+    oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
 ]

 oxm_fields.generate(__name__)
diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py
index 6043a2e..e0372e5 100644
--- a/ryu/ofproto/ofproto_v1_5.py
+++ b/ryu/ofproto/ofproto_v1_5.py
@@ -435,6 +435,7 @@ oxm_types = [
     oxm_fields.OpenFlowBasic('packet_type', 44, type_desc.Int4),
     oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
     oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+    oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
     oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
 ]

diff --git a/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
b/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
index 1c594e8..448d035 100644
--- a/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
@@ -305,6 +305,13 @@
                      "mask": null,
                      "value": "1.2.3.4"
                   }
+               },
+               {
+                  "OXMTlv": {
+                     "field": "pkt_mark",
+                     "mask": null,
+                     "value": "283686952306183"
+                  }
                }
             ],
             "type": 1
-- 
1.9.1
         # Tunnel ID is only supported by NXM
         if self.wc.tun_id_mask != 0:
@@ -913,6 +918,18 @@ class MFRegister(MFField):
                 else:
                     return self._put(buf, offset, rule.flow.regs[i])

+@_register_make
+@_set_nxm_headers([ofproto_v1_0.NXM_NX_PKT_MARK,
+                    ofproto_v1_0.NXM_NX_PKT_MARK_W])
+class MFPktMark(MFField):
+    @classmethod
+    def make(cls, header):
+        return cls(header, MF_PACK_STRING_BE32)
+
+    def put(self, buf, offset, rule):
+        return self.putm(buf, offset, rule.flow.pkt_mark,
+                rule.wc.pkt_mark_mask)
+

 def serialize_nxm_match(rule, buf, offset):
     old_offset = offset
@@ -1071,6 +1088,13 @@ def serialize_nxm_match(rule, buf, offset):
             header = ofproto_v1_0.NXM_NX_IP_FRAG_W
         offset += nxm_put(buf, offset, header, rule)

+    if rule.flow.pkt_mark != 0:
+        if rule.wc.pkt_mark_mask == UINT32_MAX:
+            header = ofproto_v1_0.NXM_NX_PKT_MARK
+        else:
+            header = ofproto_v1_0.NXM_NX_PKT_MARK_W
+        offset += nxm_put(buf, offset, header, rule)
+
     # Tunnel Id
     if rule.wc.tun_id_mask != 0:
         if rule.wc.tun_id_mask == UINT64_MAX:
diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py
index 8a1cebb..35adf04 100644
--- a/ryu/ofproto/ofproto_parser.py
+++ b/ryu/ofproto/ofproto_parser.py
@@ -26,7 +26,6 @@ from ryu import utils
 from ryu.lib import stringify

 from . import ofproto_common
-
 LOG = logging.getLogger('ryu.ofproto.ofproto_parser')


diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 8da9970..2b0e052 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -582,6 +582,9 @@ NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)

 NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)

+NXM_NX_PKT_MARK = nxm_header(0x0001, 33, 4)
+NXM_NX_PKT_MARK_W = nxm_header_w(0x0001, 33, 4)
+

 def nxm_nx_reg(idx):
     return nxm_header(0x0001, idx, 4)
diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index f6da98a..16b53e5 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -1192,6 +1192,7 @@ oxm_types = [
     oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
     oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
     oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+    oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
     oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),

     # The following definition is merely for testing 64-bit experimenter
OXMs.
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 6542b6f..19945fb 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -391,6 +391,7 @@ oxm_types = [
     oxm_fields.OpenFlowBasic('pbb_uca', 41, type_desc.Int1),
     oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
     oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+    oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
 ]

 oxm_fields.generate(__name__)
diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py
index 6043a2e..e0372e5 100644
--- a/ryu/ofproto/ofproto_v1_5.py
+++ b/ryu/ofproto/ofproto_v1_5.py
@@ -435,6 +435,7 @@ oxm_types = [
     oxm_fields.OpenFlowBasic('packet_type', 44, type_desc.Int4),
     oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
     oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
+    oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
     oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
 ]

diff --git a/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
b/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
index 1c594e8..448d035 100644
--- a/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/4-60-ofp_flow_mod.packet.json
@@ -305,6 +305,13 @@
                      "mask": null,
                      "value": "1.2.3.4"
                   }
+               },
+               {
+                  "OXMTlv": {
+                     "field": "pkt_mark",
+                     "mask": null,
+                     "value": "283686952306183"
+                  }
                }
             ],
             "type": 1
-- 
1.9.1




On Sun, Jun 14, 2015 at 4:38 PM, FUJITA Tomonori <
[email protected]> wrote:

> On Fri, 12 Jun 2015 10:32:37 +0300
> Eran Gampel <[email protected]> wrote:
>
> > Add support for the Nicira extension mark (NXM_NX_PKT_MARK),
> >  Add support for match and action.
> >  This extension is important as it is the only mark that stay persistence
> > across virtual switches.
> > Added support for 1.3,1.4,1.5 Openflow proto
> > Tried to follow the unit test example, but I am not sure if I need to add
> > more tests, please review let me know if I need to add/modify the patch.
>
> Great, thanks a lot! However, I can't apply this patch clealy:
>
> FUJITA-no-MacBook-Pro:ryu fujita$ patch -p1 < 1
> patching file ryu/ofproto/nx_match.py
> patching file ryu/ofproto/ofproto_parser.py
> patching file ryu/ofproto/ofproto_v1_0.py
> patching file ryu/ofproto/ofproto_v1_3.py
> patch: **** malformed patch at line 239: OXMs.
>
> Can you update the patch and send it?
>
> Thanks a lot!
>
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to