ofproto-dpif: Restore optimization for no-actions case (without leak).
authorBen Pfaff <blp@nicira.com>
Tue, 10 Jan 2012 23:34:55 +0000 (15:34 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 16 Jan 2012 20:55:05 +0000 (12:55 -0800)
Commit 968131c1809 (ofproto-dpif: Omit "execute" operation entirely when
there are no actions.) introduced an optimization for the case where a
flow translated to ODP actions had no actions at all (i.e. the packet is
to be dropped).  It also introduced a memory leak (the packet was not
freed).

Commit 999fba59afd (ofproto-dpif: Implement PACKET_IN in userspace.)
inadvertently removed the optimization and as a side effect fixed the
memory leak.

This commit restores the optimization but not the memory leak.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif.c

index 93403ba6eb56d1a759e6b63cae10a1e92b806018..a26981d60d67ac9bf1d783dc47e906ec16e4b04a 100644 (file)
@@ -2548,7 +2548,6 @@ handle_flow_miss(struct ofproto_dpif *ofproto, struct flow_miss *miss,
         struct flow_miss_op *op;
         struct dpif_execute *execute;
 
-        list_remove(&packet->list_node);
         ofproto->n_matches++;
 
         if (facet->rule->up.cr.priority == FAIL_OPEN_PRIORITY) {
@@ -2572,6 +2571,12 @@ handle_flow_miss(struct ofproto_dpif *ofproto, struct flow_miss *miss,
         dpif_flow_stats_extract(&facet->flow, packet, &stats);
         subfacet_update_stats(subfacet, &stats);
 
+        if (!subfacet->actions_len) {
+            /* No actions to execute, so skip talking to the dpif. */
+            continue;
+        }
+
+        list_remove(&packet->list_node);
         if (flow->vlan_tci != subfacet->initial_tci) {
             /* This packet was received on a VLAN splinter port.  We added
              * a VLAN to the packet to make the packet resemble the flow,