[ovs-dev] [xlate 1/2] ofproto: Enqueue improperly resets priority.

Ethan Jackson ethan at nicira.com
Wed Jun 1 18:41:51 UTC 2011


Before this patch, enqueue would reset the priority of a flow to
its original value instead of the value it had immediately before
the enqueue action.

Thus, these openflow actions:
set_queue:2,enqueue:1:1,output:1

Would get translated into these incorrect datapath actions:
set_priority(0x10003),set_priority(0x10002),1,pop_priority,1

Instead of these correct datapath actions:
set_priority(0x10003),set_priority(0x10002),1,set_priority(0x10003),1

A future patch will remove the redundant "set_priority(0x10003)".

Found by inspection.
---
 ofproto/ofproto-dpif.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 2f8d404..66103b6 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -186,6 +186,7 @@ struct action_xlate_ctx {
     int recurse;                /* Recursion level, via xlate_table_action. */
     int last_pop_priority;      /* Offset in 'odp_actions' just past most
                                  * recent ODP_ACTION_ATTR_SET_PRIORITY. */
+    uint32_t priority;          /* Current flow priority. 0 if none. */
 };
 
 static void action_xlate_ctx_init(struct action_xlate_ctx *,
@@ -2870,7 +2871,13 @@ xlate_enqueue_action(struct action_xlate_ctx *ctx,
     remove_pop_action(ctx);
     nl_msg_put_u32(ctx->odp_actions, ODP_ACTION_ATTR_SET_PRIORITY, priority);
     add_output_action(ctx, odp_port);
-    add_pop_action(ctx);
+
+    if (ctx->priority) {
+        nl_msg_put_u32(ctx->odp_actions, ODP_ACTION_ATTR_SET_PRIORITY,
+                       ctx->priority);
+    } else {
+        add_pop_action(ctx);
+    }
 
     /* Update NetFlow output port. */
     if (ctx->nf_output_iface == NF_OUT_DROP) {
@@ -2895,6 +2902,7 @@ xlate_set_queue_action(struct action_xlate_ctx *ctx,
         return;
     }
 
+    ctx->priority = priority;
     remove_pop_action(ctx);
     nl_msg_put_u32(ctx->odp_actions, ODP_ACTION_ATTR_SET_PRIORITY, priority);
 }
@@ -2997,6 +3005,7 @@ xlate_nicira_action(struct action_xlate_ctx *ctx,
         break;
 
     case NXAST_POP_QUEUE:
+        ctx->priority = 0;
         add_pop_action(ctx);
         break;
 
@@ -3171,6 +3180,7 @@ xlate_actions(struct action_xlate_ctx *ctx,
     ctx->nf_output_iface = NF_OUT_DROP;
     ctx->recurse = 0;
     ctx->last_pop_priority = -1;
+    ctx->priority = 0;
 
     if (process_special(ctx->ofproto, &ctx->flow, ctx->packet)) {
         ctx->may_set_up_flow = false;
-- 
1.7.5.2




More information about the dev mailing list