This patch makes ofctl_rest enable setting instruction type of
OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <[email protected]>
---
ryu/lib/ofctl_v1_2.py | 22 +++++++++++++++++++---
ryu/lib/ofctl_v1_3.py | 23 ++++++++++++++++++++---
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index 385b5ae..d4bad8b 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -102,7 +102,22 @@ def to_actions(dp, acts):
actions.append(action)
else:
action_type = a.get('type')
- if action_type == 'GOTO_TABLE':
+ if action_type == 'WRITE_ACTIONS':
+ write_actions = []
+ write_acts = a.get('actions')
+ for a in write_acts:
+ action = to_action(dp, a)
+ if action is not None:
+ write_actions.append(action)
+ else:
+ LOG.error('Unknown action type: %s', action_type)
+ if write_actions:
+
inst.append(parser.OFPInstructionActions(ofp.OFPIT_WRITE_ACTIONS,
+ write_actions))
+ elif action_type == 'CLEAR_ACTIONS':
+ inst.append(parser.OFPInstructionActions(
+ ofp.OFPIT_CLEAR_ACTIONS, []))
+ elif action_type == 'GOTO_TABLE':
table_id = int(a.get('table_id'))
inst.append(parser.OFPInstructionGotoTable(table_id))
elif action_type == 'WRITE_METADATA':
@@ -116,8 +131,9 @@ def to_actions(dp, acts):
else:
LOG.error('Unknown action type: %s', action_type)
- inst.append(parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
- actions))
+ if actions:
+ inst.append(parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
+ actions))
return inst
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 037b04a..10c5210 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -103,11 +103,27 @@ def to_actions(dp, acts):
for a in acts:
action = to_action(dp, a)
+
if action is not None:
actions.append(action)
else:
action_type = a.get('type')
- if action_type == 'GOTO_TABLE':
+ if action_type == 'WRITE_ACTIONS':
+ write_actions = []
+ write_acts = a.get('actions')
+ for a in write_acts:
+ action = to_action(dp, a)
+ if action is not None:
+ write_actions.append(action)
+ else:
+ LOG.error('Unknown action type: %s', action_type)
+ if write_actions:
+
inst.append(parser.OFPInstructionActions(ofp.OFPIT_WRITE_ACTIONS,
+ write_actions))
+ elif action_type == 'CLEAR_ACTIONS':
+ inst.append(parser.OFPInstructionActions(
+ ofp.OFPIT_CLEAR_ACTIONS, []))
+ elif action_type == 'GOTO_TABLE':
table_id = int(a.get('table_id'))
inst.append(parser.OFPInstructionGotoTable(table_id))
elif action_type == 'WRITE_METADATA':
@@ -124,8 +140,9 @@ def to_actions(dp, acts):
else:
LOG.error('Unknown action type: %s', action_type)
- inst.append(parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
- actions))
+ if actions:
+ inst.append(parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
+ actions))
return inst
--
1.9.1
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel