summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorShinpei Muraoka <shinpei.muraoka@gmail.com>2016-07-27 11:35:56 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-27 19:46:04 +0900
commit4ca81f962483896c5a73f8d0bcf4d56e85b9a583 (patch)
treee9cba0271b92558540a10549a8b4760e06d4411c
parent64ba9f1cdcd9314522254fb749c22fa6bcfd63dd (diff)
ofproto/nx_actions: Update argument of NXActionCT
Since zone_src in NXActionCT was not possible to specify string, update zone_src of NXActionCT for the uniformity. Therefore, you will be able to specify string of OXM/NXM fields for zone_src. If you want to set the immediate value for zone, zone_src set the None or empty character string. Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/nx_actions.py41
-rw-r--r--ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct.packetbin104 -> 104 bytes
-rw-r--r--ryu/tests/packet_data_generator3/gen.py2
-rw-r--r--ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct.packet.json4
-rw-r--r--ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_exec.packet.json2
-rw-r--r--ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat.packet.json2
-rw-r--r--ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat_v6.packet.json2
7 files changed, 41 insertions, 12 deletions
diff --git a/ryu/ofproto/nx_actions.py b/ryu/ofproto/nx_actions.py
index 8251521d..89210070 100644
--- a/ryu/ofproto/nx_actions.py
+++ b/ryu/ofproto/nx_actions.py
@@ -2665,20 +2665,25 @@ def generate(ofp_name, ofpp_name):
zone_ofs_nbits Start and End for the OXM/NXM field.
Setting method refer to the ``nicira_ext.ofs_nbits``.
If you need set the Immediate value for zone,
- zone_src must be set to zero.
+ zone_src must be set to None or empty character string.
recirc_table Recirculate to a specific table
alg Well-known port number for the protocol
actions Zero or more actions may immediately follow this
action
================ ======================================================
+ .. NOTE::
+
+ If you set number to zone_src,
+ Traceback occurs when you run the to_jsondict.
+
Example::
match = parser.OFPMatch(eth_type=0x0800, ct_state=(0,32))
actions += [parser.NXActionCT(
flags = 1,
- zone_src = 0,
- zone_ofs_nbits = 0,
+ zone_src = "reg0",
+ zone_ofs_nbits = nicira_ext.ofs_nbits(4, 31),
recirc_table = 4,
alg = 0,
actions = [])]
@@ -2687,7 +2692,13 @@ def generate(ofp_name, ofpp_name):
# flags, zone_src, zone_ofs_nbits, recirc_table,
# pad, alg
- _fmt_str = '!HIHB3xH'
+ _fmt_str = '!H4sHB3xH'
+ _TYPE = {
+ 'ascii': [
+ 'zone_src',
+ ]
+ }
+
# Followed by actions
def __init__(self,
@@ -2709,12 +2720,20 @@ def generate(ofp_name, ofpp_name):
@classmethod
def parser(cls, buf):
(flags,
- zone_src,
+ oxm_data,
zone_ofs_nbits,
recirc_table,
alg,) = struct.unpack_from(
cls._fmt_str, buf, 0)
rest = buf[struct.calcsize(cls._fmt_str):]
+
+ # OXM/NXM field
+ if oxm_data == b'\x00' * 4:
+ zone_src = ""
+ else:
+ (n, len_) = ofp.oxm_parse_header(oxm_data, 0)
+ zone_src = ofp.oxm_to_user_header(n)
+
# actions
actions = []
while len(rest) > 0:
@@ -2727,9 +2746,19 @@ def generate(ofp_name, ofpp_name):
def serialize_body(self):
data = bytearray()
+ # If zone_src is zero, zone_ofs_nbits is zone_imm
+ if not self.zone_src:
+ zone_src = b'\x00' * 4
+ elif isinstance(self.zone_src, six.integer_types):
+ zone_src = struct.pack("!I", self.zone_src)
+ else:
+ zone_src = bytearray()
+ oxm = ofp.oxm_from_user_header(self.zone_src)
+ ofp.oxm_serialize_header(oxm, zone_src, 0)
+
msg_pack_into(self._fmt_str, data, 0,
self.flags,
- self.zone_src,
+ six.binary_type(zone_src),
self.zone_ofs_nbits,
self.recirc_table,
self.alg)
diff --git a/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct.packet b/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct.packet
index 3aff2bdc..5eb733f9 100644
--- a/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct.packet
+++ b/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct.packet
Binary files differ
diff --git a/ryu/tests/packet_data_generator3/gen.py b/ryu/tests/packet_data_generator3/gen.py
index 65f91a72..92676e46 100644
--- a/ryu/tests/packet_data_generator3/gen.py
+++ b/ryu/tests/packet_data_generator3/gen.py
@@ -108,7 +108,7 @@ MESSAGES = [
'args': (['table=3,',
'importance=39032'] +
['dl_type=0x0800,ct_state=-trk'] +
- ['actions=ct(table=4)'])},
+ ['actions=ct(table=4,zone=NXM_NX_REG0[4..31])'])},
{'name': 'action_ct_exec',
'versions': [4],
'cmd': 'add-flow',
diff --git a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct.packet.json b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct.packet.json
index 0cd1e20e..b1157e9a 100644
--- a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct.packet.json
@@ -21,8 +21,8 @@
"recirc_table": 4,
"subtype": 35,
"type": 65535,
- "zone_ofs_nbits": 0,
- "zone_src": 0
+ "zone_ofs_nbits": 283,
+ "zone_src": "reg0"
}
}
],
diff --git a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_exec.packet.json b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_exec.packet.json
index a163abaf..e3fcd3bc 100644
--- a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_exec.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_exec.packet.json
@@ -36,7 +36,7 @@
"subtype": 35,
"type": 65535,
"zone_ofs_nbits": 0,
- "zone_src": 0
+ "zone_src": ""
}
}
],
diff --git a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat.packet.json b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat.packet.json
index ef6a7d94..5a38d8f7 100644
--- a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat.packet.json
@@ -38,7 +38,7 @@
"subtype": 35,
"type": 65535,
"zone_ofs_nbits": 0,
- "zone_src": 0
+ "zone_src": ""
}
}
],
diff --git a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat_v6.packet.json b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat_v6.packet.json
index cca46254..5c1c8c07 100644
--- a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat_v6.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_nat_v6.packet.json
@@ -38,7 +38,7 @@
"subtype": 35,
"type": 65535,
"zone_ofs_nbits": 0,
- "zone_src": 0
+ "zone_src": ""
}
}
],