Commit Graph

19 Commits

Author SHA1 Message Date
David Scott
5090fd9599 proxy: add a multiplexing server frontend
On a Hyper-V system we can only register one listening endpoint (with
a GUID), so we need to accept connections, read a header and then
start the proxy.

If the binary has argv[0] == "proxy-vsockd" then run this new frontend.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-05-22 12:43:18 +01:00
Rolf Neugebauer
6c2056055c proxy: use share vendored go packages
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2016-05-19 13:54:48 +01:00
David Scott
d5bd7d690a proxy: bind the IP port as well as the vsock port
Previously the proxy would listen only on the vsock port, which is
fine for accessing the port on the host, but if a container also wants
to access the port (e.g. via `--net=host` and using the Moby IP) then
we need to listen on the IP too.

Related to [docker/pinata#2854]

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-29 13:53:02 +01:00
David Scott
927a4d7b69 proxy: listen on vsock before requesting a connection
The 9P operations tell the host to connect to the vsock port in the
UDP case, so always listen before sending the 9P request.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-22 15:32:22 +01:00
David Scott
04c75c6c38 proxy: vendor github.com/djs55/vsock
Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:43:10 +01:00
David Scott
9e64166554 proxy: move vendor/libproxy to ./libproxy
vendor should be used for things with fully-qualified names,

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:29:23 +01:00
David Scott
c24687e2e1 proxy: fix up the vsock interface
- don't try to create a `FileConn` because the Go library sees through
  the scam and rejects it
- explicitly keep a reference to the `ctl` file just in case the GC
  decides its dead and should be closed.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:24:56 +01:00
David Scott
a321da38e5 proxy: tell the /port server the real external IP address
Before this we accidentally told it the vsock address, which obviously
isn't much good.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:24:56 +01:00
David Scott
df65441dec proxy: we don't need to explicitly unexposePort any more
The port will be automatically removed when the fd/fid is closed by
a process exit/crash, or by a hypervisor crash.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:24:56 +01:00
David Scott
f269d6289b proxy: request a vsock connection rather than a TCP/IP one
Note this means we don't need to figure out our local IP address.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:24:56 +01:00
David Scott
74be577a0f proxy: simply the Dockerfile by shuffling code under vendor/
Note there is a slight name clash between the final binary 'proxy'
and the library formerly known as 'proxy'. Resolve this by calling
the library 'libproxy'.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-15 17:24:56 +01:00
David Scott
05d6df42bb proxy: keep the fd open to the control file
A future version of the 9P server will shutdown the forward on 9P
clunk, so if this process crashes the forward will be cleaned up
properly.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-11 18:27:11 +01:00
David Scott
9acc04f99b proxy: determine "my" address by examining the "docker" forward
When requesting a port forward we currently need to know the VM's
address from the point of view of the port forwarder. The easiest way to
discover this is to read it from the existing "docker" port forward.

Note this should all be revamped once we have vsock support.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00
David Scott
e8fa5ace35 proxy: set up and tear down host port forwards
This patch uses the /port 9P filesystem to set up and tear down port
forwards on the host.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00
David Scott
00ff8897a7 proxy: add exposePort and unexposePort stubs
This patch removes `proxyForever` and adds `sendError` and `sendOK` for
signalling to the parent process. The main function now sequences these
functions and calls stub functions `exposePort` and `unexposePort` which
will be hooked up in a later patch.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00
David Scott
a8fc95eb9d proxy: on exit, return to main for cleanup
Previously the proxy.go would directly call `os.Exit`. This patch
causes control to return to `main` where we can tear down any port
forward.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00
David Scott
444a6147d9 proxy: split the execProxy function into parts
Previously `execProxy` would
- create the proxy
- signal success/failure to the parent
- run forever (until signalled)

Since we want to add more proxy setup and teardown, this patch
removes the proxy creation from `execProxy` and renames it to
`proxyForever`. Later patches will be able to perform the necessary
side-effects before signalling success to the parent.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00
David Scott
e1b8975016 Import docker/libnetwork/portmapper/proxy.go
Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00
David Scott
dc9b79f116 Add skeleton /sbin/proxy program
This will eventually contain the `docker-proxy` replacement.

Signed-off-by: David Scott <dave.scott@docker.com>
2016-04-04 12:41:02 +01:00