Skip to content

Commit

Permalink
Fix vrouter build for kernels from 4.11 to 4.13
Browse files Browse the repository at this point in the history
- linux/vhost_dev.c:
  Rename netdev destructor to priv_destructor due to API change.
  New signature of rtnl_link_ops.validate due to API change.
- linux/vr_mem.c
  Remove vma from mem_fault function since VMA pointer now accessable
  via VMF structure.

Change-Id: I9ffc103e5e69649d2a691c7a378cfd12b2363320
Partial-Bug: #1633387
  • Loading branch information
Sergey Matov committed Apr 6, 2018
1 parent eec6545 commit 60c9031
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
13 changes: 12 additions & 1 deletion linux/vhost_dev.c
Expand Up @@ -467,7 +467,12 @@ vhost_setup(struct net_device *dev)
#endif
dev->needed_headroom = sizeof(struct vr_eth) + sizeof(struct agent_hdr);
dev->netdev_ops = &vhost_dev_ops;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,9))
dev->priv_destructor = vhost_dev_destructor;
dev->needs_free_netdev = true;
#else
dev->destructor = vhost_dev_destructor;
#endif /*KERNEL_4.11*/
#ifdef CONFIG_XEN
dev->ethtool_ops = &vhost_ethtool_ops;
dev->features |= NETIF_F_GRO;
Expand Down Expand Up @@ -518,8 +523,15 @@ vhost_dellink(struct net_device *dev, struct list_head *head)
return;
}


#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0))
static int
vhost_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
#else
static int
vhost_validate(struct nlattr *tb[], struct nlattr *data[])
#endif /*KERNEL_4.13*/
{
if (vhost_num_interfaces >= VHOST_MAX_INTERFACES)
return -ENOMEM;
Expand All @@ -535,7 +547,6 @@ static struct rtnl_link_ops vhost_link_ops = {
.dellink = vhost_dellink,
};


static void
vhost_netlink_exit(void)
{
Expand Down
11 changes: 9 additions & 2 deletions linux/vr_mem.c
Expand Up @@ -310,12 +310,19 @@ vr_huge_pages_init()
return 0;
}


#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0))
static int
mem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
void *va;
struct vr_mem_object *vmo = (struct vr_mem_object *)vma->vm_private_data;
#else
static int
mem_fault(struct vm_fault *vmf)
{
struct vr_mem_object *vmo =
(struct vr_mem_object *)vmf->vma->vm_private_data;
#endif /*KERNEL_4.11*/
void *va;
struct vrouter *router = vmo->vmo_router;
struct page *page;
pgoff_t offset;
Expand Down

0 comments on commit 60c9031

Please sign in to comment.