dpif-netdev: delete lost packets in dp_execute_cb()
authorDaniele Di Proietto <ddiproietto@vmware.com>
Wed, 25 Jun 2014 18:39:34 +0000 (11:39 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Wed, 25 Jun 2014 21:35:50 +0000 (14:35 -0700)
This commit fixes memory leaks in dp_execute_cb() in two cases:
    - when the output port cannot be found
    - when the recirculation depth is exceeded

Reported-by: Pravin Shelar <pshelar@nicira.com>
Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
lib/dpif-netdev.c

index f490900..fce2650 100644 (file)
@@ -2231,8 +2231,12 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
     switch ((enum ovs_action_attr)type) {
     case OVS_ACTION_ATTR_OUTPUT:
         p = dp_netdev_lookup_port(aux->dp, u32_to_odp(nl_attr_get_u32(a)));
-        if (p) {
+        if (OVS_LIKELY(p)) {
             netdev_send(p->netdev, packets, cnt, may_steal);
+        } else if (may_steal) {
+            for (i = 0; i < cnt; i++) {
+                dpif_packet_delete(packets[i]);
+            }
         }
         break;
 
@@ -2321,6 +2325,11 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
             break;
         } else {
             VLOG_WARN("Packet dropped. Max recirculation depth exceeded.");
+            if (may_steal) {
+                for (i = 0; i < cnt; i++) {
+                    dpif_packet_delete(packets[i]);
+                }
+            }
         }
         break;