summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMinoru TAKAHASHI <takahashi.minoru7@gmail.com>2015-09-08 09:14:07 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-10 11:20:49 +0900
commit91af6a5ada5ea39ee98ad0d89d02146e3afc2d46 (patch)
tree84d88c1769899b2fc51187b26270923c683b8735
parentb6e280172a0f4204d6e558d1c11eeacdfb9ff8ab (diff)
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
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 <takahashi.minoru7@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/ofctl_v1_2.py22
-rw-r--r--ryu/lib/ofctl_v1_3.py23
2 files changed, 39 insertions, 6 deletions
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index 385b5ae3..d4bad8b8 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 037b04ad..10c52101 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