1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
diff --git a/vmnet/Makefile b/vmnet/Makefile
index 459846e..cd29652 100644
--- a/vmnet/Makefile
+++ b/vmnet/Makefile
@@ -43,7 +43,11 @@ INCLUDE += -I$(SRCROOT)/shared
endif
+ifdef KVERSION
+VM_UNAME = $(KVERSION)
+else
VM_UNAME = $(shell uname -r)
+endif
# Header directory for the running kernel
ifdef LINUXINCLUDE
diff --git a/vmnet/Makefile.kernel b/vmnet/Makefile.kernel
index 2d8e6f6..a14166b 100644
--- a/vmnet/Makefile.kernel
+++ b/vmnet/Makefile.kernel
@@ -19,7 +19,7 @@
INCLUDE := -I$(SRCROOT)
-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
+EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
obj-m += $(DRIVER).o
diff --git a/vmnet/driver.c b/vmnet/driver.c
index 7e7ad99..5f508f6 100644
--- a/vmnet/driver.c
+++ b/vmnet/driver.c
@@ -137,7 +137,16 @@ static ssize_t VNetFileOpWrite(struct file *filp, const char *buf, size_t count
static long VNetFileOpUnlockedIoctl(struct file * filp,
unsigned int iocmd, unsigned long ioarg);
-static struct file_operations vnetFileOps;
+static struct file_operations vnetFileOps = {
+ .owner = THIS_MODULE,
+ .read = VNetFileOpRead,
+ .write = VNetFileOpWrite,
+ .poll = VNetFileOpPoll,
+ .unlocked_ioctl = VNetFileOpUnlockedIoctl,
+ .compat_ioctl = VNetFileOpUnlockedIoctl,
+ .open = VNetFileOpOpen,
+ .release = VNetFileOpClose
+};
/*
* Utility functions
@@ -317,22 +326,6 @@ init_module(void)
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;
- vnetFileOps.unlocked_ioctl = VNetFileOpUnlockedIoctl;
- vnetFileOps.compat_ioctl = VNetFileOpUnlockedIoctl;
- 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",
@@ -1145,12 +1138,12 @@ VNetMulticastFilter(const uint8 *destAddr, // IN: multicast MAC
}
/*
* Do not need to further compute and check ladrf if no match
- * in exact multicast filter, since only one of them is
+ * in exact multicast filter, since only one of them is
* used at a time.
*/
return FALSE;
}
-
+
crc = 0xffffffff; /* init CRC for each address */
for (byte = 0; byte < ETH_ALEN; byte++) { /* for each address byte */
diff --git a/vmnet/vm_device_version.h b/vmnet/vm_device_version.h
index e2cb477..3dd7097 100644
--- a/vmnet/vm_device_version.h
+++ b/vmnet/vm_device_version.h
@@ -53,7 +53,9 @@
* VMware HD Audio codec
* VMware HD Audio controller
*/
+#ifndef PCI_VENDOR_ID_VMWARE
#define PCI_VENDOR_ID_VMWARE 0x15AD
+#endif
#define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710
#define PCI_DEVICE_ID_VMWARE_VGA 0x0711
diff --git a/vmnet/vmnetInt.h b/vmnet/vmnetInt.h
index 0ee52ec..4e3b923 100644
--- a/vmnet/vmnetInt.h
+++ b/vmnet/vmnetInt.h
@@ -48,7 +48,7 @@
extern struct proto vmnet_proto;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || defined(sk_net_refcnt)
# define compat_sk_alloc(_bri, _pri) sk_alloc(&init_net, \
- PF_NETLINK, _pri, &vmnet_proto, 1)
+ PF_NETLINK, _pri, &vmnet_proto, 0)
#else
# define compat_sk_alloc(_bri, _pri) sk_alloc(&init_net, \
PF_NETLINK, _pri, &vmnet_proto)
|