From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH] vhost: don't stall if guest is slow Date: Mon, 7 Dec 2015 16:50:21 -0800 Message-ID: <1449535821-12384-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org To: huawei.xie@intel.com, yuanhan.liu@linux.intel.com, nlaw@brocade.com Return-path: Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by dpdk.org (Postfix) with ESMTP id B828D2A1A for ; Tue, 8 Dec 2015 01:50:14 +0100 (CET) Received: by pfbg73 with SMTP id g73so2582624pfb.1 for ; Mon, 07 Dec 2015 16:50:14 -0800 (PST) List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 9322ce6..bbf3fac 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.1.4