summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/lib/ofctl_string.py4
-rw-r--r--ryu/ofproto/nicira_ext.py1
-rw-r--r--ryu/ofproto/nx_actions.py38
-rw-r--r--ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct_clear.packetbin0 -> 96 bytes
-rw-r--r--ryu/tests/packet_data_generator3/gen.py7
-rw-r--r--ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_clear.packet.json55
6 files changed, 105 insertions, 0 deletions
diff --git a/ryu/lib/ofctl_string.py b/ryu/lib/ofctl_string.py
index 06a91af2..30394c65 100644
--- a/ryu/lib/ofctl_string.py
+++ b/ryu/lib/ofctl_string.py
@@ -322,3 +322,7 @@ class OfctlActionConverter(object):
'recirc_table': recirc_table,
'alg': alg,
'actions': ct_actions})
+
+ @classmethod
+ def ct_clear(cls, ofproto, action_str):
+ return dict(NXActionCTClear={})
diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py
index 4a06b647..73297cfb 100644
--- a/ryu/ofproto/nicira_ext.py
+++ b/ryu/ofproto/nicira_ext.py
@@ -62,6 +62,7 @@ NXAST_NAT = 36
NXAST_CONTROLLER2 = 37
NXAST_SAMPLE2 = 38
NXAST_OUTPUT_TRUNC = 39
+NXAST_CT_CLEAR = 43
NXAST_DEC_NSH_TTL = 48
NX_ACTION_RESUBMIT_PACK_STR = '!HHIHHB3x'
diff --git a/ryu/ofproto/nx_actions.py b/ryu/ofproto/nx_actions.py
index 18dc9210..ae5c48f4 100644
--- a/ryu/ofproto/nx_actions.py
+++ b/ryu/ofproto/nx_actions.py
@@ -2766,6 +2766,43 @@ def generate(ofp_name, ofpp_name):
a.serialize(data, len(data))
return data
+ class NXActionCTClear(NXAction):
+ """
+ Clear connection tracking state action
+
+ This action clears connection tracking state from packets.
+
+ And equivalent to the followings action of ovs-ofctl command.
+
+ ..
+ ct_clear
+ ..
+
+ +--------------+
+ | **ct_clear** |
+ +--------------+
+
+ Example::
+
+ actions += [parser.NXActionCTClear()]
+ """
+ _subtype = nicira_ext.NXAST_CT_CLEAR
+
+ _fmt_str = '!6x'
+
+ def __init__(self,
+ type_=None, len_=None, experimenter=None, subtype=None):
+ super(NXActionCTClear, self).__init__()
+
+ @classmethod
+ def parser(cls, buf):
+ return cls()
+
+ def serialize_body(self):
+ data = bytearray()
+ msg_pack_into(self._fmt_str, data, 0)
+ return data
+
class NXActionNAT(NXAction):
"""
Network address translation action
@@ -3061,6 +3098,7 @@ def generate(ofp_name, ofpp_name):
'NXActionBundle',
'NXActionBundleLoad',
'NXActionCT',
+ 'NXActionCTClear',
'NXActionNAT',
'NXActionOutputTrunc',
'_NXFlowSpec', # exported for testing
diff --git a/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct_clear.packet b/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct_clear.packet
new file mode 100644
index 00000000..13bc3901
--- /dev/null
+++ b/ryu/tests/packet_data/of13/ovs-ofctl-of13-action_ct_clear.packet
Binary files differ
diff --git a/ryu/tests/packet_data_generator3/gen.py b/ryu/tests/packet_data_generator3/gen.py
index 0216dc42..dca45cf9 100644
--- a/ryu/tests/packet_data_generator3/gen.py
+++ b/ryu/tests/packet_data_generator3/gen.py
@@ -131,6 +131,13 @@ MESSAGES = [
'importance=39032'] +
['dl_type=0x86dd'] +
['actions=ct(commit,nat(dst=2001:1::1-2001:1::ffff)'])},
+ {'name': 'action_ct_clear',
+ 'versions': [4],
+ 'cmd': 'add-flow',
+ 'args': (['table=3,',
+ 'importance=39032'] +
+ ['dl_type=0x0800,ct_state=+trk'] +
+ ['actions=ct_clear'])},
{'name': 'action_note',
'versions': [4],
'cmd': 'add-flow',
diff --git a/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_clear.packet.json b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_clear.packet.json
new file mode 100644
index 00000000..32b88b72
--- /dev/null
+++ b/ryu/tests/unit/ofproto/json/of13/ovs-ofctl-of13-action_ct_clear.packet.json
@@ -0,0 +1,55 @@
+{
+ "OFPFlowMod": {
+ "buffer_id": 4294967295,
+ "command": 0,
+ "cookie": 0,
+ "cookie_mask": 0,
+ "flags": 0,
+ "hard_timeout": 0,
+ "idle_timeout": 0,
+ "instructions": [
+ {
+ "OFPInstructionActions": {
+ "actions": [
+ {
+ "NXActionCTClear": {
+ "experimenter": 8992,
+ "len": 16,
+ "subtype": 43,
+ "type": 65535
+ }
+ }
+ ],
+ "len": 24,
+ "type": 4
+ }
+ }
+ ],
+ "match": {
+ "OFPMatch": {
+ "length": 22,
+ "oxm_fields": [
+ {
+ "OXMTlv": {
+ "field": "eth_type",
+ "mask": null,
+ "value": 2048
+ }
+ },
+ {
+ "OXMTlv": {
+ "field": "ct_state",
+ "mask": 32,
+ "value": 32
+ }
+ }
+ ],
+ "type": 1
+ }
+ },
+ "out_group": 4294967295,
+ "out_port": 4294967295,
+ "priority": 32768,
+ "table_id": 3
+ }
+}