Commit Graph

121 Commits

Author SHA1 Message Date
David Mackey 3941623fbc trivial: typo cleanup
Signed-off-by: David Mackey <tdmackey@booleanhaiku.com>
2015-04-27 13:35:08 -07:00
John Howard ae9905ef9c Fixed typo 'configuring'
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-04-24 16:52:32 -07:00
Tibor Vass 259effc6df Merge pull request #9397 from jpopelka/9395-firewalld
Firewalld support
2015-04-23 16:58:08 -04:00
Jessie Frazelle 4a25c5d25b Merge pull request #12533 from ankushagarwal/gofmt-directory
gofmt 1.4.2  src directory
2015-04-20 17:02:43 -07:00
Arnaud Porterie 9838242db1 Merge pull request #9381 from lebauce/default-gateway
Proposal: Allow specifying a default gateway for bridge networking
2015-04-20 15:50:35 -07:00
Sylvain Baubeau acb6127c1a Allow specifying a default gateway for bridge networking
Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
2015-04-20 15:13:30 +02:00
Jiri Popelka b052827e02 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>
2015-04-20 13:02:09 +02:00
Jiri Popelka 8301dcc6d7 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>
2015-04-20 13:02:03 +02:00
Ankush Agarwal edf541c22b gofmt whole directory
Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
2015-04-20 01:08:51 -07:00
Antonio Murdaca 1c89c6ea2f Add minor stylistic fixes
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-04-16 21:22:32 +02:00
Jessica Frazelle b3867b8899 try to modprobe bridge
Signed-off-by: Jessica Frazelle <jess@docker.com>
2015-04-15 07:19:37 -07:00
Evan Hazlett 3434f64827 Merge pull request #12300 from johngossman/master
Added some error messages and tracing to bridge network initialization
2015-04-13 14:32:56 -04:00
Lei Jitang 8b35481292 Fix daemon panic when release a nil network interface
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-04-13 20:24:10 +08:00
John Gossman 4ce19da739 Addressed feedback. Will squash after further review
Signed-off-by: John Gossman <johngos@microsoft.com>
2015-04-12 15:49:29 -07:00
John Gossman a9843cb739 Added some error messages and tracing to bridge network initialization
Signed-off-by: John Gossman <johngos@microsoft.com>
2015-04-11 11:15:24 -07:00
Tibor Vass 53582321ee Remove jobs from daemon/networkdriver/bridge
Signed-off-by: Tibor Vass <tibor@docker.com>
2015-04-08 18:50:29 -04:00
José Tomás Albornoz 4cf5a1c2aa Remove "stupid" wording
Signed-off-by: José Tomás Albornoz <jojo@eljojo.net>
2015-04-04 15:26:45 +02:00
Alexander Morozov 584180fce7 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>
2015-03-31 11:30:57 -07:00
Michael Crosby d8c628cf08 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>
2015-03-30 18:28:24 -07:00
Michael Crosby 62522c9853 Refactor portmapper to remove ALL global state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-03-30 17:31:21 -07:00
Michael Crosby 43a50b0618 Refactor port allocator to not have ANY global state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-03-30 17:30:59 -07:00
Yuan Sun 08331294bc Fix a typo in daemon/networkdriver/ipallocator/allocator.go
Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
2015-03-30 08:31:46 +08:00
Brian Goff da5c863d20 Merge pull request #11788 from reikani/pchoi
Changed snake case naming to camelCase.
2015-03-26 23:55:50 -07:00
Antonio Murdaca 6f4d847046 Replace aliased imports of logrus, fixes #11762
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-03-26 23:22:04 +01:00
Peter Choi ae907e7af1 Changed snake case naming to camelCase
Signed-off-by: Peter Choi <phkchoi89@gmail.com>
2015-03-26 15:05:45 -06:00
Antonio Murdaca c79b9bab54 Remove engine.Status and replace it with standard go error
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-03-25 22:32:08 +01:00
Alexander Morozov f7900cdd67 Merge pull request #11689 from calavera/ipallocator_refactor
Use a structure to keep the allocated ips pool.
2015-03-24 12:42:30 -07:00
David Calavera 7e95b13460 Use a structure to keep the allocated ips pool.
Fixes #11624.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-03-24 11:41:44 -07:00
Paul Bellamy 87df5ab41b 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>
2015-03-24 11:15:30 +00:00
Jessie Frazelle d5eea4e8b0 Merge pull request #11636 from robertabbott/refactor_networkfs
Refactor pkg/networkfs
2015-03-23 16:58:29 -07:00
Jessie Frazelle ccd4181d10 Merge pull request #11545 from cpuguy83/remove_allocator_warning
Don't warn when ip_local_port_range not found
2015-03-23 14:19:57 -07:00
Paul Bellamy 1257679876 Refactor global portallocator state into a global struct
Signed-off-by: Paul Bellamy <paul.a.bellamy@gmail.com>
2015-03-23 20:41:41 +00:00
Brian Goff 8e4d9f3cf9 Improve err message when parsing kernel port range
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-03-23 13:29:25 -07:00
bobby abbott a91b2431a3 Refactor pkg/networkfs
Solves #11591

Signed-off-by: bobby abbott <ttobbaybbob@gmail.com>
2015-03-22 23:53:47 -07:00
Christian Simon 4307ec283b [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>
2015-03-18 08:51:14 +01:00
Vishnu Kannan 39d49ba7ba 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)
2015-03-17 17:39:17 +00:00
Jessie Frazelle 213be9ee27 Merge pull request #11427 from LK4D4/fix_alloc_ip6
Fix IPv6 autoallocation from mac with --ipv6-cidr
2015-03-16 16:38:46 -07:00
Michael Crosby 88f437d6c6 Merge pull request #11402 from miminar/err-cleanup
Error formatting cleanups
2015-03-16 16:13:16 -07:00
Alexander Morozov 491f8ab144 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>
2015-03-16 15:36:50 -07:00
Lars Kellogg-Stedman 3559b4177e 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>
2015-03-16 17:14:45 -04:00
Michal Minar 210ab030bc 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>
2015-03-16 12:05:53 +01:00
Michal Minar 40d5406371 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>
2015-03-13 09:40:53 +01:00
Michal Minar 0dcc970432 Restructured port range loader
And renamed `GetPortRange` to `PortRange`.

Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-10 10:02:43 +01:00
Michal Minar fcf8e85a35 Use default port range in unit tests
Signed-off-by: Michal Minar <miminar@redhat.com>
2015-03-09 16:58:14 +01:00
Michal Minar 0eb3544c43 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>
2015-03-09 09:13:20 +01:00
Sven Dowideit 4e5ea0c875 Seems like an un-necessary if statement
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2015-03-04 13:24:17 -08:00
Zen Lin(Zhinan Lin) 2c0e027ab9 Just format some logs and notes in /daemon/networkdriver/bridge/driver.go
Signed-off-by: Zen Lin(Zhinan Lin) <linzhinan@huawei.com>
2015-03-03 23:39:04 +08:00
Zen Lin(Zhinan Lin) e5bc50b5cd fix err in note at daemon/networkdriver/bridge/driver.go
Signed-off-by: Zen Lin(Zhinan Lin) <linzhinan@huawei.com>
2015-03-03 00:52:53 +08:00
Michael Crosby ffc499dbab Merge pull request #10215 from taohu/remove-assumption-first-ip-is-bridge-ip
Remove the assumption that the first IP is the bridge IP
2015-02-06 14:15:46 -08:00
Erik Hollensbe 8d7683af86 Remove "OMG IPV6" log message
Signed-off-by: Erik Hollensbe <erik+github@hollensbe.org>
2015-01-31 13:21:06 -08:00