Commit Graph

102 Commits

Author SHA1 Message Date
Josh Poimboeuf a2aa12eced network: insert masq rule
This fixes IP masquerading on systems with reject rules at the end of
the POSTROUTING table, by inserting the rule at the beginning of the
table instead of adding it at the end.

Docker-DCO-1.1-Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> (github: jpoimboe)
Upstream-commit: cc382ec62848855f6fe7302fe7a37ac62af35a9c
Component: engine
2014-01-30 11:06:28 -06:00
Michael Crosby 4971da5034 Move port mapper tests out of core and into portmapper
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: b3b12f00593d96c6d0e93f9e333ee368278e871d
Component: engine
2014-01-28 17:10:13 -08:00
Michael Crosby b8f930d15c Initial move of port mapper code into sub pkg
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 99756ef11fc2a3ae821bb412607e7e9b322f278a
Component: engine
2014-01-28 15:42:46 -08:00
Guillaume J. Charmes 33ad91ccbb Merge pull request #3801 from tianon/ip-forward
Add --ip-forward flag to daemon (enabled by default)
Upstream-commit: 4ab59179e76dc2311422c2ebdeafca279dc94b65
Component: engine
2014-01-28 11:17:45 -08:00
Guillaume J. Charmes 72e2fd7949 Merge pull request #3759 from jpoimboe/links-iptables-cleanup
network: remove unnecessary links iptables rule for return traffic
Upstream-commit: d4ea6308fd0593a50c9f245a8dfd4db8cba8c297
Component: engine
2014-01-28 11:10:36 -08:00
Tianon Gravi 07c81f6fbb Add --ip-forward flag to daemon (enabled by default) which automatically sets "net.ipv4.ip_forward" to 1
See also https://groups.google.com/d/topic/docker-dev/DCjF5Prx7HA/discussion

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: cabe624c823348579ada234e3c029479683f624c
Component: engine
2014-01-27 21:35:05 -07:00
Michael Crosby 1feadd553a Simplify logic for registering ports
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: da61b99b392657343df4dc221ba5cd9ad6b1c9e1
Component: engine
2014-01-26 14:01:38 -08:00
Michael Crosby c14df520ff Refactor to support multiple ip addresses
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: ac2a4e64106b28d7b05d1ee31716af365424ff83
Component: engine
2014-01-26 14:01:38 -08:00
Josh Poimboeuf de913bbe65 network: remove unnecessary links iptables rule for return traffic
Currently there are two iptables rules per port for each link: one to
allow the parent to connect to the child's port, and another one to
allow return traffic from the child back to the parent.  The second rule
shouldn't be needed because the "ctstate RELATED,ESTABLISHED" rule can
already allow all established traffic.

So this patch does the following:

1. Move the RELATED,ESTABLISHED rule to be _before_ the potential
   inter-container communication DROP rule so it will work for
   inter-container traffic as well.  Since we're inserting, everything
   is reversed chronologically so it should be inserted _after_ we
   insert the DROP.  This also has a small performance benefit because
   it will be processed earlier and it's generally one of the most
   commonly used rules.

2. Get rid of the unnecessary return traffic rule per link.

3. Also move the other "Accept all non-intercontainer outgoing packets"
   rule to earlier.  This gives a small performance benefit since it's
   also a commonly used rule, and it makes sense to logically group it
   next to the ctstate rule.

Docker-DCO-1.1-Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> (github: jpoimboe)
Upstream-commit: 5c04f1bcc70e81fe3c93b1c246ce17a11304ad7f
Component: engine
2014-01-24 21:20:34 -06:00
Michael Crosby 57e87d938b Refactor and fix register interface when bridge does not exist
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: ec73c232318a3dae803a27a6922f0af7117eec6e
Component: engine
2014-01-23 14:39:10 -08:00
Michael Crosby e16cdc0102 Finalize core changes with new package
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: ea5b3e193ba40b65c38c774e9abb85340c52e8c6
Component: engine
2014-01-23 05:22:32 -08:00
Michael Crosby f755b9590d Move tests from core into ipallocator
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: fccca3542b91513dd0da73db21ffa3ced4dd9b7f
Component: engine
2014-01-23 01:31:38 -08:00
Michael Crosby 5cb56f7078 WIP for ip allocator
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 9e2e8a923c28833dd631a7206d3664a6a90cc24c
Component: engine
2014-01-22 15:52:39 -08:00
Johan Euphrosine 9ba5452f29 netlink: make darwin happy
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
Upstream-commit: 77d9fd262828c0c626b2093e8a62e05cc130905e
Component: engine
2014-01-17 16:55:42 -08:00
Johan Euphrosine 06869c7c04 network: exclude default routes from checkRouteOverlaps
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
Upstream-commit: a886fbfa4a01f7d73c9c2d836da89ecf23a40a33
Component: engine
2014-01-17 11:09:53 -08:00
Johan Euphrosine 52d25202bf netlink: add default Route to NetworkGetRoutes
Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
Upstream-commit: 26726dc9ff3ac8ccc7f40f7672e6494d0e77611d
Component: engine
2014-01-17 11:09:50 -08:00
Michael Crosby 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
Solomon Hykes d5d32a285c Move utility package 'iptables' to pkg/iptables
Upstream-commit: 7799ae27ca1dd85761f0595346a0dda15bbeda6c
Component: engine
2014-01-06 15:41:24 -08:00
Tzu-Jung Lee 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
Solomon Hykes e7204ea88e Move utility package 'netlink' to pkg/netlink
Upstream-commit: f6b91262a77b2e70da8572850dd8b56d92384dfe
Component: engine
2013-12-23 23:39:39 +00:00
Tzu-Jung Lee 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
Michael Crosby 44050b9219 Allow mtu to be configured at daemon start
Upstream-commit: 566ff54d0ddffbeb3ba2e5f1e400db8528faf0a7
Component: engine
2013-12-20 12:12:03 -05:00
Guillaume J. Charmes 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
Rodrigo Vaz c85e5831b2 fix #3141 Bridge creation when ipv6 is not enabled
Upstream-commit: a530b8d9818126e04207de619af8578a4ec4c590
Component: engine
2013-12-13 16:39:49 -02:00
WarheadsSE 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
Josh Poimboeuf 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
Victor Vieux 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
Victor Vieux 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
Emil Hernvall 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
Andrews Medina 26d7cf1b0c fixed some go vet issues.
Upstream-commit: a6c9a332d040a98c5cf4325491fc8d9aa7e5475b
Component: engine
2013-11-29 22:53:20 -02:00
Marek Goldmann 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
Vincent Batts 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
Josh Poimboeuf 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
Michael Crosby 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
Mark Allen 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
Guillaume J. Charmes 255b88c532 Check the output of iptables command.
Upstream-commit: ff8a4ba0aa20dc3b382e2dcddcd89bb0bb168496
Component: engine
2013-11-05 08:33:13 -08:00
Michael Crosby 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
Victor Vieux 1ea9ba1de7 fix merge issue and gofmt
Upstream-commit: 89fb51f6063467124c8883399fc293faae8d8ef5
Component: engine
2013-10-25 15:13:25 -07:00
Alexander Larsson 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
Michael Crosby 226b51e180 Add flag for inter-container communication
Upstream-commit: ce965b8c43f91f0c32403cfaadfd4e279421090b
Component: engine
2013-10-25 15:13:24 -07:00
Michael Crosby 952ac8a789 Add links for container relationships and introspection
Upstream-commit: 1cbdaebaa1c2326e57945333420d25d6f77011d5
Component: engine
2013-10-25 15:13:24 -07:00
Guillaume J. Charmes 921ffe0649 Make sure to close the network allocators
Upstream-commit: 9107565d0634ea3eed3290c6c4b6c0f006fdefe8
Component: engine
2013-10-08 15:42:02 -07:00
Brian Olsen 4fa9c87644 Just fixing gofmt issues in other people's code.
Upstream-commit: 6756e786ac36d4e5cda46541b5d6e0b2913b6997
Component: engine
2013-08-30 22:02:05 +02:00
pysqz 2865213e6d Make sure 'Ghost' container is available with allocated IP
Upstream-commit: 2f6ce27fde04456284457ff686c8f78ab9bd6d71
Component: engine
2013-08-21 22:37:58 +08:00
Pascal Borreli efc4a51c0c Fixed typos
Upstream-commit: 9b2a5964fc2067014f24e26bd2f99873751ebdc3
Component: engine
2013-08-12 18:53:06 +01:00
Guillaume J. Charmes 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
Jérôme Petazzoni 437d59d219 Let userland proxy handle container-bound traffic
Upstream-commit: fea2d5f2fe81d983efbdd803cef2fd1c70f98ebc
Component: engine
2013-08-06 17:44:39 -07:00
Jérôme Petazzoni 217ae3229e change network range to avoid conflict with EC2 DNS
Upstream-commit: 9f1c9686e0ee47289adeeedd6cf8d5296a058463
Component: engine
2013-08-06 17:24:10 -07:00
Guillaume J. Charmes 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
Steeve Morin 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