From 6f03286739833299d722122e4a4c362d841a25f0 Mon Sep 17 00:00:00 2001 From: vmaffione Date: Mon, 1 Jun 2020 16:14:29 +0000 Subject: [PATCH] netmap: if_vtnet: avoid netmap ring wraparound netmap assumes the one "slot" is left unused to distinguish the empty ring and full ring conditions. This assumption was violated by vtnet_netmap_rxq_populate(). MFC after: 1 week --- sys/dev/netmap/if_vtnet_netmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/netmap/if_vtnet_netmap.h b/sys/dev/netmap/if_vtnet_netmap.h index 7086ef2fce4c..4e01c663ef6b 100644 --- a/sys/dev/netmap/if_vtnet_netmap.h +++ b/sys/dev/netmap/if_vtnet_netmap.h @@ -275,8 +275,8 @@ vtnet_netmap_rxq_populate(struct vtnet_rxq *rxq) /* Expose all the RX netmap buffers we can. In case of no indirect * buffers, the number of netmap slots in the RX ring matches the * maximum number of 2-elements sglist that the RX virtqueue can - * accommodate. */ - error = vtnet_netmap_kring_refill(kring, na->num_rx_desc); + * accommodate (minus 1 to avoid netmap ring wraparound). */ + error = vtnet_netmap_kring_refill(kring, na->num_rx_desc - 1); virtqueue_notify(rxq->vtnrx_vq); return error < 0 ? ENXIO : 0;