Hi, Please see attached patch with your comments resolved. I think I will need some guidelines on how to add unitest if necessary Thanks, Eran On Wed, Jun 17, 2015 at 5:53 PM, IWAMOTO Toshihiro <[email protected]> wrote:
> Hi, > > At Tue, 16 Jun 2015 08:53:27 +0300, > Eran Gampel wrote: > > > > 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 > > - > > Please keep this blank line. > > > import logging > > LOG = logging.getLogger('ryu.ofproto.nx_match') > > > > > > 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') > > > > > > This change is unnecessary, too. > > -- > IWAMOTO Toshihiro >
From 83d8505229cfa495f6fce17b05cda5c516d78fb7 Mon Sep 17 00:00:00 2001 From: Eran <[email protected]> Date: Thu, 18 Jun 2015 06:07:22 -0700 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 <[email protected]> --- ryu/ofproto/nx_match.py | 24 ++++++++++++++++++++++++ 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 + 5 files changed, 30 insertions(+) diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py index 38ce02b..c161720 100644 --- a/ryu/ofproto/nx_match.py +++ b/ryu/ofproto/nx_match.py @@ -90,6 +90,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 +112,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 +293,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: @@ -914,6 +920,17 @@ class MFRegister(MFField): 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_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), ] -- 1.9.1
------------------------------------------------------------------------------
_______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
