Skip to content

Commit

Permalink
ofproto: add Nicira extension ct_clear action
Browse files Browse the repository at this point in the history
Signed-off-by: IWAMOTO Toshihiro <[email protected]>
Signed-off-by: FUJITA Tomonori <[email protected]>
  • Loading branch information
toshiiw authored and fujita committed Mar 28, 2018
1 parent 4e10ba4 commit b8ebdbe
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ryu/lib/ofctl_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,7 @@ def ct(cls, ofproto, action_str):
'recirc_table': recirc_table,
'alg': alg,
'actions': ct_actions})

@classmethod
def ct_clear(cls, ofproto, action_str):
return dict(NXActionCTClear={})
1 change: 1 addition & 0 deletions ryu/ofproto/nicira_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
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'
Expand Down
38 changes: 38 additions & 0 deletions ryu/ofproto/nx_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,43 @@ def serialize_body(self):
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
Expand Down Expand Up @@ -3061,6 +3098,7 @@ def add_attr(k, v):
'NXActionBundle',
'NXActionBundleLoad',
'NXActionCT',
'NXActionCTClear',
'NXActionNAT',
'NXActionOutputTrunc',
'_NXFlowSpec', # exported for testing
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions ryu/tests/packet_data_generator3/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@
'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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit b8ebdbe

Please sign in to comment.