Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
---
v2
- changed for ofp_instruction
---
 lib/ofp-actions.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 2b0476e..0122594 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -809,6 +809,17 @@ ofpacts_pull_openflow11_actions(struct ofpbuf *openflow,
                                 ofpacts_from_openflow11);
 }
 
+static enum ofperr
+ofpacts_pull_openflow11_inst_actions(const struct ofp11_instruction *inst,
+                                     struct ofpbuf *ofpacts)
+{
+    const union ofp_action *actions;
+    size_t n_actions;
+
+    get_actions_from_instruction(inst, &actions, &n_actions);
+    return ofpacts_from_openflow11(actions, n_actions, ofpacts);
+}
+
 enum ofperr
 ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
                                      unsigned int instructions_len,
@@ -846,16 +857,47 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf 
*openflow,
     }
 
     if (insts[OVSINST_OFPIT11_APPLY_ACTIONS]) {
-        const union ofp_action *actions;
-        size_t n_actions;
+        if (insts[OVSINST_OFPIT11_GOTO_TABLE] ||
+            insts[OVSINST_OFPIT11_WRITE_METADATA] ||
+            insts[OVSINST_OFPIT11_WRITE_ACTIONS] ||
+            insts[OVSINST_OFPIT11_CLEAR_ACTIONS]) {
+            /* Tell early that instruction is really necessary and
+             * it's incompatible with OF1.0.
+             */
+            ofpact_put_instruction(ofpacts, OVSINST_OFPIT11_APPLY_ACTIONS);
+        }
 
-        get_actions_from_instruction(insts[OVSINST_OFPIT11_APPLY_ACTIONS],
-                                     &actions, &n_actions);
-        error = ofpacts_from_openflow11(actions, n_actions, ofpacts);
+        error = ofpacts_pull_openflow11_inst_actions(
+            insts[OVSINST_OFPIT11_APPLY_ACTIONS], ofpacts);
         if (error) {
             goto exit;
         }
     }
+    if (insts[OVSINST_OFPIT11_CLEAR_ACTIONS]) {
+        ofpact_put_instruction(ofpacts, OVSINST_OFPIT11_CLEAR_ACTIONS);
+    }
+    if (insts[OVSINST_OFPIT11_WRITE_ACTIONS]) {
+        ofpact_put_instruction(ofpacts, OVSINST_OFPIT11_WRITE_ACTIONS);
+
+        error = ofpacts_pull_openflow11_inst_actions(
+            insts[OVSINST_OFPIT11_WRITE_ACTIONS], ofpacts);
+        if (error) {
+            goto exit;
+        }
+    }
+    /* TODO:XXX Write-Metadata */
+    if (insts[OVSINST_OFPIT11_GOTO_TABLE]) {
+        struct ofp11_instruction_goto_table *oigt;
+        struct ofpact_resubmit *resubmit;
+
+        ofpact_put_instruction(ofpacts, OVSINST_OFPIT11_GOTO_TABLE);
+        oigt = (struct ofp11_instruction_goto_table *)
+            insts[OVSINST_OFPIT11_GOTO_TABLE];
+        resubmit = ofpact_put_RESUBMIT(ofpacts);
+        resubmit->ofpact.compat = -1; /* TODO:XXX instruction */
+        resubmit->in_port = OFPP_IN_PORT;
+        resubmit->table_id = oigt->table_id;
+    }
 
     if (insts[OVSINST_OFPIT11_GOTO_TABLE] ||
         insts[OVSINST_OFPIT11_WRITE_METADATA] ||
-- 
1.7.1.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to