memif: Revert "memif buffer leaks during disconnect." 00/22700/2
authorAndrew Yourtchenko <ayourtch@gmail.com>
Mon, 14 Oct 2019 10:55:31 +0000 (10:55 +0000)
committerDamjan Marion <dmarion@me.com>
Mon, 14 Oct 2019 22:44:03 +0000 (22:44 +0000)
This reverts commit d570c4d18df404cb59ef72d20d56f8e31418c8e9.
That commit introduced crash into memif make test-debug.
To reproduce: "TEST=memif make test-debug".

With this commit reverted the make test-debug for memif passes.

Type: fix
Change-Id: Ic335359e2050bb8a5d530b01c595b081476fa197
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
src/plugins/memif/memif.c

index c216a16..c2df8d3 100644 (file)
@@ -70,7 +70,6 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
 {
   memif_main_t *mm = &memif_main;
   vnet_main_t *vnm = vnet_get_main ();
-  vlib_main_t *vm = vlib_get_main ();
   memif_region_t *mr;
   memif_queue_t *mq;
   int i;
@@ -127,19 +126,7 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
            memif_log_warn (mif,
                           "Unable to unassign interface %d, queue %d: rc=%d",
                           mif->hw_if_index, i, rv);
-         if (mif->flags & MEMIF_IF_FLAG_ZERO_COPY)
-            {
-
-              u16 cur_slot,last_slot, start;
-              u16 ring_size = 1 << mq->log2_ring_size;
-              u16 mask = ring_size - 1;
-              cur_slot =  mq->last_tail;
-              last_slot = mq->ring->head - 1 ;
-              start = (mq->last_tail & mask);
-              u16 n_slots = ((last_slot - cur_slot) & mask) + 1;
-              vlib_buffer_free_from_ring(vm,mq->buffers,start,ring_size,n_slots);
-            }
-          mq->ring = 0;
+         mq->ring = 0;
        }
     }
 
@@ -149,28 +136,7 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
   vec_free (mif->rx_queues);
 
   vec_foreach (mq, mif->tx_queues)
-    {
-      if (mif->flags & MEMIF_IF_FLAG_ZERO_COPY)
-        {
-          memif_ring_t *ring = mq->ring;
-          u16 cur_slot,last_slot, start;
-          u16 ring_size = 1 << mq->log2_ring_size;
-          u16 mask = ring_size - 1;
-          u16 n_slots = ring->tail - mq->last_tail;
-          cur_slot =  mq->last_tail;
-          last_slot = mq->ring->head;
-          start = (mq->last_tail & mask);
-          if(last_slot > cur_slot)
-             n_slots = n_slots + ((last_slot - cur_slot)) ;
-          else if (last_slot < cur_slot)
-             n_slots = n_slots + (cur_slot - last_slot);
-          vlib_buffer_free_from_ring_no_next (vm, mq->buffers,
-                      start,
-                      ring_size, n_slots);
-        }
-      memif_queue_intfd_close (mq);
-    }
-
+    memif_queue_intfd_close (mq);
   vec_free (mif->tx_queues);
 
   /* free memory regions */