diff mbox

[dpdk-dev] kni: fix vhost-kni compile errors

Message ID 1460393668-17719-1-git-send-email-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Ferruh Yigit April 11, 2016, 4:54 p.m. UTC
fix vhost-kni compile errors because of Linux kernel API changes

- SOCK_ASYNC_WAITDATA renamed to SOCKWQ_ASYNC_WAITDATA
  Linux commit id: 9cd3e072
  Updated in Linux kernel 4.4

- sk_alloc() gets new parameter
  Linux commit id: 11aa9c28b
  Updated in Linux kernel 4.2
  New parameter is: "@kern: is this to be a kernel socket?"

Reported-by: chintu hetam <rometoroam@gmail.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

---

Patch not tested, just fixed compiler errors.
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Comments

Thomas Monjalon April 11, 2016, 5:04 p.m. UTC | #1
2016-04-11 17:54, Ferruh Yigit:
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
> +	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
> +#else
>  	    (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
> +#endif

You could avoid some issues with backported feature by using
#ifdef SOCKWQ_ASYNC_NOSPACE
Ferruh Yigit April 11, 2016, 5:57 p.m. UTC | #2
On 4/11/2016 6:04 PM, Thomas Monjalon wrote:
> 2016-04-11 17:54, Ferruh Yigit:
>> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
>> +	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
>> +#else
>>  	    (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
>> +#endif
> 
> You could avoid some issues with backported feature by using
> #ifdef SOCKWQ_ASYNC_NOSPACE
> 
Right, I am sending a new version.

Regards,
ferruh
diff mbox

Patch

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 6f2a961..482b384 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -251,7 +251,11 @@  kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		mask |= POLLIN | POLLRDNORM;
 
 	if (sock_writeable(&q->sk) ||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
+	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+#else
 	    (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+#endif
 	     sock_writeable(&q->sk)))
 		mask |= POLLOUT | POLLWRNORM;
 
@@ -619,8 +623,11 @@  kni_sk_write_space(struct sock *sk)
 	wait_queue_head_t *wqueue;
 
 	if (!sock_writeable(sk) ||
-	    !test_and_clear_bit(SOCK_ASYNC_NOSPACE,
-				&sk->sk_socket->flags))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
+	    !test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags))
+#else
+	    !test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags))
+#endif
 		return;
 	wqueue = sk_sleep(sk);
 	if (wqueue && waitqueue_active(wqueue))
@@ -666,8 +673,14 @@  kni_vhost_backend_init(struct kni_dev *kni)
 	if (kni->vhost_queue != NULL)
 		return -1;
 
-	if (!(q = (struct kni_vhost_queue *)sk_alloc(
-		      net, AF_UNSPEC, GFP_KERNEL, &kni_raw_proto)))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
+	q = (struct kni_vhost_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
+			&kni_raw_proto, 0);
+#else
+	q = (struct kni_vhost_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
+			&kni_raw_proto);
+#endif
+	if (!q)
 		return -ENOMEM;
 
 	err = sock_create_lite(AF_UNSPEC, SOCK_RAW, IPPROTO_RAW, &q->sock);