[dpdk-dev,v2,4/4] kni: fix missing validation when vhost HDR is enabled

Message ID 1435356878-10304-5-git-send-email-miguel.bernal.marin@linux.intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Miguel Bernal Marin June 26, 2015, 10:14 p.m. UTC
  A missing port from memcpy_toiovecend to copy_to_iter
is showed when vHost HDR is enabled. DPDK would not build.

This patch add this validation to build with kernel > 3.19.

Fixes: 45e63ba8db31 ("kni: fix vhost build with kernels 3.19 and 4.0")
Fixes: ba7438aed924 ("vhost: don't bother copying iovecs in handle_rx(), kill memcpy_toiovecend()")

Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Zhang, Helin July 10, 2015, 3:35 p.m. UTC | #1
Could one of you guys help to review the vhost part?

Thanks,
Helin

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Miguel Bernal Marin
> Sent: Friday, June 26, 2015 3:15 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2 4/4] kni: fix missing validation when vhost HDR is
> enabled
> 
> A missing port from memcpy_toiovecend to copy_to_iter is showed when vHost
> HDR is enabled. DPDK would not build.
> 
> This patch add this validation to build with kernel > 3.19.
> 
> Fixes: 45e63ba8db31 ("kni: fix vhost build with kernels 3.19 and 4.0")
> Fixes: ba7438aed924 ("vhost: don't bother copying iovecs in handle_rx(), kill
> memcpy_toiovecend()")
> 
> Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
> ---
>  lib/librte_eal/linuxapp/kni/kni_vhost.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c
> b/lib/librte_eal/linuxapp/kni/kni_vhost.c
> index f21b47e..013a677 100644
> --- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
> +++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
> @@ -427,10 +427,15 @@ kni_sock_rcvmsg(struct socket *sock,
> 
>  #ifdef RTE_KNI_VHOST_VNET_HDR_EN
>  	/* no need to copy hdr when no pkt received */
> +#ifdef HAVE_IOV_ITER_MSGHDR
> +	if (unlikely(copy_to_iter((void *)&vnet_hdr, vnet_hdr_len,
> +		&m->msg_iter)))
> +#else
>  	if (unlikely(memcpy_toiovecend(m->msg_iov,
>  		(void *)&vnet_hdr, 0, vnet_hdr_len)))
> +#endif /* HAVE_IOV_ITER_MSGHDR */
>  		return -EFAULT;
> -#endif
> +#endif /* RTE_KNI_VHOST_VNET_HDR_EN */
>  	KNI_DBG_RX("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
>  		   (unsigned long)len, q->flags, pkt_len);
> 
> --
> 2.4.4
  

Patch

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f21b47e..013a677 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -427,10 +427,15 @@  kni_sock_rcvmsg(struct socket *sock,
 
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 	/* no need to copy hdr when no pkt received */
+#ifdef HAVE_IOV_ITER_MSGHDR
+	if (unlikely(copy_to_iter((void *)&vnet_hdr, vnet_hdr_len,
+		&m->msg_iter)))
+#else
 	if (unlikely(memcpy_toiovecend(m->msg_iov,
 		(void *)&vnet_hdr, 0, vnet_hdr_len)))
+#endif /* HAVE_IOV_ITER_MSGHDR */
 		return -EFAULT;
-#endif
+#endif /* RTE_KNI_VHOST_VNET_HDR_EN */
 	KNI_DBG_RX("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
 		   (unsigned long)len, q->flags, pkt_len);