DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wang, Zhihong" <zhihong.wang@intel.com>
To: "Bie, Tiwei" <tiwei.bie@intel.com>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Wang, Yinan" <yinan.wang@intel.com>, "Yao, Lei A" <lei.a.yao@intel.com>
Subject: Re: [dpdk-dev] [PATCH] vhost: fix buffer length calculation
Date: Wed, 18 Jul 2018 10:47:39 +0000	[thread overview]
Message-ID: <8F6C2BD409508844A0EFC19955BE094151566EEE@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20180717131035.15635-1-tiwei.bie@intel.com>



> -----Original Message-----
> From: Bie, Tiwei
> Sent: Tuesday, July 17, 2018 9:11 PM
> To: maxime.coquelin@redhat.com; Wang, Zhihong
> <zhihong.wang@intel.com>; dev@dpdk.org
> Cc: Wang, Yinan <yinan.wang@intel.com>; Yao, Lei A <lei.a.yao@intel.com>
> Subject: [PATCH] vhost: fix buffer length calculation
> 
> Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>  lib/librte_vhost/virtio_net.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 2b7ffcf92..07cc0c845 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -720,7 +720,8 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  				uint16_t hdr_vec_idx = 0;
> 
>  				while (remain) {
> -					len = remain;
> +					len = RTE_MIN(remain,
> +
> 	buf_vec[hdr_vec_idx].buf_len);
>  					dst = buf_vec[hdr_vec_idx].buf_addr;
>  					rte_memcpy((void *)(uintptr_t)dst,
>  							(void *)(uintptr_t)src,
> @@ -747,7 +748,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  			hdr_addr = 0;
>  		}
> 
> -		cpy_len = RTE_MIN(buf_len, mbuf_avail);
> +		cpy_len = RTE_MIN(buf_avail, mbuf_avail);
> 
>  		if (likely(cpy_len > MAX_BATCH_LEN ||
>  					vq->batch_copy_nb_elems >= vq-
> >size)) {
> @@ -1112,7 +1113,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  			 * in a contiguous virtual area.
>  			 */
>  			while (remain) {
> -				len = remain;
> +				len = RTE_MIN(remain,
> +					buf_vec[hdr_vec_idx].buf_len);
>  				src = buf_vec[hdr_vec_idx].buf_addr;
>  				rte_memcpy((void *)(uintptr_t)dst,
>  						   (void *)(uintptr_t)src, len);
> --
> 2.18.0

Acked-by: Zhihong Wang <zhihong.wang@intel.com>

Thanks

  reply	other threads:[~2018-07-18 10:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 13:10 Tiwei Bie
2018-07-18 10:47 ` Wang, Zhihong [this message]
     [not found] ` <20180719020531.GA16332@debian>
2018-07-19  2:31   ` Wang, Yinan
2018-07-19  3:37 ` Tiwei Bie
2018-07-19 14:15   ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8F6C2BD409508844A0EFC19955BE094151566EEE@SHSMSX103.ccr.corp.intel.com \
    --to=zhihong.wang@intel.com \
    --cc=dev@dpdk.org \
    --cc=lei.a.yao@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=tiwei.bie@intel.com \
    --cc=yinan.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).