Commit Graph

124 Commits

Author SHA1 Message Date
d7e8665b03 Add --userland-proxy daemon flag
The `--userland-proxy` daemon flag makes it possible to rely on hairpin
NAT and additional iptables routes instead of userland proxy for port
publishing and inter-container communication.

Usage of the userland proxy remains the default as hairpin NAT is
unsupported by older kernels.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Upstream-commit: f42348e18f73d1d775d77ac75bc96466aae56d7c
Component: engine
2015-05-04 16:07:45 -07:00
031175bb41 Merge pull request #11526 from mizzy/append-drop-rule-not-insert
Append DROP rule with --icc=false, not insert
Upstream-commit: 6c46c9c83936689937701b3259d969255bcf4ca6
Component: engine
2015-04-29 10:28:11 -07:00
ae74d9f34f trivial: typo cleanup
Signed-off-by: David Mackey <tdmackey@booleanhaiku.com>
Upstream-commit: 3941623fbc3fa724d61f53121513ffd87d03b61c
Component: engine
2015-04-27 13:35:08 -07:00
aac3868541 Fixed typo 'configuring'
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: ae9905ef9c5e8fe793e6a6269bb720618f4fcaed
Component: engine
2015-04-24 16:52:32 -07:00
249f3df46c Merge pull request #9397 from jpopelka/9395-firewalld
Firewalld support
Upstream-commit: 259effc6dfd901130ca6d2926090bddfe35f7cdc
Component: engine
2015-04-23 16:58:08 -04:00
78da009c7c Append icc related iptables rules, not INSERT
Signed-off-by: Gosuke Miyashita <gosukenator@gmail.com>
Upstream-commit: 90a8e45604f42d60d58b4cefa37a5e5d3112b64a
Component: engine
2015-04-22 11:45:46 +09:00
a2ec388af9 Merge pull request #12533 from ankushagarwal/gofmt-directory
gofmt 1.4.2  src directory
Upstream-commit: 4a25c5d25bad693f9e79a810d87f9103769f918c
Component: engine
2015-04-20 17:02:43 -07:00
9d30ecdb29 Merge pull request #9381 from lebauce/default-gateway
Proposal: Allow specifying a default gateway for bridge networking
Upstream-commit: 9838242db1890ae82dd63a6aae134147c74933ef
Component: engine
2015-04-20 15:50:35 -07:00
6f062d5e99 Allow specifying a default gateway for bridge networking
Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
Upstream-commit: acb6127c1a3f7054c25d1468b67f2eb269f4ecbf
Component: engine
2015-04-20 15:13:30 +02:00
fcda625311 React to firewalld's reload/restart
When firewalld (or iptables service) restarts/reloads,
all previously added docker firewall rules are flushed.

With firewalld we can react to its Reloaded() [1]
D-Bus signal and recreate the firewall rules.
Also when firewalld gets restarted (stopped & started)
we can catch the NameOwnerChanged signal [2].
To specify which signals we want to react to we use AddMatch [3].

Libvirt has been doing this for quite a long time now.

Docker changes firewall rules on basically 3 places.
1) daemon/networkdriver/portmapper/mapper.go - port mappings
   Portmapper fortunatelly keeps list of mapped ports,
   so we can easily recreate firewall rules on firewalld restart/reload
   New ReMapAll() function does that
2) daemon/networkdriver/bridge/driver.go
   When setting a bridge, basic firewall rules are created.
   This is done at once during start, it's parametrized and nowhere
   tracked so how can one know what and how to set it again when
   there's been firewalld restart/reload ?
   The only solution that came to my mind is using of closures [4],
   i.e. I keep list of references to closures (anonymous functions
   together with a referencing environment) and when there's firewalld
   restart/reload I re-call them in the same order.
3) links/links.go - linking containers
   Link is added in Enable() and removed in Disable().
   In Enable() we add a callback function, which creates the link,
   that's OK so far.
   It'd be ideal if we could remove the same function from
   the list in Disable(). Unfortunatelly that's not possible AFAICT,
   because we don't know the reference to that function
   at that moment, so we can only add a reference to function,
   which removes the link. That means that after creating and
   removing a link there are 2 functions in the list,
   one adding and one removing the link and after
   firewalld restart/reload both are called.
   It works, but it's far from ideal.

[1] https://jpopelka.fedorapeople.org/firewalld/doc/firewalld.dbus.html#FirewallD1.Signals.Reloaded
[2] http://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-name-owner-changed
[3] http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules
[4] https://en.wikipedia.org/wiki/Closure_%28computer_programming%29

Signed-off-by: Jiri Popelka <jpopelka@redhat.com>
Upstream-commit: b052827e025267336f0d426df44ec536745821f8
Component: engine
2015-04-20 13:02:09 +02:00
8f2bd21917 Support for Firewalld
Firewalld [1] is a firewall managing daemon with D-Bus interface.

What sort of problem are we trying to solve with this ?

Firewalld internally also executes iptables/ip6tables to change firewall settings.
It might happen on systems where both docker and firewalld are running
concurrently, that both of them try to call iptables at the same time.
The result is that the second one fails because the first one is holding a xtables lock.
One workaround is to use --wait/-w option in both
docker & firewalld when calling iptables.
It's already been done in both upstreams:
b315c380f4
b3b451d6f8
But it'd still be better if docker used firewalld when it's running.

Other problem the firewalld support would solve is that
iptables/firewalld service's restart flushes all firewall rules
previously added by docker.
See next patch for possible solution.

This patch utilizes firewalld's D-Bus interface.
If firewalld is running, we call direct.passthrough() [2] method instead
of executing iptables directly.
direct.passthrough() takes the same arguments as iptables tool itself
and passes them through to iptables tool.
It might be better to use other methods, like direct.addChain and
direct.addRule [3] so it'd be more intergrated with firewalld, but
that'd make the patch much bigger.
If firewalld is not running, everything works as before.

[1] http://www.firewalld.org/
[2] https://jpopelka.fedorapeople.org/firewalld/doc/firewalld.dbus.html#FirewallD1.direct.Methods.passthrough
[3] https://jpopelka.fedorapeople.org/firewalld/doc/firewalld.dbus.html#FirewallD1.direct.Methods.addChain
    https://jpopelka.fedorapeople.org/firewalld/doc/firewalld.dbus.html#FirewallD1.direct.Methods.addRule

Signed-off-by: Jiri Popelka <jpopelka@redhat.com>
Upstream-commit: 8301dcc6d702a97feeb968ee79ae381fd8a4997a
Component: engine
2015-04-20 13:02:03 +02:00
396287023b gofmt whole directory
Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
Upstream-commit: edf541c22b5253a980ee061b35110d0da8fdb905
Component: engine
2015-04-20 01:08:51 -07:00
47592700e5 Add minor stylistic fixes
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: 1c89c6ea2f34f51a05215279c9cdefca30bb13b1
Component: engine
2015-04-16 21:22:32 +02:00
72996be1fe try to modprobe bridge
Signed-off-by: Jessica Frazelle <jess@docker.com>
Upstream-commit: b3867b889960604904a4afbab6450bb9528afe06
Component: engine
2015-04-15 07:19:37 -07:00
ff2ef2c440 Merge pull request #12300 from johngossman/master
Added some error messages and tracing to bridge network initialization
Upstream-commit: 3434f64827dc5e69afa7161a9da24a9117e7990a
Component: engine
2015-04-13 14:32:56 -04:00
a75ea8c667 Fix daemon panic when release a nil network interface
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: 8b3548129220a8c79342a12717d87667927df4c9
Component: engine
2015-04-13 20:24:10 +08:00
91af3b1937 Addressed feedback. Will squash after further review
Signed-off-by: John Gossman <johngos@microsoft.com>
Upstream-commit: 4ce19da739ccdb8337c59f841e790255d21c6f50
Component: engine
2015-04-12 15:49:29 -07:00
aeebc69e43 Added some error messages and tracing to bridge network initialization
Signed-off-by: John Gossman <johngos@microsoft.com>
Upstream-commit: a9843cb739bd30a9e6eeb8841f645008e1fc905f
Component: engine
2015-04-11 11:15:24 -07:00
0c091d906f Remove jobs from daemon/networkdriver/bridge
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 53582321ee502335a9c3be4789bef984e09f77c4
Component: engine
2015-04-08 18:50:29 -04:00
00cc5b6eeb Remove "stupid" wording
Signed-off-by: José Tomás Albornoz <jojo@eljojo.net>
Upstream-commit: 4cf5a1c2aa2f95a0bca5a0bf47026518b7b2167f
Component: engine
2015-04-04 15:26:45 +02:00
7f060d0ed1 Initialize portMapper in RequestPort too
Api requesting port for daemon before init_networkdriver called.
Problem is that now initialization of api depends on initialization of
daemon and their intializations runs in parallel. Proper fix will be
just do it sequentially. For now I don't want refactor it, because it
can bring additional problems in 1.6.0.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 584180fce7ad11516a256b8abd4621138337e918
Component: engine
2015-03-31 11:30:57 -07:00
45221d6bfb Ensure that bridge driver does not use global mappers
This has a few hacks in it but it ensures that the bridge driver does
not use global state in the mappers, atleast as much as possible at this
point without further refactoring.  Some of the exported fields are
hacks to handle the daemon port mapping but this results in a much
cleaner approach and completely remove the global state from the mapper
and allocator.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: d8c628cf082a50c0a2a5e381a21da8279a5462b4
Component: engine
2015-03-30 18:28:24 -07:00
cbb7d427c6 Refactor portmapper to remove ALL global state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 62522c98539e1591017cf0d4f28e6a58f3b1ec6b
Component: engine
2015-03-30 17:31:21 -07:00
163fcc5bfd Refactor port allocator to not have ANY global state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 43a50b06187e324e43b26003cace0f351a5fb78c
Component: engine
2015-03-30 17:30:59 -07:00
8b07e2892d Fix a typo in daemon/networkdriver/ipallocator/allocator.go
Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
Upstream-commit: 08331294bcabf90ce3d22dca729f206912d2a752
Component: engine
2015-03-30 08:31:46 +08:00
1c9316a817 Merge pull request #11788 from reikani/pchoi
Changed snake case naming to camelCase.
Upstream-commit: da5c863d20df8c030b3ffc6c4e95f976ed162721
Component: engine
2015-03-26 23:55:50 -07:00
e5b36a723c Replace aliased imports of logrus, fixes #11762
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: 6f4d847046cb4e072de61d042c0266190d73a8c9
Component: engine
2015-03-26 23:22:04 +01:00
0913f2905d Changed snake case naming to camelCase
Signed-off-by: Peter Choi <phkchoi89@gmail.com>
Upstream-commit: ae907e7af16136225417242ef5d55d3f6062fb3b
Component: engine
2015-03-26 15:05:45 -06:00
a16f3d6cb4 Remove engine.Status and replace it with standard go error
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: c79b9bab541673af121d829ebc3b29ff1b01efa2
Component: engine
2015-03-25 22:32:08 +01:00
558349d8ce Merge pull request #11689 from calavera/ipallocator_refactor
Use a structure to keep the allocated ips pool.
Upstream-commit: f7900cdd67e71a418d3cbfeb1b23315c5be78bdf
Component: engine
2015-03-24 12:42:30 -07:00
0185f15317 Use a structure to keep the allocated ips pool.
Fixes #11624.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 7e95b13460a58db75630d2d795482f39c68762c2
Component: engine
2015-03-24 11:41:44 -07:00
8938696741 Refactor global portallocator and portmapper state
Continuation of: #11660, working on issue #11626.

Wrapped portmapper global state into a struct. Now portallocator and
portmapper have no global state (except configuration, and a default
instance).

Unfortunately, removing the global default instances will break
```api/server/server.go:1539```, and ```daemon/daemon.go:832```, which
both call the global portallocator directly. Fixing that would be a much
bigger change, so for now, have postponed that.

Signed-off-by: Paul Bellamy <paul.a.bellamy@gmail.com>
Upstream-commit: 87df5ab41b3f9b2bdd8682f4afd41dac78f7e96d
Component: engine
2015-03-24 11:15:30 +00:00
7074731d32 Merge pull request #11636 from robertabbott/refactor_networkfs
Refactor pkg/networkfs
Upstream-commit: d5eea4e8b04074b709d1bbe19b5336504df44446
Component: engine
2015-03-23 16:58:29 -07:00
6be1b45eff Merge pull request #11545 from cpuguy83/remove_allocator_warning
Don't warn when ip_local_port_range not found
Upstream-commit: ccd4181d10752c41603fcc03bb6b576603b24271
Component: engine
2015-03-23 14:19:57 -07:00
4df1193b38 Refactor global portallocator state into a global struct
Signed-off-by: Paul Bellamy <paul.a.bellamy@gmail.com>
Upstream-commit: 12576798769081823a3f660b46290da808630616
Component: engine
2015-03-23 20:41:41 +00:00
f2b00f6fe1 Improve err message when parsing kernel port range
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 8e4d9f3cf9669f45b0591eea27c47b6f64d89c2d
Component: engine
2015-03-23 13:29:25 -07:00
4b8e196164 Refactor pkg/networkfs
Solves #11591

Signed-off-by: bobby abbott <ttobbaybbob@gmail.com>
Upstream-commit: a91b2431a303f919b0737d95639d8e445124cb23
Component: engine
2015-03-22 23:53:47 -07:00
005b71267c [WiP] Adds testing for bridge's IPv6 support
* fixes #10001
* test for global subnets <= 80
* test for global subnets > 80
* test link local allocations
* test duplicated addresses
* test regression from bug #11427

Signed-off-by: Christian Simon <simon@swine.de>
Upstream-commit: 4307ec283b817997bdcf989767a99d57f7361b9f
Component: engine
2015-03-18 08:51:14 +01:00
8da4d5374d Reduce logging level from error to warning if "/proc/sys/net/ipv4/ip_local_port_range" proc file in not accessible.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
Upstream-commit: 39d49ba7ba21f204f5fc174aaf319ed1cdad790f
Component: engine
2015-03-17 17:39:17 +00:00
1820b54f91 Merge pull request #11427 from LK4D4/fix_alloc_ip6
Fix IPv6 autoallocation from mac with --ipv6-cidr
Upstream-commit: 213be9ee2761828f56c7308bd85e4ca9fd33e34a
Component: engine
2015-03-16 16:38:46 -07:00
7a404617a3 Merge pull request #11402 from miminar/err-cleanup
Error formatting cleanups
Upstream-commit: 88f437d6c619f7b07a22cb5750814bce4d8d7164
Component: engine
2015-03-16 16:13:16 -07:00
aeed74c156 Fix IPv6 autoallocation from mac with --ipv6-cidr
We used slice globalIPv6Network.IP itself, not its copy as expected.

Fixes #10774

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 491f8ab14493babb1c06e240c7a9de64f34827a0
Component: engine
2015-03-16 15:36:50 -07:00
2781401caa fix various problems with iptables.Exists
This modifies iptables.Exists so that it must be called with an explicit
table and chain.  This allows us (a) to generate an appropriate command
line for "iptables -C", which was not previously possible, and (b) it
allows us to limit our strings.Contains() search to just the table and
chain in question, preventing erroneous matches against unrelated rules.

Resolves #10781

Signed-off-by: Lars Kellogg-Stedman <lars@redhat.com>
Upstream-commit: 3559b4177e611920d87c4dae607c641efb645783
Component: engine
2015-03-16 17:14:45 -04:00
c29e43cc4b Format error by value
- Use `%v` verb to format errors.
- Give `param` constant in portallocator some better name.

Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: 210ab030bc3dab7bcf8f7252f2f9facb5a26cb6b
Component: engine
2015-03-16 12:05:53 +01:00
dc9421e6d9 Pass buffered file reader to Fscanf instead of string reader
Unless `file` is wrapped with buffered reader, `fmt.Fscanf` will read
just one byte and terminate with `EOF`.

Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: 40d540637168fd5781e0c4a9cbd91959b7407d96
Component: engine
2015-03-13 09:40:53 +01:00
70fb9fcc59 Restructured port range loader
And renamed `GetPortRange` to `PortRange`.

Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: 0dcc970432677ddd13d8ed583de84ae075888228
Component: engine
2015-03-10 10:02:43 +01:00
c40472feb0 Use default port range in unit tests
Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: fcf8e85a35cddfd1f75f652a513015bb6f169257
Component: engine
2015-03-09 16:58:14 +01:00
054ec22a23 Use system's ephemeral port range for port allocation
Read `/proc/sys/net/ipv4/ip_local_port_range` kernel parameter to obtain
ephemeral port range that now sets the boundaries of port allocator
which finds free host ports for those exported by containers.

Signed-off-by: Michal Minar <miminar@redhat.com>
Upstream-commit: 0eb3544c43cb8e9488d6bf329ceecc11fa0db6f1
Component: engine
2015-03-09 09:13:20 +01:00
8d2cefd5a5 Seems like an un-necessary if statement
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
Upstream-commit: 4e5ea0c8755231dfffd7b82bc6551415b14ed0de
Component: engine
2015-03-04 13:24:17 -08:00
1e821173bd Just format some logs and notes in /daemon/networkdriver/bridge/driver.go
Signed-off-by: Zen Lin(Zhinan Lin) <linzhinan@huawei.com>
Upstream-commit: 2c0e027ab9b7da131451d571c4d0f25bc5fc14eb
Component: engine
2015-03-03 23:39:04 +08:00