From b3f82f045abd7ed67cd2dc42f908c79789bd49c9 Mon Sep 17 00:00:00 2001 From: David Scott Date: Fri, 15 Apr 2016 17:30:43 +0100 Subject: [PATCH] proxy: vendor github.com/djs55/vsock Signed-off-by: David Scott --- alpine/packages/proxy/libproxy/proxy.go | 2 +- alpine/packages/proxy/main.go | 2 +- .../{ => github.com/djs55}/vsock/vsock.go | 12 +- alpine/packages/proxy/vendor/manifest | 13 ++ .../vsock/include/uapi/linux/vm_sockets.h | 161 ------------------ 5 files changed, 26 insertions(+), 164 deletions(-) rename alpine/packages/proxy/vendor/{ => github.com/djs55}/vsock/vsock.go (92%) create mode 100644 alpine/packages/proxy/vendor/manifest delete mode 100644 alpine/packages/proxy/vendor/vsock/include/uapi/linux/vm_sockets.h diff --git a/alpine/packages/proxy/libproxy/proxy.go b/alpine/packages/proxy/libproxy/proxy.go index 7e72057fb..2e6bb569b 100644 --- a/alpine/packages/proxy/libproxy/proxy.go +++ b/alpine/packages/proxy/libproxy/proxy.go @@ -5,7 +5,7 @@ package libproxy import ( "fmt" "net" - "vsock" + "github.com/djs55/vsock" ) // Proxy defines the behavior of a proxy. It forwards traffic back and forth diff --git a/alpine/packages/proxy/main.go b/alpine/packages/proxy/main.go index 5e3c1e742..a7c125a2a 100644 --- a/alpine/packages/proxy/main.go +++ b/alpine/packages/proxy/main.go @@ -8,7 +8,7 @@ import ( "os" "proxy/libproxy" "strings" - "vsock" + "github.com/djs55/vsock" ) func main() { diff --git a/alpine/packages/proxy/vendor/vsock/vsock.go b/alpine/packages/proxy/vendor/github.com/djs55/vsock/vsock.go similarity index 92% rename from alpine/packages/proxy/vendor/vsock/vsock.go rename to alpine/packages/proxy/vendor/github.com/djs55/vsock/vsock.go index dc7217874..f8c38e00a 100644 --- a/alpine/packages/proxy/vendor/vsock/vsock.go +++ b/alpine/packages/proxy/vendor/github.com/djs55/vsock/vsock.go @@ -13,7 +13,17 @@ import ( /* #include -#include "include/uapi/linux/vm_sockets.h" + +struct sockaddr_vm { + 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)]; +}; + int bind_sockaddr_vm(int fd, const struct sockaddr_vm *sa_vm) { return bind(fd, (const struct sockaddr*)sa_vm, sizeof(*sa_vm)); } diff --git a/alpine/packages/proxy/vendor/manifest b/alpine/packages/proxy/vendor/manifest new file mode 100644 index 000000000..27f87a766 --- /dev/null +++ b/alpine/packages/proxy/vendor/manifest @@ -0,0 +1,13 @@ +{ + "version": 0, + "dependencies": [ + { + "importpath": "github.com/djs55/vsock", + "repository": "ssh://github.com/djs55/vsock", + "vcs": "git", + "revision": "7ea787de194e9a251ea746cf37f464c1e6cb822a", + "branch": "master", + "notests": true + } + ] +} \ No newline at end of file diff --git a/alpine/packages/proxy/vendor/vsock/include/uapi/linux/vm_sockets.h b/alpine/packages/proxy/vendor/vsock/include/uapi/linux/vm_sockets.h deleted file mode 100644 index 41934a185..000000000 --- a/alpine/packages/proxy/vendor/vsock/include/uapi/linux/vm_sockets.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * VMware vSockets Driver - * - * Copyright (C) 2007-2013 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation version 2 and no later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef _UAPI_VM_SOCKETS_H -#define _UAPI_VM_SOCKETS_H - -#ifdef __KERNEL__ -#include -#else -#define __kernel_sa_family_t sa_family_t -#include -#endif - -/* Option name for STREAM socket buffer size. Use as the option name in - * setsockopt(3) or getsockopt(3) to set or get an unsigned long long that - * specifies the size of the buffer underlying a vSockets STREAM socket. - * Value is clamped to the MIN and MAX. - */ - -#define SO_VM_SOCKETS_BUFFER_SIZE 0 - -/* Option name for STREAM socket minimum buffer size. Use as the option name - * in setsockopt(3) or getsockopt(3) to set or get an unsigned long long that - * specifies the minimum size allowed for the buffer underlying a vSockets - * STREAM socket. - */ - -#define SO_VM_SOCKETS_BUFFER_MIN_SIZE 1 - -/* Option name for STREAM socket maximum buffer size. Use as the option name - * in setsockopt(3) or getsockopt(3) to set or get an unsigned long long - * that specifies the maximum size allowed for the buffer underlying a - * vSockets STREAM socket. - */ - -#define SO_VM_SOCKETS_BUFFER_MAX_SIZE 2 - -/* Option name for socket peer's host-specific VM ID. Use as the option name - * in getsockopt(3) to get a host-specific identifier for the peer endpoint's - * VM. The identifier is a signed integer. - * Only available for hypervisor endpoints. - */ - -#define SO_VM_SOCKETS_PEER_HOST_VM_ID 3 - -/* Option name for determining if a socket is trusted. Use as the option name - * in getsockopt(3) to determine if a socket is trusted. The value is a - * signed integer. - */ - -#define SO_VM_SOCKETS_TRUSTED 5 - -/* Option name for STREAM socket connection timeout. Use as the option name - * in setsockopt(3) or getsockopt(3) to set or get the connection - * timeout for a STREAM socket. - */ - -#define SO_VM_SOCKETS_CONNECT_TIMEOUT 6 - -/* Option name for using non-blocking send/receive. Use as the option name - * for setsockopt(3) or getsockopt(3) to set or get the non-blocking - * transmit/receive flag for a STREAM socket. This flag determines whether - * send() and recv() can be called in non-blocking contexts for the given - * socket. The value is a signed integer. - * - * This option is only relevant to kernel endpoints, where descheduling the - * thread of execution is not allowed, for example, while holding a spinlock. - * It is not to be confused with conventional non-blocking socket operations. - * - * Only available for hypervisor endpoints. - */ - -#define SO_VM_SOCKETS_NONBLOCK_TXRX 7 - -/* The vSocket equivalent of INADDR_ANY. This works for the svm_cid field of - * sockaddr_vm and indicates the context ID of the current endpoint. - */ - -#define VMADDR_CID_ANY -1U - -/* Bind to any available port. Works for the svm_port field of - * sockaddr_vm. - */ - -#define VMADDR_PORT_ANY -1U - -/* Use this as the destination CID in an address when referring to the - * hypervisor. VMCI relies on it being 0, but this would be useful for other - * transports too. - */ - -#define VMADDR_CID_HYPERVISOR 0 - -/* This CID is specific to VMCI and can be considered reserved (even VMCI - * doesn't use it anymore, it's a legacy value from an older release). - */ - -#define VMADDR_CID_RESERVED 1 - -/* Use this as the destination CID in an address when referring to the host - * (any process other than the hypervisor). VMCI relies on it being 2, but - * this would be useful for other transports too. - */ - -#define VMADDR_CID_HOST 2 - -/* Invalid vSockets version. */ - -#define VM_SOCKETS_INVALID_VERSION -1U - -/* The epoch (first) component of the vSockets version. A single byte - * representing the epoch component of the vSockets version. - */ - -#define VM_SOCKETS_VERSION_EPOCH(_v) (((_v) & 0xFF000000) >> 24) - -/* The major (second) component of the vSockets version. A single byte - * representing the major component of the vSockets version. Typically - * changes for every major release of a product. - */ - -#define VM_SOCKETS_VERSION_MAJOR(_v) (((_v) & 0x00FF0000) >> 16) - -/* The minor (third) component of the vSockets version. Two bytes representing - * the minor component of the vSockets version. - */ - -#define VM_SOCKETS_VERSION_MINOR(_v) (((_v) & 0x0000FFFF)) - -/* Address structure for vSockets. The address family should be set to - * AF_VSOCK. The structure members should all align on their natural - * boundaries without resorting to compiler packing directives. The total size - * of this structure should be exactly the same as that of struct sockaddr. - */ - -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) - -#endif /* _UAPI_VM_SOCKETS_H */