avf: may crash if failed to allocate buffers to ring 03/15003/3
authorSteven <sluong@cisco.com>
Wed, 26 Sep 2018 17:56:46 +0000 (10:56 -0700)
committerDamjan Marion <dmarion@me.com>
Thu, 27 Sep 2018 12:10:50 +0000 (12:10 +0000)
commit258c2f6c6339d5261d3b4edc9197cbbf9157378e
tree1ead841271e34a457aa684a261ca18b5179a3e05
parentbaf740512aa6f3e8c81484b5e914b77200db21d9
avf: may crash if failed to allocate buffers to ring

In avf_rxq_refill, we invoke vlib_buffer_alloc_to_ring which may fill buffers from the
end of the ring and continue to the beginning of the ring. If we fill some in the end and
continue to fill some in the beginning, but does not have enough buffers to fill the
whole request, n_alloc returns a value which is not equal to n_refill to indicate partial
refill. We don't like partial refill and invoke vlib_buffer_free to get rid of
the buffers that just got refilled. However, vlib_buffer_free API is to free the buffers
from the slot continuously. It does not know how to free some from rxq->bufs[slot], and then
continue to free the rest when it reaches the end of the ring.

The fix is to use vlib_buffer_free_from_ring which is smart enough to figure that stuff
out.

Change-Id: I93c28e0b0d8d8f22c321d1a5912e00c27b4e2e8d
Signed-off-by: Steven <sluong@cisco.com>
src/plugins/avf/input.c