[ovs-dev] [PATCH v3 04/12] ofp-action: introduce actions corresponding to intruction.

Isaku Yamahata yamahata at valinux.co.jp
Mon Jul 23 08:08:43 UTC 2012


Those actions correspond to instructions, Clear-Actions, Write-Actions and
Goto-Table.
Since Write-Metadata is addressed by other patch series, so it isn't
introduced.

Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>

---
v3:
- introduce OFPACT_{CLEAR_ACTIONS, WRITE_ACTIONS, GOTO_TABLE}

v2
- changed for ofp_instruction

Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>
---
 lib/ofp-actions.c      |   41 +++++++++++++++++++++++++++++++++++++++++
 lib/ofp-actions.h      |   30 +++++++++++++++++++++++++++---
 ofproto/ofproto-dpif.c |   12 ++++++++++++
 3 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 122066c..ace51bb 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -938,6 +938,11 @@ ofpact_check__(const struct ofpact *a, const struct flow *flow, int max_ports)
     case OFPACT_EXIT:
         return 0;
 
+    case OFPACT_CLEAR_ACTIONS:
+    case OFPACT_WRITE_ACTIONS:
+    case OFPACT_GOTO_TABLE:
+        return 0;
+
     default:
         NOT_REACHED();
     }
@@ -1130,6 +1135,9 @@ ofpact_to_nxast(const struct ofpact *a, struct ofpbuf *out)
     case OFPACT_SET_IPV4_DSCP:
     case OFPACT_SET_L4_SRC_PORT:
     case OFPACT_SET_L4_DST_PORT:
+    case OFPACT_CLEAR_ACTIONS:
+    case OFPACT_WRITE_ACTIONS:
+    case OFPACT_GOTO_TABLE:
         NOT_REACHED();
     }
 }
@@ -1219,6 +1227,12 @@ ofpact_to_openflow10(const struct ofpact *a, struct ofpbuf *out)
             = htons(ofpact_get_SET_L4_DST_PORT(a)->port);
         break;
 
+    case OFPACT_CLEAR_ACTIONS:
+    case OFPACT_WRITE_ACTIONS:
+    case OFPACT_GOTO_TABLE:
+        NOT_REACHED();  /* TODO:XXX return error */
+        break;
+
     case OFPACT_CONTROLLER:
     case OFPACT_OUTPUT_REG:
     case OFPACT_BUNDLE:
@@ -1327,6 +1341,18 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out)
             = htons(ofpact_get_SET_L4_DST_PORT(a)->port);
         break;
 
+    case OFPACT_CLEAR_ACTIONS:
+        NOT_REACHED();  /* TODO:XXX */
+        break;
+
+    case OFPACT_WRITE_ACTIONS:
+        NOT_REACHED();  /* TODO:XXX */
+        break;
+
+    case OFPACT_GOTO_TABLE:
+        NOT_REACHED();  /* TODO:XXX */
+        break;
+
     case OFPACT_CONTROLLER:
     case OFPACT_OUTPUT_REG:
     case OFPACT_BUNDLE:
@@ -1421,6 +1447,9 @@ ofpact_outputs_to_port(const struct ofpact *ofpact, uint16_t port)
     case OFPACT_AUTOPATH:
     case OFPACT_NOTE:
     case OFPACT_EXIT:
+    case OFPACT_CLEAR_ACTIONS:
+    case OFPACT_WRITE_ACTIONS:
+    case OFPACT_GOTO_TABLE:
     default:
         return false;
     }
@@ -1665,6 +1694,18 @@ ofpact_format(const struct ofpact *a, struct ds *s)
     case OFPACT_EXIT:
         ds_put_cstr(s, "exit");
         break;
+
+    case OFPACT_CLEAR_ACTIONS:
+        NOT_REACHED();  /* TODO:XXX */
+        break;
+
+    case OFPACT_WRITE_ACTIONS:
+        NOT_REACHED();  /* TODO:XXX */
+        break;
+
+    case OFPACT_GOTO_TABLE:
+        NOT_REACHED();  /* TODO:XXX */
+        break;
     }
 }
 
diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h
index 624dba2..5734da9 100644
--- a/lib/ofp-actions.h
+++ b/lib/ofp-actions.h
@@ -87,7 +87,12 @@
                                                                     \
     /* Other. */                                                    \
     DEFINE_OFPACT(NOTE,            ofpact_note,          data)      \
-    DEFINE_OFPACT(EXIT,            ofpact_null,          ofpact)
+    DEFINE_OFPACT(EXIT,            ofpact_null,          ofpact)    \
+                                                                    \
+    /* Instructions */                                              \
+    DEFINE_OFPACT(CLEAR_ACTIONS,   ofpact_null,          ofpact)    \
+    DEFINE_OFPACT(WRITE_ACTIONS,   ofpact_null,          ofpact)    \
+    DEFINE_OFPACT(GOTO_TABLE,      ofpact_goto_table,    ofpact)
 
 /* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
 enum OVS_PACKED_ENUM ofpact_type {
@@ -145,9 +150,11 @@ ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
 
 /* Action structure for each OFPACT_*. */
 
-/* OFPACT_STRIP_VLAN, OFPACT_DEC_TTL, OFPACT_POP_QUEUE, OFPACT_EXIT.
+/* OFPACT_STRIP_VLAN, OFPACT_DEC_TTL, OFPACT_POP_QUEUE, OFPACT_EXIT,
+ * OFPACT_CLEAR_ACTIONS, OFPACT_WRITE_ACTIONS.
  *
- * Used for OFPAT10_STRIP_VLAN, NXAST_DEC_TTL, NXAST_POP_QUEUE, NXAST_EXIT.
+ * Used for OFPAT10_STRIP_VLAN, NXAST_DEC_TTL, NXAST_POP_QUEUE, NXAST_EXIT,
+ * OFPIT11_CLEAR_ACTIONS, OFPIT11_WRITE_ACTIONS.
  *
  * Action structure for actions that do not have any extra data beyond the
  * action type. */
@@ -380,6 +387,14 @@ struct ofpact_note {
     uint8_t data[];
 };
 
+/* OFPACT_GOTO_TABLE
+ *
+ * Used for OFPIT11_GOTO_TABLE */
+struct ofpact_goto_table {
+    struct ofpact ofpact;
+    uint8_t table_id;
+};
+
 /* Converting OpenFlow to ofpacts. */
 enum ofperr ofpacts_pull_openflow10(struct ofpbuf *openflow,
                                     unsigned int actions_len,
@@ -529,4 +544,13 @@ enum {
 #undef DEFINE_INST
 };
 
+static inline bool
+ofpact_is_instruction(const struct ofpact *a)
+{
+    return a->type == OFPACT_CLEAR_ACTIONS
+        || a->type == OFPACT_WRITE_ACTIONS
+        /* TODO:XXX Write-Metadata */
+        || a->type == OFPACT_GOTO_TABLE;
+}
+
 #endif /* ofp-actions.h */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index dc15c15..8a63a44 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5539,6 +5539,18 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             ctx->has_fin_timeout = true;
             xlate_fin_timeout(ctx, ofpact_get_FIN_TIMEOUT(a));
             break;
+
+        case OFPACT_CLEAR_ACTIONS:
+            NOT_REACHED();  /* TODO:XXX */
+            break;
+
+        case OFPACT_WRITE_ACTIONS:
+            NOT_REACHED();  /* TODO:XXX */
+            break;
+
+        case OFPACT_GOTO_TABLE:
+            NOT_REACHED();  /* TODO:XXX */
+            break;
         }
     }
 
-- 
1.7.1.1




More information about the dev mailing list