aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/vm_sockets_diag.h
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2017-10-05 16:46:53 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-05 18:44:17 -0700
commit413a4317aca7d6367d57a5971b0c461f03851207 (patch)
treecf1b8a4ac209b5ce6ef8aaf861f84bc8279cf4d8 /include/uapi/linux/vm_sockets_diag.h
parent3b4477d2dcf2709d0be89e2a8dced3d0f4a017f2 (diff)
downloadkernel_replicant_linux-413a4317aca7d6367d57a5971b0c461f03851207.tar.gz
kernel_replicant_linux-413a4317aca7d6367d57a5971b0c461f03851207.tar.bz2
kernel_replicant_linux-413a4317aca7d6367d57a5971b0c461f03851207.zip
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>
Diffstat (limited to 'include/uapi/linux/vm_sockets_diag.h')
-rw-r--r--include/uapi/linux/vm_sockets_diag.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/uapi/linux/vm_sockets_diag.h b/include/uapi/linux/vm_sockets_diag.h
new file mode 100644
index 000000000000..14cd7dc5a187
--- /dev/null
+++ b/include/uapi/linux/vm_sockets_diag.h
@@ -0,0 +1,33 @@
+/* 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__ */