[ovs-dev] [PATCH v2 18/21] actions: Allow caller to specify output table.

Ben Pfaff blp at nicira.com
Tue Jul 28 15:44:36 UTC 2015


When an upcoming commit divides the pipeline up into ingress and egress
pipeline, it will become necessary to resubmit to different tables from
each of those pipelines to implement output.  This commit makes that
possible.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 ovn/controller/rule.c |  2 +-
 ovn/lib/actions.c     | 16 +++++++++++-----
 ovn/lib/actions.h     |  6 ++++--
 tests/test-ovn.c      |  2 +-
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/ovn/controller/rule.c b/ovn/controller/rule.c
index 0f5971b..c7281a0 100644
--- a/ovn/controller/rule.c
+++ b/ovn/controller/rule.c
@@ -283,7 +283,7 @@ rule_run(struct controller_ctx *ctx, struct hmap *flow_table)
         ofpbuf_use_stub(&ofpacts, ofpacts_stub, sizeof ofpacts_stub);
         next_table_id = rule->table_id < 31 ? rule->table_id + 17 : 0;
         error = actions_parse_string(rule->actions, &symtab, &ldp->ports,
-                                     next_table_id, &ofpacts, &prereqs);
+                                     next_table_id, 64, &ofpacts, &prereqs);
         if (error) {
             static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
             VLOG_WARN_RL(&rl, "error parsing actions \"%s\": %s",
diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c
index 0aabdcf..e15c7f8 100644
--- a/ovn/lib/actions.c
+++ b/ovn/lib/actions.c
@@ -31,6 +31,7 @@ struct action_context {
     struct lexer *lexer;        /* Lexer for pulling more tokens. */
     const struct shash *symtab; /* Symbol table. */
     uint8_t next_table_id;      /* OpenFlow table for 'next' to resubmit. */
+    uint8_t output_table_id;    /* OpenFlow table for 'output' to resubmit. */
     const struct simap *ports;  /* Map from port name to number. */
 
     /* State. */
@@ -161,8 +162,7 @@ parse_actions(struct action_context *ctx)
                 action_error(ctx, "\"next\" action not allowed here.");
             }
         } else if (lexer_match_id(ctx->lexer, "output")) {
-            /* Table 64 does logical-to-physical translation. */
-            emit_resubmit(ctx, 64);
+            emit_resubmit(ctx, ctx->output_table_id);
         } else {
             action_syntax_error(ctx, "expecting action");
         }
@@ -189,6 +189,9 @@ parse_actions(struct action_context *ctx)
  * 'next_table_id' should be the OpenFlow table to which the "next" action will
  * resubmit, or 0 to disable "next".
  *
+ * 'output_table_id' should be the OpenFlow table to which the "output" action
+ * will resubmit
+ *
  * Some actions add extra requirements (prerequisites) to the flow's match.  If
  * so, this function sets '*prereqsp' to the actions' prerequisites; otherwise,
  * it sets '*prereqsp' to NULL.  The caller owns '*prereqsp' and must
@@ -202,7 +205,8 @@ parse_actions(struct action_context *ctx)
 char * OVS_WARN_UNUSED_RESULT
 actions_parse(struct lexer *lexer, const struct shash *symtab,
               const struct simap *ports, uint8_t next_table_id,
-              struct ofpbuf *ofpacts, struct expr **prereqsp)
+              uint8_t output_table_id, struct ofpbuf *ofpacts,
+              struct expr **prereqsp)
 {
     size_t ofpacts_start = ofpacts->size;
 
@@ -211,6 +215,7 @@ actions_parse(struct lexer *lexer, const struct shash *symtab,
     ctx.symtab = symtab;
     ctx.ports = ports;
     ctx.next_table_id = next_table_id;
+    ctx.output_table_id = output_table_id;
     ctx.error = NULL;
     ctx.ofpacts = ofpacts;
     ctx.prereqs = NULL;
@@ -232,7 +237,8 @@ actions_parse(struct lexer *lexer, const struct shash *symtab,
 char * OVS_WARN_UNUSED_RESULT
 actions_parse_string(const char *s, const struct shash *symtab,
                      const struct simap *ports, uint8_t next_table_id,
-                     struct ofpbuf *ofpacts, struct expr **prereqsp)
+                     uint8_t output_table_id, struct ofpbuf *ofpacts,
+                     struct expr **prereqsp)
 {
     struct lexer lexer;
     char *error;
@@ -240,7 +246,7 @@ actions_parse_string(const char *s, const struct shash *symtab,
     lexer_init(&lexer, s);
     lexer_get(&lexer);
     error = actions_parse(&lexer, symtab, ports, next_table_id,
-                          ofpacts, prereqsp);
+                          output_table_id, ofpacts, prereqsp);
     lexer_destroy(&lexer);
 
     return error;
diff --git a/ovn/lib/actions.h b/ovn/lib/actions.h
index b442061..74cd185 100644
--- a/ovn/lib/actions.h
+++ b/ovn/lib/actions.h
@@ -28,11 +28,13 @@ struct simap;
 
 char *actions_parse(struct lexer *, const struct shash *symtab,
                     const struct simap *ports, uint8_t next_table_id,
-                    struct ofpbuf *ofpacts, struct expr **prereqsp)
+                    uint8_t output_table_id, struct ofpbuf *ofpacts,
+                    struct expr **prereqsp)
     OVS_WARN_UNUSED_RESULT;
 char *actions_parse_string(const char *s, const struct shash *symtab,
                            const struct simap *ports, uint8_t next_table_id,
-                           struct ofpbuf *ofpacts, struct expr **prereqsp)
+                           uint8_t output_table_id, struct ofpbuf *ofpacts,
+                           struct expr **prereqsp)
     OVS_WARN_UNUSED_RESULT;
 
 #endif /* ovn/actions.h */
diff --git a/tests/test-ovn.c b/tests/test-ovn.c
index f57a4ec..60b87de 100644
--- a/tests/test-ovn.c
+++ b/tests/test-ovn.c
@@ -1138,7 +1138,7 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)
         char *error;
 
         ofpbuf_init(&ofpacts, 0);
-        error = actions_parse_string(ds_cstr(&input), &symtab, &ports, 11,
+        error = actions_parse_string(ds_cstr(&input), &symtab, &ports, 11, 64,
                                      &ofpacts, &prereqs);
         if (!error) {
             struct ds output;
-- 
2.1.3




More information about the dev mailing list