This also fixes a memory leak if an upcall fails

Signed-off-by: Daniele Di Proietto <ddiproie...@vmware.com>
---
 lib/dpif-netdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index a1db620..11aacc3 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2430,10 +2430,6 @@ dp_netdev_upcall(struct dp_netdev *dp, struct 
dpif_packet *packet_,
 {
     struct ofpbuf *packet = &packet_->ofpbuf;
 
-    if (type == DPIF_UC_MISS) {
-        dp_netdev_count_packet(dp, DP_STAT_MISS, 1);
-    }
-
     if (OVS_UNLIKELY(!dp->upcall_cb)) {
         return ENODEV;
     }
@@ -2651,6 +2647,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
     if (OVS_UNLIKELY(any_miss) && !fat_rwlock_tryrdlock(&dp->upcall_rwlock)) {
         uint64_t actions_stub[512 / 8], slow_stub[512 / 8];
         struct ofpbuf actions, put_actions;
+        int miss_cnt = 0, dropped_cnt = 0;
         struct match match;
 
         ofpbuf_use_stub(&actions, actions_stub, sizeof actions_stub);
@@ -2683,8 +2680,11 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
                                       DPIF_UC_MISS, NULL, &actions,
                                       &put_actions);
             if (OVS_UNLIKELY(error && error != ENOSPC)) {
+                dpif_packet_delete(packets[i]);
+                dropped_cnt++;
                 continue;
             }
+            miss_cnt++;
 
             /* We can't allow the packet batching in the next loop to execute
              * the actions.  Otherwise, if there are any slow path actions,
@@ -2715,6 +2715,8 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
         ofpbuf_uninit(&actions);
         ofpbuf_uninit(&put_actions);
         fat_rwlock_unlock(&dp->upcall_rwlock);
+        dp_netdev_count_packet(dp, DP_STAT_MISS, miss_cnt);
+        dp_netdev_count_packet(dp, DP_STAT_LOST, dropped_cnt);
     } else if (OVS_UNLIKELY(any_miss)) {
         int dropped_cnt = 0;
 
-- 
2.1.0.rc1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to