Commit Graph

14 Commits

Author SHA1 Message Date
ce7a658e04 Make sure the routes IP are taken into consideration + add unit test for network overlap detection
Upstream-commit: f5a8e90d101cd2dbb4ce19543ed15fff48579877
Component: engine
2013-08-01 18:12:39 -07:00
c69035fce1 Add support for UDP (closes #33)
API Changes
-----------

The port notation is extended to support "/udp" or "/tcp" at the *end*
of the specifier string (and defaults to tcp if "/tcp" or "/udp" are
missing)

`docker ps` now shows UDP ports as "frontend->backend/udp". Nothing
changes for TCP ports.

`docker inspect` now displays two sub-dictionaries: "Tcp" and "Udp",
under "PortMapping" in "NetworkSettings".

Theses changes stand true for the values returned by the HTTP API too.

This changeset will definitely break tools built upon the API (or upon
`docker inspect`). A less intrusive way to add UDP ports in `docker
inspect` would be to simply add "/udp" for UDP ports but it will still
break existing applications which tries to convert the whole field to an
integer. I believe that having two TCP/UDP sub-dictionaries is better
because it makes the whole thing more clear and more easy to parse right
away (i.e: you don't have to check the format of the string, split it
and convert the right part to an integer)

Code Changes
------------

Significant changes in network.go:

- A second PortAllocator is instantiated for the UDP range;
- PortMapper maintains separate mapping for TCP and UDP;
- The extPorts array in NetworkInterface is now an array of Nat objects
  (so we can know on which protocol a given port was mapped when
  NetworkInterface.Release() is called);
- TCP proxying on localhost has been moved away in network_proxy.go.

localhost proxy code rewrite in network_proxy.go:

We have to proxy the traffic between localhost:frontend-port and
container:backend-port because Netfilter doesn't work properly on the
loopback interface and DNAT iptable rules aren't applied there.

- Goroutines in the TCP proxying code are now explicitly stopped when
  the proxy is stopped;
- UDP connection tracking using a map (more infos in [1]);
- Support for IPv6 (to be more accurate, the code is transparent to the
  Go net package, so you can use, tcp/tcp4/tcp6/udp/udp4/udp6);
- Single Proxy interface for both UDP and TCP proxying;
- Full test suite.

[1] https://github.com/dotcloud/docker/issues/33#issuecomment-20010400
Upstream-commit: fac0d87d00ada08309ea3b82cae69beeef637c89
Component: engine
2013-07-09 17:42:35 -07:00
a8d7e665c6 add tests
Upstream-commit: 0de3f1ca9a2135033ca482a8916123e51d82de09
Component: engine
2013-06-10 14:14:54 +00:00
4747c5b99f linted names
Upstream-commit: fd224ee590dc9f003f6507b529a9f47cceb02c44
Component: engine
2013-06-04 18:00:22 +00:00
3bb1012d01 Merge remote-tracking branch 'origin/219-default-bridge-2'
Upstream-commit: 793c1ad9909701a8b89ac6731ac266048e48ec46
Component: engine
2013-04-05 14:02:16 -07:00
f49bdcbf33 Add tests of tcp port allocator
Upstream-commit: febaeebfb8848265267213b2f6a6fc3a40ad90f1
Component: engine
2013-04-05 13:03:24 -07:00
d25d9d9cff Add an helper function to check if two network overlaps. Also add unit tests for this function
Upstream-commit: 90a6e310fe4c70b99f9fa5c8d8615e2382edba0b
Component: engine
2013-04-03 16:15:43 -07:00
8a40ce58f3 Make IP allocator lazy
Instead of allocating all possible IPs in advance, generate them as
needed.

A loop will cycle through all possible IPs in sequential order,
allocating them as needed and marking them as in use. Once the loop
exhausts all IPs, it will wrap back to the beginning. IPs that are
already in use will be skipped. When an IP is released, it will be
cleared and be available for allocation again.

Two decisions went into this design:

1) Minimize memory footprint by only allocating IPs that are actually
in use

2) Minimize reuse of released IP addresses to avoid sending traffic to
the wrong containers

As a side effect, the functions for IP/Mask<->int conversion have been
rewritten to never be able to fail in order to reduce the amount of
error returns.

Fixes gh-231
Upstream-commit: 6f9a67a7c7cb717ad1a575df3e4c0fd2ec8bc651
Component: engine
2013-04-01 06:02:44 +02:00
7f80c9c88f Test that iptables() looks for iptables in the PATH
Upstream-commit: ba33d67a1a0f3310bddab8176a9d570e5d5c00e2
Component: engine
2013-03-28 18:44:47 -07:00
a9ffc585e7 Comply the tests with golang TIP
Upstream-commit: d8fa52b7b5b6101538c15735500b3a01327ca96f
Component: engine
2013-03-21 10:31:02 -07:00
3cddff121d Network: Port mapping support.
Implemented a port allocator and a port mapper that is able to forward TCP ports
from the host to the container.
Upstream-commit: 799ffa176399877e610ff2049dbf84610037a2be
Component: engine
2013-02-28 11:50:02 -08:00
6bc8a20d54 Integrated the network allocator into Docker. A networking environment
is assigned to each container upon Start and released whenever the
container exits.
Upstream-commit: c08f5b2b8460f13f2094bae2a496bf308f7645bb
Component: engine
2013-02-25 14:06:22 -08:00
550e796b18 Network allocator
Upstream-commit: 797bb6e75b8f33fe44932bf90145cf069f342e44
Component: engine
2013-02-25 10:45:23 -08:00
5d44a89654 Network tests
Upstream-commit: 149badc22b45acb171c3e583f6e820a06e4ced87
Component: engine
2013-02-21 18:34:35 -08:00