Browse code

kernel: 9p vsock transport support

Change-Id: Ic787a790b32b67fda2f53263f1519c7abf45fe67
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1738
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: suezzelur <anishs@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1786
Reviewed-by: Sharath George

Alexey Makhalov authored on 2016/11/23 06:11:49
Showing 3 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:       Kernel
3 3
 Name:          linux-esx
4 4
 Version:       4.4.31
5
-Release:       3%{?dist}
5
+Release:       4%{?dist}
6 6
 License:       GPLv2
7 7
 URL:           http://www.kernel.org/
8 8
 Group:         System Environment/Kernel
... ...
@@ -36,6 +36,7 @@ Patch20:       vmci-1.1.4.0-use-32bit-atomics-for-queue-headers.patch
36 36
 Patch21:       vmci-1.1.5.0-doorbell-create-and-destroy-fixes.patch
37 37
 #fixes CVE-2016-7039
38 38
 Patch22:       net-add-recursion-limit-to-GRO.patch
39
+Patch23:       net-9p-vsock.patch
39 40
 BuildRequires: bc
40 41
 BuildRequires: kbd
41 42
 BuildRequires: kmod
... ...
@@ -93,6 +94,7 @@ The Linux package contains the Linux kernel doc files
93 93
 %patch20 -p1
94 94
 %patch21 -p1
95 95
 %patch22 -p1
96
+%patch23 -p1
96 97
 
97 98
 %build
98 99
 # patch vmw_balloon driver
... ...
@@ -164,6 +166,8 @@ ln -sf %{name}-%{version}-%{release}.cfg /boot/photon.cfg
164 164
 /usr/src/%{name}-headers-%{version}-%{release}
165 165
 
166 166
 %changelog
167
+*   Tue Nov 22 2016 Alexey Makhalov <amakhalov@vmware.com> 4.4.31-4
168
+-   net-9p-vsock.patch
167 169
 *   Thu Nov 17 2016 Alexey Makhalov <amakhalov@vmware.com> 4.4.31-3
168 170
 -   tty-prevent-ldisc-drivers-from-re-using-stale-tty-fields.patch
169 171
     to fix CVE-2015-8964
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux
4 4
 Version:    	4.4.31
5
-Release:    	3%{?dist}
5
+Release:    	4%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -31,6 +31,7 @@ Patch14:        vmxnet3-1.4.8.0-segCnt-can-be-1-for-LRO-packets.patch
31 31
 Patch15:        apparmor-fix-oops-validate-buffer-size-in-apparmor_setprocattr.patch
32 32
 #fixes CVE-2016-7039
33 33
 Patch16:        net-add-recursion-limit-to-GRO.patch
34
+Patch17:        net-9p-vsock.patch
34 35
 BuildRequires:  bc
35 36
 BuildRequires:  kbd
36 37
 BuildRequires:  kmod
... ...
@@ -103,6 +104,7 @@ Kernel driver for oprofile, a statistical profiler for Linux systems
103 103
 %patch14 -p1
104 104
 %patch15 -p1
105 105
 %patch16 -p1
106
+%patch17 -p1
106 107
 
107 108
 %build
108 109
 make mrproper
... ...
@@ -200,6 +202,8 @@ ln -s /usr/lib/debug/lib/modules/%{version}/vmlinux-%{version}-%{release}.debug
200 200
 /lib/modules/%{version}/kernel/arch/x86/oprofile/
201 201
 
202 202
 %changelog
203
+*   Tue Nov 22 2016 Alexey Makhalov <amakhalov@vmware.com> 4.4.31-4
204
+-   net-9p-vsock.patch
203 205
 *   Thu Nov 17 2016 Alexey Makhalov <amakhalov@vmware.com> 4.4.31-3
204 206
 -   tty-prevent-ldisc-drivers-from-re-using-stale-tty-fields.patch
205 207
     to fix CVE-2015-8964
206 208
new file mode 100644
... ...
@@ -0,0 +1,105 @@
0
+diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
1
+index bced8c0..ac57c4b 100644
2
+--- a/net/9p/trans_fd.c
3
+@@ -37,6 +37,8 @@
4
+ #include <linux/un.h>
5
+ #include <linux/uaccess.h>
6
+ #include <linux/inet.h>
7
++#include <linux/vmw_vmci_defs.h>
8
++#include <uapi/linux/vm_sockets.h>
9
+ #include <linux/idr.h>
10
+ #include <linux/file.h>
11
+ #include <linux/parser.h>
12
+@@ -64,6 +66,7 @@ struct p9_fd_opts {
13
+ 	int wfd;
14
+ 	u16 port;
15
+ 	int privport;
16
++	int vsock;
17
+ };
18
+ 
19
+ /*
20
+@@ -73,7 +76,7 @@ struct p9_fd_opts {
21
+ 
22
+ enum {
23
+ 	/* Options that take integer arguments */
24
+-	Opt_port, Opt_rfdno, Opt_wfdno, Opt_err,
25
++	Opt_port, Opt_rfdno, Opt_wfdno, Opt_err, Opt_vsock,
26
+ 	/* Options that take no arguments */
27
+ 	Opt_privport,
28
+ };
29
+@@ -83,6 +86,7 @@ static const match_table_t tokens = {
30
+ 	{Opt_rfdno, "rfdno=%u"},
31
+ 	{Opt_wfdno, "wfdno=%u"},
32
+ 	{Opt_privport, "privport"},
33
++	{Opt_vsock, "vsock=%d"},
34
+ 	{Opt_err, NULL},
35
+ };
36
+ 
37
+@@ -735,6 +739,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
38
+ 	opts->rfd = ~0;
39
+ 	opts->wfd = ~0;
40
+ 	opts->privport = 0;
41
++	opts->vsock = 0;
42
+ 
43
+ 	if (!params)
44
+ 		return 0;
45
+@@ -774,6 +779,9 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
46
+ 		case Opt_privport:
47
+ 			opts->privport = 1;
48
+ 			break;
49
++		case Opt_vsock:
50
++			opts->vsock = option;
51
++			break;
52
+ 		default:
53
+ 			continue;
54
+ 		}
55
+@@ -938,11 +946,27 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
56
+ 
57
+ 	csocket = NULL;
58
+ 
59
+-	sin_server.sin_family = AF_INET;
60
+-	sin_server.sin_addr.s_addr = in_aton(addr);
61
+-	sin_server.sin_port = htons(opts.port);
62
+-	err = __sock_create(current->nsproxy->net_ns, PF_INET,
63
+-			    SOCK_STREAM, IPPROTO_TCP, &csocket, 1);
64
++	if (opts.vsock == 0) {
65
++		sin_server.sin_family = AF_INET;
66
++		sin_server.sin_addr.s_addr = in_aton(addr);
67
++		sin_server.sin_port = htons(opts.port);
68
++		err = __sock_create(current->nsproxy->net_ns, PF_INET,
69
++		                    SOCK_STREAM, IPPROTO_TCP, &csocket, 1);
70
++	} else {
71
++		/*
72
++		 * for vsock, addr is not used, but opts.vsock is the vsock address,
73
++		 * where 2 means host (hypervisor), and other numbers mean the vmci id
74
++		 * in the VMX file of this running VM
75
++		 */
76
++		struct sockaddr_vm *vsock_server = (struct sockaddr_vm*)&sin_server;
77
++
78
++		memset(vsock_server, 0, sizeof(struct sockaddr_vm));
79
++		vsock_server->svm_family = AF_VSOCK;
80
++		vsock_server->svm_port = opts.port;
81
++		vsock_server->svm_cid = opts.vsock;
82
++		err = __sock_create(read_pnet(&current->nsproxy->net_ns), PF_VSOCK,
83
++		                    SOCK_STREAM, 0, &csocket, 1);
84
++	}
85
+ 	if (err) {
86
+ 		pr_err("%s (%d): problem creating socket\n",
87
+ 		       __func__, task_pid_nr(current));
88
+@@ -963,8 +987,13 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
89
+ 				    (struct sockaddr *)&sin_server,
90
+ 				    sizeof(struct sockaddr_in), 0);
91
+ 	if (err < 0) {
92
+-		pr_err("%s (%d): problem connecting socket to %s\n",
93
+-		       __func__, task_pid_nr(current), addr);
94
++		if (opts.vsock) {
95
++			pr_err("%s (%d): problem connecting vmware vsock addr %d\n",
96
++			       __func__, task_pid_nr(current), opts.vsock);
97
++		} else {
98
++			pr_err("%s (%d): problem connecting socket to %s\n",
99
++			       __func__, task_pid_nr(current), addr);
100
++		}
101
+ 		sock_release(csocket);
102
+ 		return err;
103
+ 	}