On Mon, 14 May 2012 11:42:56 +0900
Isaku Yamahata <[email protected]> wrote:

> 
> It might be too late because it has been already committed.
> pep8 please. Too long lines.

Ok, the following fixed patch was applied (including some other pep8
fixes to two modified files).


=
>From 17979ffefa4138098732e9da9aa408da97a3c5a5 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Mon, 14 May 2012 12:48:42 +0900
Subject: [PATCH] add Nicira Extension NXAST_BUNDLE and NXAST_BUNDLE_LOAD
 support

Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/ofproto/ofproto_v1_0.py        |   18 ++++++-
 ryu/ofproto/ofproto_v1_0_parser.py |   85 +++++++++++++++++++++++++++++++++++-
 2 files changed, 98 insertions(+), 5 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index c45f316..b7acd5f 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -238,6 +238,8 @@ 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
 
 NX_ACTION_RESUBMIT_PACK_STR = '!HHIHHB3x'
@@ -264,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_HEADER_PACK_STR = '!HHIH'
 NX_ACTION_HEADER_SIZE = 10
 assert calcsize(NX_ACTION_HEADER_PACK_STR) == NX_ACTION_HEADER_SIZE
@@ -572,7 +578,7 @@ NXM_OF_ETH_DST_W = nxm_header_w(0x0000, 1, 6)
 NXM_OF_ETH_SRC = nxm_header(0x0000, 2, 6)
 NXM_OF_ETH_TYPE = nxm_header(0x0000, 3, 2)
 
-NXM_OF_VLAN_TCI =  nxm_header(0x0000, 4, 2)
+NXM_OF_VLAN_TCI = nxm_header(0x0000, 4, 2)
 NXM_OF_VLAN_TCI_W = nxm_header_w(0x0000, 4, 2)
 
 NXM_OF_IP_TOS = nxm_header(0x0000, 5, 1)
@@ -617,14 +623,16 @@ NXM_NX_ND_SLL = nxm_header(0x0001, 24, 6)
 
 NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6)
 
+NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
+
+
 def nxm_nx_reg(idx):
     return nxm_header(0x0001, idx, 4)
 
+
 def nxm_nx_reg_w(idx):
     return nxm_header_w(0x0001, idx, 4)
 
-NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
-
 NXM_HEADER_PACK_STRING = '!I'
 
 # enum nx_hash_fields
@@ -636,3 +644,7 @@ NX_MP_ALG_MODULO_N = 0
 NX_MP_ALG_HASH_THRESHOLD = 1
 NX_MP_ALG_HRW = 2
 NX_MP_ALG_ITER_HASH = 3
+
+# enum nx_bd_algorithm
+NX_BD_ALG_ACTIVE_BACKUP = 0
+NX_BD_ALG_HRW = 1
diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index f345de8..d2f8cd1 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -403,7 +403,6 @@ class NXActionHeader(object):
             return cls
         return _register_nx_action_subtype
 
-
     def __init__(self, subtype_, len_):
         self.type = ofproto_v1_0.OFPAT_VENDOR
         self.len = len_
@@ -421,6 +420,7 @@ class NXActionHeader(object):
         cls_ = cls._NX_ACTION_SUBTYPES.get(subtype)
         return cls_.parser(buf, offset)
 
+
 class NXActionResubmitBase(NXActionHeader):
     def __init__(self, subtype, in_port, table):
         assert subtype in (ofproto_v1_0.NXAST_RESUBMIT,
@@ -481,6 +481,7 @@ class NXActionSetTunnel(NXActionHeader):
             ofproto_v1_0.NX_ACTION_SET_TUNNEL_PACK_STR, buf, offset)
         return cls(tun_id)
 
+
 @NXActionHeader.register_nx_action_subtype(ofproto_v1_0.NXAST_REG_MOVE)
 class NXActionRegMove(NXActionHeader):
     def __init__(self, n_bits, src_ofs, dst_ofs, src, dst):
@@ -542,7 +543,7 @@ class NXActionSetTunnel64(NXActionHeader):
         msg_pack_into(ofproto_v1_0.NX_ACTION_SET_TUNNEL64_PACK_STR, buf,
                       offset, self.type, self.len, self.vendor, self.subtype,
                       self.tun_id)
-        
+
     @classmethod
     def parser(cls, buf, offset):
         type_, len_, vendor, subtype, in_port, table = struct.unpack_from(
@@ -580,6 +581,86 @@ class NXActionMultipath(NXActionHeader):
                    dst)
 
 
+class NXActionBundleBase(NXActionHeader):
+    def __init__(self, subtype, algorithm, fields, basis, slave_type, n_slaves,
+                 ofs_nbits, dst, slaves):
+        _len = ofproto_v1_0.NX_ACTION_BUNDLE_SIZE + len(slaves) * 2
+        _len += (_len % 8)
+        super(NXActionBundleBase, self).__init__(subtype, _len)
+
+        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
+
+        pad_len = (len(self.slaves) * 2 +
+                   ofproto_v1_0.NX_ACTION_BUNDLE_SIZE) % 8
+
+        if pad_len != 0:
+            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)
+
+    @classmethod
+    def parser(cls, action_cls, buf, offset):
+        type_, len_, vendor, subtype, algorithm, fields, basis,\
+            slave_type, n_slaves, ofs_nbits, dst = struct.unpack_from(
+            ofproto_v1_0.NX_ACTION_BUNDLE_PACK_STR, buf, offset)
+        slave_offset = offset + ofproto_v1_0.NX_ACTION_BUNDLE_SIZE
+
+        slaves = []
+        for i in range(0, n_slaves):
+            s = struct.unpack_from('!H', buf, slave_offset)
+            slaves.append(s[0])
+            slave_offset += 2
+
+        return action_cls(algorithm, fields, basis, slave_type,
+                          n_slaves, ofs_nbits, dst, slaves)
+
+
[email protected]_nx_action_subtype(ofproto_v1_0.NXAST_BUNDLE)
+class NXActionBundle(NXActionBundleBase):
+    def __init__(self, algorithm, fields, basis, slave_type, n_slaves,
+                 ofs_nbits, dst, slaves):
+        super(NXActionBundle, self).__init__(
+            ofproto_v1_0.NXAST_BUNDLE,
+            algorithm, fields, basis, slave_type, n_slaves,
+            ofs_nbits, dst, slaves)
+
+    @classmethod
+    def parser(cls, buf, offset):
+        return NXActionBundleBase.parser(NXActionBundle, buf, offset)
+
+
[email protected]_nx_action_subtype(ofproto_v1_0.NXAST_BUNDLE_LOAD)
+class NXActionBundleLoad(NXActionBundleBase):
+    def __init__(self, algorithm, fields, basis, slave_type, n_slaves,
+                 ofs_nbits, dst, slaves):
+        super(NXActionBundleLoad, self).__init__(
+            ofproto_v1_0.NXAST_BUNDLE_LOAD,
+            algorithm, fields, basis, slave_type, n_slaves,
+            ofs_nbits, dst, slaves)
+
+    @classmethod
+    def parser(cls, buf, offset):
+        return NXActionBundleBase.parser(NXActionBundleLoad, buf, offset)
+
+
 class OFPDescStats(collections.namedtuple('OFPDescStats',
         ('mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
     @classmethod
-- 
1.7.4.4


------------------------------------------------------------------------------
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