ofproto: Enqueue improperly resets priority.
authorEthan Jackson <ethan@nicira.com>
Tue, 31 May 2011 23:44:09 +0000 (16:44 -0700)
committerEthan Jackson <ethan@nicira.com>
Wed, 1 Jun 2011 21:18:14 +0000 (14:18 -0700)
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

index c5fe2820dddeb6826200126867257e01f4f5df0a..f632ad0ecafc03e8f7c42bec116ac7bbc3bf7240 100644 (file)
@@ -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 *,
@@ -2885,7 +2886,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) {
@@ -2910,6 +2917,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);
 }
@@ -3012,6 +3020,7 @@ xlate_nicira_action(struct action_xlate_ctx *ctx,
         break;
 
     case NXAST_POP_QUEUE:
+        ctx->priority = 0;
         add_pop_action(ctx);
         break;
 
@@ -3186,6 +3195,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;