[dpdk-dev] kni: fix compilation issue on kernel 3.19
Commit Message
Due to commit c0371da6 in kernel 3.19, which removed msg_iov
and msg_iovlen from struct msghdr, DPDK would not build.
This patch makes use of struct iov_iter, which has references
to those two variables.
Reported-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
lib/librte_eal/linuxapp/kni/compat.h | 4 ++++
lib/librte_eal/linuxapp/kni/kni_vhost.c | 13 ++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Monday, May 04, 2015 10:46 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] kni: fix compilation issue on kernel 3.19
>
> Due to commit c0371da6 in kernel 3.19, which removed msg_iov
> and msg_iovlen from struct msghdr, DPDK would not build.
>
> This patch makes use of struct iov_iter, which has references
> to those two variables.
>
> Reported-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Self-NACK. Kernel 4.0 has other changes that require other fixes, incompatible with this patch.
Will send a v2 compatible with both kernels 3.19 and 4.0
@@ -19,3 +19,7 @@
#define sk_sleep(s) (s)->sk_sleep
#endif /* < 2.6.35 */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+#define HAVE_IOV_ITER_MSGHDR
+#endif
@@ -76,7 +76,7 @@ static struct proto kni_raw_proto = {
};
static inline int
-kni_vhost_net_tx(struct kni_dev *kni, struct iovec *iov,
+kni_vhost_net_tx(struct kni_dev *kni, const struct iovec *iov,
unsigned offset, unsigned len)
{
struct rte_kni_mbuf *pkt_kva = NULL;
@@ -143,7 +143,7 @@ drop:
}
static inline int
-kni_vhost_net_rx(struct kni_dev *kni, struct iovec *iov,
+kni_vhost_net_rx(struct kni_dev *kni, const struct iovec *iov,
unsigned offset, unsigned len)
{
uint32_t pkt_len;
@@ -361,8 +361,11 @@ kni_sock_sndmsg(struct kiocb *iocb, struct socket *sock,
if (unlikely(len < ETH_HLEN + q->vnet_hdr_sz))
return -EINVAL;
-
+#ifdef HAVE_IOV_ITER_MSGHDR
+ return kni_vhost_net_tx(q->kni, m->msg_iter.iov, vnet_hdr_len, len);
+#else
return kni_vhost_net_tx(q->kni, m->msg_iov, vnet_hdr_len, len);
+#endif
}
static int
@@ -391,7 +394,11 @@ kni_sock_rcvmsg(struct kiocb *iocb, struct socket *sock,
#endif
if (unlikely(0 == (pkt_len = kni_vhost_net_rx(q->kni,
+#ifdef HAVE_IOV_ITER_MSGHDR
+ m->msg_iter.iov, vnet_hdr_len, len))))
+#else
m->msg_iov, vnet_hdr_len, len))))
+#endif
return 0;
#ifdef RTE_KNI_VHOST_VNET_HDR_EN