diff options
-rw-r--r-- | src/core/ext/filters/client_channel/parse_address.cc | 4 | ||||
-rw-r--r-- | src/core/lib/iomgr/sockaddr_posix.h | 8 | ||||
-rw-r--r-- | src/core/lib/iomgr/unix_sockets_posix.cc | 7 | ||||
-rw-r--r-- | src/core/lib/iomgr/vm_sockets.h | 44 |
4 files changed, 51 insertions, 12 deletions
diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index c737f53d01..b49d2a6b3a 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -26,10 +26,6 @@ #include <string.h> #ifdef GRPC_HAVE_UNIX_SOCKET #include <sys/un.h> -#ifdef GRPC_HAVE_LINUX_VSOCK -#include <sys/socket.h> -#include <linux/vm_sockets.h> -#endif /* GRPC_HAVE_LINUX_VSOCK */ #endif #include <grpc/support/alloc.h> diff --git a/src/core/lib/iomgr/sockaddr_posix.h b/src/core/lib/iomgr/sockaddr_posix.h index e32fc9a219..9ad9abe26f 100644 --- a/src/core/lib/iomgr/sockaddr_posix.h +++ b/src/core/lib/iomgr/sockaddr_posix.h @@ -51,7 +51,13 @@ typedef struct in6_addr grpc_in6_addr; #ifdef GRPC_HAVE_LINUX_VSOCK #include <linux/vm_sockets.h> // Needs to come after sys/socket.h #define GRPC_AF_VSOCK AF_VSOCK -#endif /* GRPC_HAVE_LINUX_VSOCK */ +#elif GPR_ANDROID +// HACK(chenhaosjtuacm): when building host services for run_cvd, the glibc version of Android +// toolchain is too low, using the header copied from bionic libc instead +#include "vm_sockets.h" +#define GRPC_HAVE_LINUX_VSOCK +#define GRPC_AF_VSOCK AF_VSOCK +#endif #define GRPC_AI_PASSIVE AI_PASSIVE diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc index cf93a7d9c4..6541b58dc5 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.cc +++ b/src/core/lib/iomgr/unix_sockets_posix.cc @@ -19,13 +19,6 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_HAVE_LINUX_VSOCK - -#include <sys/socket.h> -#include <linux/vm_sockets.h> - -#endif /* GRPC_HAVE_LINUX_VSOCK */ - #ifdef GRPC_HAVE_UNIX_SOCKET #include "src/core/lib/iomgr/sockaddr.h" diff --git a/src/core/lib/iomgr/vm_sockets.h b/src/core/lib/iomgr/vm_sockets.h new file mode 100644 index 0000000000..151f6769d1 --- /dev/null +++ b/src/core/lib/iomgr/vm_sockets.h @@ -0,0 +1,44 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + *** Copied and modified from bionic/libc/kernel/uapi/linux/vm_sockets.h + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _UAPI_VM_SOCKETS_H +#define _UAPI_VM_SOCKETS_H +#include <linux/socket.h> +#define SO_VM_SOCKETS_BUFFER_SIZE 0 +#define SO_VM_SOCKETS_BUFFER_MIN_SIZE 1 +#define SO_VM_SOCKETS_BUFFER_MAX_SIZE 2 +#define SO_VM_SOCKETS_PEER_HOST_VM_ID 3 +#define SO_VM_SOCKETS_TRUSTED 5 +#define SO_VM_SOCKETS_CONNECT_TIMEOUT 6 +#define SO_VM_SOCKETS_NONBLOCK_TXRX 7 +#define VMADDR_CID_ANY - 1U +#define VMADDR_PORT_ANY - 1U +#define VMADDR_CID_HYPERVISOR 0 +#define VMADDR_CID_RESERVED 1 +#define VMADDR_CID_HOST 2 +#define VM_SOCKETS_INVALID_VERSION - 1U +#define VM_SOCKETS_VERSION_EPOCH(_v) (((_v) & 0xFF000000) >> 24) +#define VM_SOCKETS_VERSION_MAJOR(_v) (((_v) & 0x00FF0000) >> 16) +#define VM_SOCKETS_VERSION_MINOR(_v) (((_v) & 0x0000FFFF)) +struct sockaddr_vm { + __kernel_sa_family_t svm_family; + unsigned short svm_reserved1; + unsigned int svm_port; + unsigned int svm_cid; + unsigned char svm_zero[sizeof(struct sockaddr) - sizeof(sa_family_t) - sizeof(unsigned short) - sizeof(unsigned int) - sizeof(unsigned int)]; +}; +#define IOCTL_VM_SOCKETS_GET_LOCAL_CID _IO(7, 0xb9) +#ifndef AF_VSOCK +#define AF_VSOCK 40 +#endif +#endif |