kni: fix vhost build with kernel 3.7

Signed-off-by: Intel
This commit is contained in:
Intel 2013-11-08 03:00:00 +01:00 committed by Thomas Monjalon
parent c1c677a1ec
commit a4a9fa474c

View File

@ -31,6 +31,7 @@
#include <linux/nsproxy.h>
#include <linux/sched.h>
#include <linux/if_tun.h>
#include <linux/version.h>
#include "kni_dev.h"
#include "kni_fifo.h"
@ -39,6 +40,34 @@
extern void put_unused_fd(unsigned int fd);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
extern struct file*
sock_alloc_file(struct socket *sock,
int flags, const char *dname);
extern int get_unused_fd_flags(unsigned flags);
extern void fd_install(unsigned int fd, struct file *file);
static int kni_sock_map_fd(struct socket *sock)
{
struct file *file;
int fd = get_unused_fd_flags(0);
if (fd < 0)
return fd;
file = sock_alloc_file(sock, 0, NULL);
if (IS_ERR(file)) {
put_unused_fd(fd);
return PTR_ERR(file);
}
fd_install(fd, file);
return fd;
}
#else
#define kni_sock_map_fd(s) sock_map_fd(s, 0)
#endif
static struct proto kni_raw_proto = {
.name = "kni_vhost",
.owner = THIS_MODULE,
@ -598,7 +627,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
if (err)
goto free_sk;
sockfd = sock_map_fd(q->sock, 0);
sockfd = kni_sock_map_fd(q->sock);
if (sockfd < 0) {
err = sockfd;
goto free_sock;