On Mon, May 14, 2012 at 10:53:55AM +0900, FUJITA Tomonori wrote:
> On Mon, 14 May 2012 10:50:03 +0900
> Simon Horman <[email protected]> wrote:
> 
> > On Mon, May 14, 2012 at 10:25:36AM +0900, FUJITA Tomonori wrote:
> >> On Mon, 14 May 2012 10:19:17 +0900 (JST)
> >> FUJITA Tomonori <[email protected]> wrote:
> >> 
> >> > On Mon, 14 May 2012 10:03:59 +0900
> >> > Simon Horman <[email protected]> wrote:
> >> > 
> >> >> On Sun, May 13, 2012 at 09:03:01PM +0900, FUJITA Tomonori wrote:
> >> >>> Signed-off-by: FUJITA Tomonori <[email protected]>
> >> >>> ---
> >> >>>  ryu/ofproto/ofproto_v1_0.py        |    5 +++++
> >> >>>  ryu/ofproto/ofproto_v1_0_parser.py |   36 
> >> >>> ++++++++++++++++++++++++++++++++++++
> >> >>>  2 files changed, 41 insertions(+), 0 deletions(-)
> >> >>> 
> >> >>> diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
> >> >>> index 90bfdf4..b3c9c95 100644
> >> >>> --- a/ryu/ofproto/ofproto_v1_0.py
> >> >>> +++ b/ryu/ofproto/ofproto_v1_0.py
> >> >>> @@ -238,6 +238,7 @@ NXAST_REG_MOVE = 6
> >> >>>  NXAST_REG_LOAD = 7
> >> >>>  NXAST_SET_TUNNEL64 = 9
> >> >>>  NXAST_MULTIPATH = 10
> >> >>> +NXAST_BUNDLE = 12
> >> >>>  NXAST_BUNDLE_LOAD = 13
> >> >>>  NXAST_RESUBMIT_TABLE = 14
> >> >>>  
> >> >>> @@ -265,6 +266,10 @@ NX_ACTION_MULTIPATH_PACK_STR = '!HHIHHH2xHHI2xHI'
> >> >>>  NX_ACTION_MULTIPATH_SIZE = 32
> >> >>>  assert calcsize(NX_ACTION_MULTIPATH_PACK_STR) == 
> >> >>> NX_ACTION_MULTIPATH_SIZE
> >> >>>  
> >> >>> +NX_ACTION_BUNDLE_PACK_STR = '!HHIHHHHIHHI4x'
> >> >>> +NX_ACTION_BUNDLE_SIZE = 32
> >> >>> +assert calcsize(NX_ACTION_BUNDLE_PACK_STR) == NX_ACTION_BUNDLE_SIZE
> >> >>> +
> >> >>>  NX_ACTION_BUNDLE_LOAD_PACK_STR = '!HHIHHHHIHHI4x'
> >> >>>  NX_ACTION_BUNDLE_LOAD_SIZE = 32
> >> >>>  assert calcsize(NX_ACTION_BUNDLE_LOAD_PACK_STR) == 
> >> >>> NX_ACTION_BUNDLE_LOAD_SIZE
> >> >>> diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
> >> >>> b/ryu/ofproto/ofproto_v1_0_parser.py
> >> >>> index 651275c..c0c9b65 100644
> >> >>> --- a/ryu/ofproto/ofproto_v1_0_parser.py
> >> >>> +++ b/ryu/ofproto/ofproto_v1_0_parser.py
> >> >>> @@ -580,6 +580,42 @@ class NXActionMultipath(NXActionHeader):
> >> >>>                     dst)
> >> >>>  
> >> >>>  
> >> >>> [email protected]_nx_action_subtype(ofproto_v1_0.NXAST_BUNDLE)
> >> >>> +class NXActionBundle(NXActionHeader):
> >> >>> +    def __init__(self, algorithm, fields, basis, slave_type, n_slaves,
> >> >>> +                 ofs_nbits, dst, slaves):
> >> >>> +        super(NXActionBundle, self).__init__(
> >> >>> +            ofproto_v1_0.NXAST_BUNDLE,
> >> >>> +            ofproto_v1_0.NX_ACTION_BUNDLE_SIZE)
> >> >>> +        self.algorithm = algorithm
> >> >>> +        self.fields = fields
> >> >>> +        self.basis = basis
> >> >>> +        self.slave_type = slave_type
> >> >>> +        self.n_slaves = n_slaves
> >> >>> +        self.ofs_nbits = ofs_nbits
> >> >>> +        self.dst = dst
> >> >>> +        self.slaves = slaves
> >> >>> +
> >> >>> +    def serialize(self, buf, offset):
> >> >>> +        slave_offset = offset + ofproto_v1_0.NX_ACTION_BUNDLE_SIZE
> >> >>> +
> >> >>> +        for s in self.slaves:
> >> >>> +            msg_pack_into('!H', buf, slave_offset, s)
> >> >>> +            slave_offset += 2
> >> >>> +            self.len += 2
> >> >>> +
> >> >>> +        pad_len = self.len % 8
> >> >>> +        if pad_len != 0:
> >> >>> +            self.len += pad_len
> >> >>> +            msg_pack_into('%dx' % pad_len, buf, slave_offset)
> >> >>> +
> >> >>> +        msg_pack_into(ofproto_v1_0.NX_ACTION_BUNDLE_PACK_STR, buf,
> >> >>> +                      offset, self.type, self.len, self.vendor, 
> >> >>> self.subtype,
> >> >>> +                      self.algorithm, self.fields, self.basis,
> >> >>> +                      self.slave_type, self.n_slaves,
> >> >>> +                      self.ofs_nbits, self.dst)
> >> >>> +
> >> >>> +
> >> >>>  
> >> >>> @NXActionHeader.register_nx_action_subtype(ofproto_v1_0.NXAST_BUNDLE_LOAD)
> >> >>>  class NXActionBundleLoad(NXActionHeader):
> >> >>>      def __init__(self, algorithm, fields, basis, slave_type, n_slaves,
> >> >> 
> >> >> Hi Fujita-san,
> >> >> 
> >> >> as the NXAST_BUNDLE and NXAST_BUNDLE_LOAD actions share the same
> >> >> wire-format I wonder if it is desirable for them to share the same
> >> >> PACK_STRING or even have a shared parent class.
> >> > 
> >> > Yeah, I thought about the similar but I guess that we can't remove
> >> > much duplication with it so I did the simplest.
> >> > 
> >> >> As it seems that Ryu only needs parsing for NXAST_BUNDLE_LOAD and
> >> >> serlialisation for NXAST_BUNDLE,
> >> > 
> >> > What do you mean? Both actions need parsing and serlialisation,
> >> > I think.
> > 
> > Sorry, I now see that they both need parsing and serialisation.
> > 
> >> >> I don't imagine this would lead to much if
> >> >> any code reduction. But it may make it more obvious that the wire 
> >> >> format is
> >> >> the same.
> >> > 
> >> > If someone sends a clean patch to do that, I'll apply it, I guess. But
> >> > I don't care much since nxm is one time stuff for me. Hopefully, we
> >> > can focus on the standard of protocol in the future.
> >> 
> >> Ok, I still have some time on a train now. I'll see how I can clean up
> >> the stuff.
> > 
> > Ok, I guess that if the code isn't coming out cleanly then it
> > would be best to just drop my idea.
> 
> The following seems to work.

Nice.

Reviewed-by: Simon Horman <[email protected]>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to