hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/net/af_vsock.h
....@@ -1,16 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * VMware vSockets Driver
34 *
45 * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License as published by the Free
8
- * Software Foundation version 2 and no later version.
9
- *
10
- * This program is distributed in the hope that it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
146 */
157
168 #ifndef __AF_VSOCK_H__
....@@ -18,7 +10,7 @@
1810
1911 #include <linux/kernel.h>
2012 #include <linux/workqueue.h>
21
-#include <linux/vm_sockets.h>
13
+#include <uapi/linux/vm_sockets.h>
2214
2315 #include "vsock_addr.h"
2416
....@@ -35,6 +27,7 @@
3527 struct vsock_sock {
3628 /* sk must be the first member. */
3729 struct sock sk;
30
+ const struct vsock_transport *transport;
3831 struct sockaddr_vm local_addr;
3932 struct sockaddr_vm remote_addr;
4033 /* Links for the global tables of bound and connected sockets. */
....@@ -72,16 +65,18 @@
7265 bool sent_request;
7366 bool ignore_connecting_rst;
7467
68
+ /* Protected by lock_sock(sk) */
69
+ u64 buffer_size;
70
+ u64 buffer_min_size;
71
+ u64 buffer_max_size;
72
+
7573 /* Private to transport. */
7674 void *trans;
7775 };
7876
7977 s64 vsock_stream_has_data(struct vsock_sock *vsk);
8078 s64 vsock_stream_has_space(struct vsock_sock *vsk);
81
-struct sock *__vsock_create(struct net *net,
82
- struct socket *sock,
83
- struct sock *parent,
84
- gfp_t priority, unsigned short type, int kern);
79
+struct sock *vsock_create_connected(struct sock *parent);
8580
8681 /**** TRANSPORT ****/
8782
....@@ -96,7 +91,19 @@
9691 u64 data2; /* Transport-defined. */
9792 };
9893
94
+/* Transport features flags */
95
+/* Transport provides host->guest communication */
96
+#define VSOCK_TRANSPORT_F_H2G 0x00000001
97
+/* Transport provides guest->host communication */
98
+#define VSOCK_TRANSPORT_F_G2H 0x00000002
99
+/* Transport provides DGRAM communication */
100
+#define VSOCK_TRANSPORT_F_DGRAM 0x00000004
101
+/* Transport provides local (loopback) communication */
102
+#define VSOCK_TRANSPORT_F_LOCAL 0x00000008
103
+
99104 struct vsock_transport {
105
+ struct module *module;
106
+
100107 /* Initialize/tear-down socket. */
101108 int (*init)(struct vsock_sock *, struct vsock_sock *);
102109 void (*destruct)(struct vsock_sock *);
....@@ -147,17 +154,11 @@
147154 struct vsock_transport_send_notify_data *);
148155 int (*notify_send_post_enqueue)(struct vsock_sock *, ssize_t,
149156 struct vsock_transport_send_notify_data *);
157
+ /* sk_lock held by the caller */
158
+ void (*notify_buffer_size)(struct vsock_sock *, u64 *);
150159
151160 /* Shutdown. */
152161 int (*shutdown)(struct vsock_sock *, int);
153
-
154
- /* Buffer sizes. */
155
- void (*set_buffer_size)(struct vsock_sock *, u64);
156
- void (*set_min_buffer_size)(struct vsock_sock *, u64);
157
- void (*set_max_buffer_size)(struct vsock_sock *, u64);
158
- u64 (*get_buffer_size)(struct vsock_sock *);
159
- u64 (*get_min_buffer_size)(struct vsock_sock *);
160
- u64 (*get_max_buffer_size)(struct vsock_sock *);
161162
162163 /* Addressing. */
163164 u32 (*get_local_cid)(void);
....@@ -165,15 +166,11 @@
165166
166167 /**** CORE ****/
167168
168
-int __vsock_core_init(const struct vsock_transport *t, struct module *owner);
169
-static inline int vsock_core_init(const struct vsock_transport *t)
170
-{
171
- return __vsock_core_init(t, THIS_MODULE);
172
-}
173
-void vsock_core_exit(void);
169
+int vsock_core_register(const struct vsock_transport *t, int features);
170
+void vsock_core_unregister(const struct vsock_transport *t);
174171
175172 /* The transport may downcast this to access transport-specific functions */
176
-const struct vsock_transport *vsock_core_get_transport(void);
173
+const struct vsock_transport *vsock_core_get_transport(struct vsock_sock *vsk);
177174
178175 /**** UTILS ****/
179176
....@@ -201,6 +198,8 @@
201198 struct sockaddr_vm *dst);
202199 void vsock_remove_sock(struct vsock_sock *vsk);
203200 void vsock_for_each_connected_socket(void (*fn)(struct sock *sk));
201
+int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk);
202
+bool vsock_find_cid(unsigned int cid);
204203
205204 /**** TAP ****/
206205