Commit Graph

86 Commits

Author SHA1 Message Date
a4929b47af Merge pull request #3435 from roylee17/3149-fix_port_mapping_of_tcp_plus_udp
Fix #3149: port mapping of TCP + UDP
Upstream-commit: b8b18a2b428ebc9519b0dd26a18cf7b2d12cea6b
Component: engine
2014-01-07 10:08:13 -08:00
d5d32a285c Move utility package 'iptables' to pkg/iptables
Upstream-commit: 7799ae27ca1dd85761f0595346a0dda15bbeda6c
Component: engine
2014-01-06 15:41:24 -08:00
819cc0a8d5 Fix #3149: port mapping of TCP + UDP
Signed-off-by: Tzu-Jung Lee <roylee17@gmail.com>
Upstream-commit: f560b87a863916d6ea5b0bd863db654563ffa14d
Component: engine
2014-01-02 16:01:04 -08:00
e7204ea88e Move utility package 'netlink' to pkg/netlink
Upstream-commit: f6b91262a77b2e70da8572850dd8b56d92384dfe
Component: engine
2013-12-23 23:39:39 +00:00
3658b14c94 network: fix a typo in udp cleanup path
Fix #3224 - Port already in use error when running a container

Signed-off-by: Tzu-Jung Lee <roylee17@gmail.com>
Upstream-commit: 7d2e851d8e921bf8f07f54c8afb8262580b36e8d
Component: engine
2013-12-20 17:54:54 -08:00
44050b9219 Allow mtu to be configured at daemon start
Upstream-commit: 566ff54d0ddffbeb3ba2e5f1e400db8528faf0a7
Component: engine
2013-12-20 12:12:03 -05:00
8638e1b670 Merge pull request #3208 from WarheadsSE/bridgeip
Add -bip flag: allow specification of dynamic bridge IP via CIDR
Upstream-commit: 9a9ecda7c8034534130a37a469a66e90c51799f8
Component: engine
2013-12-13 13:56:35 -08:00
c85e5831b2 fix #3141 Bridge creation when ipv6 is not enabled
Upstream-commit: a530b8d9818126e04207de619af8578a4ec4c590
Component: engine
2013-12-13 16:39:49 -02:00
ca9e7bd94d Add -bip flag: allow specification of dynamic bridge IP via CIDR
e.g.:

```
docker -d -bip "10.10.0.1/16"
```

If set and valid, use provided in place of trial and error from pre-defined array in network.go.
Mutually exclusive of -b option.
Upstream-commit: a68d7f3d70ab1638fd5b63a3026b211cb4e7a65e
Component: engine
2013-12-13 10:47:19 -05:00
dccee4fb11 create the bridge device with ioctl
On RHEL 6, creation of a bridge device with netlink fails.  Use the more
backward-compatible ioctl instead.  This fixes networking on RHEL 6.
Upstream-commit: 7a94cdf8edd917899a38a58917cd4439652047a1
Component: engine
2013-12-05 15:32:15 -06:00
e0c7cf69e6 Merge pull request #2907 from goldmann/iptables-fix
Make sure the firewall rules are created even if the bridge interface is already created
Upstream-commit: 79031c4f8cd443a3d6fe26205b6d66830e306619
Component: engine
2013-12-04 18:04:57 -08:00
3f773fbd23 Merge pull request #2966 from andrewsmedina/govet2
fixed some `go vet` issues.
Upstream-commit: 5f55c1aee1a6acdce35f5d7be776104d66e44483
Component: engine
2013-12-04 17:57:10 -08:00
5cd0105c86 Support for same port on multiple interfaces
This commit improves upon the PortMapper and PortAllocator classes by changing
their internal data structures for port allocations to use a string rather than
a single integer. This string holds the network interface address as well as the
port number. This solves a previous problem where a port would be incorrectly
reported as being in use because it had been allocated for a different interface.

I've also added a basic test case for the PortMapper class, and extended the
existing test case for PortAllocator. In the case of PortMapper, this is done
by handing it a stub function for creating proxies rather than an actual
implementation.
Upstream-commit: 1cb1e08644b450d3371bfd7d6e305be454d19719
Component: engine
2013-12-03 15:14:54 +01:00
26d7cf1b0c fixed some go vet issues.
Upstream-commit: a6c9a332d040a98c5cf4325491fc8d9aa7e5475b
Component: engine
2013-11-29 22:53:20 -02:00
890b7668d4 Make sure the firewall rules are created even if the bridge interface is already created
Upstream-commit: 0ff9bc1be3ae044107732c605986a0af20220134
Component: engine
2013-11-27 12:14:18 +01:00
92b39790ed fix the nil pointer panic on closing a disabled network manager
Issue #2768
Upstream-commit: ef14aaf627377b24edb55fe2080e10f748c0e444
Component: engine
2013-11-22 14:28:49 -05:00
07f796bd96 network: add iptables rules to explicitly allow forwarding
Explicitly enable container networking for Fedora and other distros that
have a REJECT all rule at the end of their FORWARD table.
Upstream-commit: ec4657b28a3e97447921357d454df974e0979ac6
Component: engine
2013-11-07 16:23:39 -06:00
61da922aa3 Merge pull request #2561 from dotcloud/add_iptabled_errors
Make iptable return an error in case of output
Upstream-commit: b5c984f9b4899d577430134135379b0088d88b47
Component: engine
2013-11-07 09:15:09 -08:00
a507d209c4 Prevent DNS server conflicts in CreateBridgeIface
Retrieve /etc/resolv.conf data (if available)

Add checkNameserverOverlaps and call it to
make sure there are no conflicts

Add utils.GetNameserversAsCIDR and tests

Read /etc/resolv.conf and pull out nameservers,
formatting them as a CIDR block ("1.2.3.4/32")
Upstream-commit: 3560c922b193e0f6b06c715a7b920f90a5990859
Component: engine
2013-11-05 21:24:37 -06:00
255b88c532 Check the output of iptables command.
Upstream-commit: ff8a4ba0aa20dc3b382e2dcddcd89bb0bb168496
Component: engine
2013-11-05 08:33:13 -08:00
c646f3b347 Move iptable rules outside of create bridge
This allows the user to toggle enabling and
disabling intercontainer communication when
they run the daemon.
Upstream-commit: 94e5081baca9a3b3408d3a6ffa2926d1e262d6fe
Component: engine
2013-10-25 15:13:26 -07:00
1ea9ba1de7 fix merge issue and gofmt
Upstream-commit: 89fb51f6063467124c8883399fc293faae8d8ef5
Component: engine
2013-10-25 15:13:25 -07:00
de03d355b0 network: Stop shelling out to /sbin/ip
We have our own netlink version of all the required calls now, so
we can just skip the /sbin/ip dependency.
Upstream-commit: 494cd07f722d6bf5f2e69a6d2d729848882e1971
Component: engine
2013-10-25 15:13:24 -07:00
226b51e180 Add flag for inter-container communication
Upstream-commit: ce965b8c43f91f0c32403cfaadfd4e279421090b
Component: engine
2013-10-25 15:13:24 -07:00
952ac8a789 Add links for container relationships and introspection
Upstream-commit: 1cbdaebaa1c2326e57945333420d25d6f77011d5
Component: engine
2013-10-25 15:13:24 -07:00
921ffe0649 Make sure to close the network allocators
Upstream-commit: 9107565d0634ea3eed3290c6c4b6c0f006fdefe8
Component: engine
2013-10-08 15:42:02 -07:00
4fa9c87644 Just fixing gofmt issues in other people's code.
Upstream-commit: 6756e786ac36d4e5cda46541b5d6e0b2913b6997
Component: engine
2013-08-30 22:02:05 +02:00
2865213e6d Make sure 'Ghost' container is available with allocated IP
Upstream-commit: 2f6ce27fde04456284457ff686c8f78ab9bd6d71
Component: engine
2013-08-21 22:37:58 +08:00
efc4a51c0c Fixed typos
Upstream-commit: 9b2a5964fc2067014f24e26bd2f99873751ebdc3
Component: engine
2013-08-12 18:53:06 +01:00
228a0e9732 Merge pull request #1435 from jpetazzo/userland-proxy-should-listen-on-inaddr-any
* Runtime: Let userland proxy handle container-bound traffic
Upstream-commit: a2f526dadc71e4f7b6aa8d8bbbd0594d24146a78
Component: engine
2013-08-07 15:48:17 -07:00
437d59d219 Let userland proxy handle container-bound traffic
Upstream-commit: fea2d5f2fe81d983efbdd803cef2fd1c70f98ebc
Component: engine
2013-08-06 17:44:39 -07:00
217ae3229e change network range to avoid conflict with EC2 DNS
Upstream-commit: 9f1c9686e0ee47289adeeedd6cf8d5296a058463
Component: engine
2013-08-06 17:24:10 -07:00
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
2eba08c4b7 Handle ip route showing mask-less IP addresses
Sometimes `ip route` will show mask-less IPs, so net.ParseCIDR will fail. If it does we check if we can net.ParseIP, and fail only if we can't.
Fixes #1214
Fixes #362
Upstream-commit: 2e72882216ce13169a578614202830a5b084bfb4
Component: engine
2013-08-01 02:42:22 +02:00
be9f5063e4 Merge branch '858-disable-network-configuration' of https://github.com/stfp/docker into stfp-858-disable-network-configuration
Upstream-commit: 8165e51eccd15b7eed3939ada6017ed12b9e81b3
Component: engine
2013-07-23 08:44:12 +00:00
4f8c565f24 Allocate a /16 IP range by default, with fallback to /24. Try a total of 12 ranges instead of 3.
Upstream-commit: 4714f102d72f03159acd0f7be71cde3d169c06b8
Component: engine
2013-07-22 12:06:24 -07:00
ca9f0f0f1d Support completely disabling network configuration with docker -d -b none
Upstream-commit: 49673fc45cc5cfc15219bf1eb6eaff7621696919
Component: engine
2013-07-21 17:49:09 -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
8f5746f4d9 Mutex style change.
For structs protected by a single mutex, embed the mutex for more
concise usage.

Also use a sync.Mutex directly, rather than a pointer, to avoid the
need for initialization (because a Mutex's zero-value is valid and
ready to be used).
Upstream-commit: 1cf9c80e976fb60b4d5d489cd1c4c9959bcc4f7f
Component: engine
2013-07-02 15:53:08 -07:00
9cf4a66364 Remove code unreachable using Go 1.1
Upstream-commit: 50b70eeb6830040db73c8b2b389d881a3200de8d
Component: engine
2013-06-20 23:19:44 -04:00
231e68638d specify public port
Upstream-commit: 95d66ebc6b068f2762d1a8bf3f78cd78d6ab4900
Component: engine
2013-06-10 13:56:43 +00:00
82ddfc6a07 Put back panic for go1.0.3 compatibility
Upstream-commit: 7ef9833dbb299ebf796092a6921127ea77d38337
Component: engine
2013-06-04 14:26:40 -07:00
4747c5b99f linted names
Upstream-commit: fd224ee590dc9f003f6507b529a9f47cceb02c44
Component: engine
2013-06-04 18:00:22 +00:00
9c0086fb7d drop/omit
Upstream-commit: 86ada2fa5d00820288df8a59eca3deef83f4aeb6
Component: engine
2013-06-04 13:51:12 +00:00
51d3c4635e go vet
Upstream-commit: b515a5a9ec5792c67be5fe8476df96903f43df71
Component: engine
2013-06-04 13:24:58 +00:00
bc6fad489c Create a subpackage for utils
Upstream-commit: 2e69e1727b4d5698a90c24c5800eecd5401dc319
Component: engine
2013-05-14 22:37:35 +00:00
2d0d73c6f3 Shutdown loopback-to-loopback proxy when unmapping a port
Upstream-commit: 7f1a32b9ff31bd931e9495acc1d5ccdef4bd51b6
Component: engine
2013-04-19 20:44:25 -07:00
1cb0701d9b Emulate DNAT in userland for loopback-to-loopback connections. This makes container ports available from localhost.
Upstream-commit: 930e9a7e430a3d78e09a95bb32d9fb6052e7dae1
Component: engine
2013-04-19 19:35:44 -07:00
66366b4f1d Exclude loopback-to-loopback connections from DNAT rules, to allow userland proxying
Upstream-commit: 61259ab4b4bfe3404e75dd811a2da7c88e7c7133
Component: engine
2013-04-19 19:32:32 -07:00
ebb6835d20 Go fmt
Upstream-commit: 22893429ed29dbb7a01eed7a90a4d1fbecfd5d90
Component: engine
2013-04-12 07:37:24 -07:00