2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-02 10:43:57 +08:00
linux-next/include/uapi/linux/vm_sockets_diag.h
Stefan Hajnoczi 413a4317ac VSOCK: add sock_diag interface
This patch adds the sock_diag interface for querying sockets from
userspace.  Tools like ss(8) and netstat(8) can use this interface to
list open sockets.

The userspace ABI is defined in <linux/vm_sockets_diag.h> and includes
netlink request and response structs.  The request can query sockets
based on their sk_state (e.g. listening sockets only) and the response
contains socket information fields including the local/remote addresses,
inode number, etc.

This patch does not dump VMCI pending sockets because I have only tested
the virtio transport, which does not use pending sockets.  Support can
be added later by extending vsock_diag_dump() if needed by VMCI users.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-05 18:44:17 -07:00

34 lines
915 B
C

/* AF_VSOCK sock_diag(7) interface for querying open sockets */
#ifndef _UAPI__VM_SOCKETS_DIAG_H__
#define _UAPI__VM_SOCKETS_DIAG_H__
#include <linux/types.h>
/* Request */
struct vsock_diag_req {
__u8 sdiag_family; /* must be AF_VSOCK */
__u8 sdiag_protocol; /* must be 0 */
__u16 pad; /* must be 0 */
__u32 vdiag_states; /* query bitmap (e.g. 1 << TCP_LISTEN) */
__u32 vdiag_ino; /* must be 0 (reserved) */
__u32 vdiag_show; /* must be 0 (reserved) */
__u32 vdiag_cookie[2];
};
/* Response */
struct vsock_diag_msg {
__u8 vdiag_family; /* AF_VSOCK */
__u8 vdiag_type; /* SOCK_STREAM or SOCK_DGRAM */
__u8 vdiag_state; /* sk_state (e.g. TCP_LISTEN) */
__u8 vdiag_shutdown; /* local RCV_SHUTDOWN | SEND_SHUTDOWN */
__u32 vdiag_src_cid;
__u32 vdiag_src_port;
__u32 vdiag_dst_cid;
__u32 vdiag_dst_port;
__u32 vdiag_ino;
__u32 vdiag_cookie[2];
};
#endif /* _UAPI__VM_SOCKETS_DIAG_H__ */