From 98b5ecbf76f0743128b4e0dd69a5481ace5005f6 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 7 Dec 2015 16:50:21 -0800 Subject: [PATCH] vhost: do not stall if guest is slow When guest is booting (or any othertime guest is busy) it is possible for the small receive ring (256) to get full. If this happens the vhost library should just return normally. It's current behavior of logging just creates massive log spew/overflow which could even act as a DoS attack against host. Reported-by: Nathan Law Signed-off-by: Stephen Hemminger Acked-by: Yuanhan Liu --- lib/librte_vhost/vhost_rxtx.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c index 9322ce6e84..bbf3fac178 100644 --- a/lib/librte_vhost/vhost_rxtx.c +++ b/lib/librte_vhost/vhost_rxtx.c @@ -510,17 +510,12 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id, do { avail_idx = *((volatile uint16_t *)&vq->avail->idx); - if (unlikely(res_cur_idx == avail_idx)) { - LOG_DEBUG(VHOST_DATA, - "(%"PRIu64") Failed " - "to get enough desc from " - "vring\n", - dev->device_fh); + if (unlikely(res_cur_idx == avail_idx)) goto merge_rx_exit; - } else { - update_secure_len(vq, res_cur_idx, &secure_len, &vec_idx); - res_cur_idx++; - } + + update_secure_len(vq, res_cur_idx, + &secure_len, &vec_idx); + res_cur_idx++; } while (pkt_len > secure_len); /* vq->last_used_idx_res is atomically updated. */ -- 2.20.1