include/net/af_vsock.h

Source file repositories/reference/linux-study-clean/include/net/af_vsock.h

File Facts

System
Linux kernel
Corpus path
include/net/af_vsock.h
Extension
.h
Size
11043 bytes
Lines
334
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct vsock_sock {
	/* sk must be the first member. */
	struct sock sk;
	const struct vsock_transport *transport;
	struct sockaddr_vm local_addr;
	struct sockaddr_vm remote_addr;
	/* Links for the global tables of bound and connected sockets. */
	struct list_head bound_table;
	struct list_head connected_table;
	/* Accessed without the socket lock held. This means it can never be
	 * modified outsided of socket create or destruct.
	 */
	bool trusted;
	bool cached_peer_allow_dgram;	/* Dgram communication allowed to
					 * cached peer?
					 */
	u32 cached_peer;  /* Context ID of last dgram destination check. */
	const struct cred *owner;
	/* Rest are SOCK_STREAM only. */
	long connect_timeout;
	/* Listening socket that this came from. */
	struct sock *listener;
	/* Used for pending list and accept queue during connection handshake.
	 * The listening socket is the head for both lists.  Sockets created
	 * for connection requests are placed in the pending list until they
	 * are connected, at which point they are put in the accept queue list
	 * so they can be accepted in accept().  If accept() cannot accept the
	 * connection, it is marked as rejected so the cleanup function knows
	 * to clean up the socket.
	 */
	struct list_head pending_links;
	struct list_head accept_queue;
	bool rejected;
	struct delayed_work connect_work;
	struct delayed_work pending_work;
	struct delayed_work close_work;
	bool close_work_scheduled;
	u32 peer_shutdown;
	bool sent_request;
	bool ignore_connecting_rst;

	/* Protected by lock_sock(sk) */
	u64 buffer_size;
	u64 buffer_min_size;
	u64 buffer_max_size;

	/* Private to transport. */
	void *trans;
};

s64 vsock_connectible_has_data(struct vsock_sock *vsk);
s64 vsock_stream_has_data(struct vsock_sock *vsk);
s64 vsock_stream_has_space(struct vsock_sock *vsk);
struct sock *vsock_create_connected(struct sock *parent);
void vsock_data_ready(struct sock *sk);

/**** TRANSPORT ****/

struct vsock_transport_recv_notify_data {
	u64 data1; /* Transport-defined. */
	u64 data2; /* Transport-defined. */
	bool notify_on_block;
};

struct vsock_transport_send_notify_data {
	u64 data1; /* Transport-defined. */
	u64 data2; /* Transport-defined. */
};

/* Transport features flags */
/* Transport provides host->guest communication */
#define VSOCK_TRANSPORT_F_H2G		0x00000001
/* Transport provides guest->host communication */
#define VSOCK_TRANSPORT_F_G2H		0x00000002
/* Transport provides DGRAM communication */
#define VSOCK_TRANSPORT_F_DGRAM		0x00000004
/* Transport provides local (loopback) communication */
#define VSOCK_TRANSPORT_F_LOCAL		0x00000008

struct vsock_transport {
	struct module *module;

	/* Initialize/tear-down socket. */
	int (*init)(struct vsock_sock *, struct vsock_sock *);
	void (*destruct)(struct vsock_sock *);
	void (*release)(struct vsock_sock *);

	/* Cancel all pending packets sent on vsock. */
	int (*cancel_pkt)(struct vsock_sock *vsk);

Annotation

Implementation Notes