[dpdk-dev] kni: fix compilation issue with KNI_VHOST enabled
Commit Message
Fix for the following error, on kernels 4.2.0 or higher,
when KNI_VHOST is enabled:
CC [M] lib/librte_eal/linuxapp/kni/kni_vhost.o
lib/librte_eal/linuxapp/kni/kni_vhost.c: In function ‘kni_vhost_backend_init’:
lib/librte_eal/linuxapp/kni/kni_vhost.c:669:38: error: too few arguments to function ‘sk_alloc’
if (!(q = (struct kni_vhost_queue *)sk_alloc(
^
In file included from lib/librte_eal/linuxapp/kni/kni_vhost.c:27:0:
/usr/src/kernels/4.2.3-300.fc23.x86_64/include/net/sock.h:1515:14: note: declared here
struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
^
This change in the kernel was added in the following commit:
Linux: 11aa9c28 ("net: Pass kern from net_proto_family.create to sk_alloc")
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
lib/librte_eal/linuxapp/kni/kni_vhost.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -666,9 +666,15 @@ kni_vhost_backend_init(struct kni_dev *kni)
if (kni->vhost_queue != NULL)
return -1;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
+ if (!(q = (struct kni_vhost_queue *)sk_alloc(
+ net, AF_UNSPEC, GFP_KERNEL, &kni_raw_proto, 0)))
+ return -ENOMEM;
+#else
if (!(q = (struct kni_vhost_queue *)sk_alloc(
net, AF_UNSPEC, GFP_KERNEL, &kni_raw_proto)))
return -ENOMEM;
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0) */
err = sock_create_lite(AF_UNSPEC, SOCK_RAW, IPPROTO_RAW, &q->sock);
if (err)