diff -rupN vmnet-only.orig//driver.c vmnet-only/driver.c --- vmnet-only.orig//driver.c 2011-11-14 08:16:55.000000000 +0100 +++ vmnet-only/driver.c 2012-02-21 00:09:34.577959452 +0100 @@ -165,7 +165,30 @@ static long VNetFileOpUnlockedIoctl(str unsigned int iocmd, unsigned long ioarg); #endif -static struct file_operations vnetFileOps; +/* static struct file_operations vnetFileOps; old */ + + /* Moved file operations initialize here because of incompatibilites + * with Gentoo hardened profile/hardend Linux 3. + * Initialize the file_operations structure. Because this code is always + * compiled as a module, this is fine to do it here and not in a static + * initializer. + */ +static struct file_operations vnetFileOps = { + .owner = THIS_MODULE, + .read = VNetFileOpRead, + .write = VNetFileOpWrite, + .poll = VNetFileOpPoll, +#ifdef HAVE_UNLOCKED_IOCTL + .unlocked_ioctl = VNetFileOpUnlockedIoctl, +#else + .ioctl = VNetFileOpIoctl, +#endif +#ifdef HAVE_COMPAT_IOCTL + .compat_ioctl = VNetFileOpUnlockedIoctl, +#endif + .open = VNetFileOpOpen, + .release = VNetFileOpClose +}; /* * Utility functions @@ -475,29 +498,7 @@ init_module(void) if (retval) { goto err_proto; } - - /* - * Initialize the file_operations structure. Because this code is always - * compiled as a module, this is fine to do it here and not in a static - * initializer. - */ - - memset(&vnetFileOps, 0, sizeof vnetFileOps); - vnetFileOps.owner = THIS_MODULE; - vnetFileOps.read = VNetFileOpRead; - vnetFileOps.write = VNetFileOpWrite; - vnetFileOps.poll = VNetFileOpPoll; -#ifdef HAVE_UNLOCKED_IOCTL - vnetFileOps.unlocked_ioctl = VNetFileOpUnlockedIoctl; -#else - vnetFileOps.ioctl = VNetFileOpIoctl; -#endif -#ifdef HAVE_COMPAT_IOCTL - vnetFileOps.compat_ioctl = VNetFileOpUnlockedIoctl; -#endif - vnetFileOps.open = VNetFileOpOpen; - vnetFileOps.release = VNetFileOpClose; - + retval = register_chrdev(VNET_MAJOR_NUMBER, "vmnet", &vnetFileOps); if (retval) { LOG(0, (KERN_NOTICE "/dev/vmnet: could not register major device %d\n", diff -rupN vmnet-only.orig//filter.c vmnet-only/filter.c --- vmnet-only.orig//filter.c 2011-11-14 08:16:55.000000000 +0100 +++ vmnet-only/filter.c 2012-02-21 00:16:01.471937259 +0100 @@ -40,6 +40,10 @@ #include "vnetInt.h" #include "vmnetInt.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) +#include +#endif + // VNet_FilterLogPacket.action for dropped packets #define VNET_FILTER_ACTION_DRP (1) #define VNET_FILTER_ACTION_DRP_SHORT (2) diff -rupN vmnet-only.orig//netif.c vmnet-only/netif.c --- vmnet-only.orig//netif.c 2011-11-14 08:16:55.000000000 +0100 +++ vmnet-only/netif.c 2012-02-21 00:14:17.891943201 +0100 @@ -62,7 +62,9 @@ static int VNetNetifClose(struct net_de static int VNetNetifStartXmit(struct sk_buff *skb, struct net_device *dev); static struct net_device_stats *VNetNetifGetStats(struct net_device *dev); static int VNetNetifSetMAC(struct net_device *dev, void *addr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 42, 0) || (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) static void VNetNetifSetMulticast(struct net_device *dev); +#endif #if 0 static void VNetNetifTxTimeout(struct net_device *dev); #endif @@ -131,7 +133,9 @@ VNetNetIfSetup(struct net_device *dev) .ndo_stop = VNetNetifClose, .ndo_get_stats = VNetNetifGetStats, .ndo_set_mac_address = VNetNetifSetMAC, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 42, 0) || (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) .ndo_set_multicast_list = VNetNetifSetMulticast, +#endif /* * We cannot stuck... If someone will report problems under * low memory conditions or some such, we should enable it. @@ -612,11 +616,12 @@ VNetNetifSetMAC(struct net_device *dev, *---------------------------------------------------------------------- */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 42, 0) || (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) void VNetNetifSetMulticast(struct net_device *dev) // IN: unused { } - +#endif /* *---------------------------------------------------------------------- diff -rupN vmnet-only.orig//userif.c vmnet-only/userif.c --- vmnet-only.orig//userif.c 2011-11-14 08:16:55.000000000 +0100 +++ vmnet-only/userif.c 2012-02-21 00:11:19.949953408 +0100 @@ -516,11 +516,18 @@ VNetCsumCopyDatagram(const struct sk_buf if (frag->size > 0) { unsigned int tmpCsum; const void *vaddr; - +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 42, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + vaddr = kmap(skb_frag_page(frag)); +#else vaddr = kmap(frag->page); +#endif tmpCsum = csum_and_copy_to_user(vaddr + frag->page_offset, curr, frag->size, 0, &err); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 42, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) + kunmap(skb_frag_page(frag)); +#else kunmap(frag->page); +#endif if (err) { return err; }