Commit graph

75 commits

Author SHA1 Message Date
Flavio Crisciani
3684df4a66 Flush container flows in conntrack (Bug #8795)
Flush all the endpoint flows when the external
connectivity is removed.
This will prevent issues where if there is a flow
in conntrack this will have precedence and will
let the packet skip the POSTROUTING chain.

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-04-07 18:30:45 -07:00
Max Timchenko
fc2414f988 Ensure iptables initialization only happens once
I saw a rare race during the first few calls to iptables module
where some of them would reenter initCheck() after the first call
to it already changed iptablesPath, but before the rest of the function
completed (in particular the long execs into testing for availability
of --wait flag and determining iptables version), resulting in
failure of one or more of iptables calls that did not use --wait and
were concurrent.

To fix the problem, this change gathers all one-time initialization into a
single function under a sync.Once instead of using a global variable
as a "done initializing" flag before initialization is done. sync.Once
guarantees all concurrent calls will block until the first one completes.

In addition, it turns out that GetVersion(), called from initCheck(), used
Raw() which called back into initCheck() via raw(), which did not cause a
problem in the earlier implementation but deadlocked when initialization became
strict.  This was changed to use a direct call, similar to initialization of
supportsXlock.

Signed-off-by: Max Timchenko <max@maxvt.com>
2017-03-08 20:37:13 +02:00
Santhosh Manohar
b2430cc299 Merge pull request #961 from JrCs/fix-iptables-order
Fix bad order of iptables filter rules
2017-03-05 20:28:22 -08:00
Alessandro Boch
595246bdfb Merge pull request #1568 from likel/refactor
Remove unnecessary string formats
2016-12-29 12:18:06 -08:00
Alessandro Boch
e2f0070492 Fix xtables_lock message probe
- iptables pkg functions are coded to discard
  the xtables_lock error message about acquiring
  the lock, because all the calls are done with
  the wait logic. But the error message has
  slightly changed between iptables 1.4.x and 1.6.
  This lead to false positives causing docker
  network create to fil in presence of concurrent calls.
- Fixed message mark to be common among the two main versions.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-21 22:02:07 -08:00
Ke Li
23ac56fdd0 Remove unnecessary string formats
Signed-off-by: Ke Li <kel@splunk.com>
2016-11-22 09:29:53 +08:00
Alessandro Boch
5b4059e087 Fix new golint reported errors
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-14 16:41:54 -08:00
Madhu Venugopal
5040d8ccd7 Merge pull request #1526 from sanimej/policy
when enabling ip forwarding set the default forward policy to drop
2016-11-10 10:12:26 -08:00
Santhosh Manohar
9f2ecdcd9d If enabling ip forwarding set the default forward policy to drop
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-11-03 20:38:43 -07:00
Alessandro Boch
a21d577b8b Block non exposed port traffic on ingress nw interfaces
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-10-27 20:28:08 -07:00
Alessandro Boch
795697d823 Check for presence before installing forward rules
- same for links rules

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-10-13 14:33:23 -07:00
Yves Blusseau
6149b1f32f Fix bad order of iptables filter rules
Rules with ctstate RELATED,ESTABLISHED must be create before same
rules without ctstate.

Signed-off-by: Yves Blusseau <90z7oey02@sneakemail.com>
2016-04-16 18:42:13 +02:00
Alessandro Boch
52da8bda47 modprobe when needed
- in bridge driver modprobe for br_netfilter only if EnableIPTables==true
- move FirewalldInit() to iptables pakcage Init()
- move modprobe for nf_nat and xt_conntrack in iptables.initCheck()

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-03-21 16:35:28 -07:00
Alessandro Boch
8cf7270d06 Miscellaneous fixes
- Fix npe in sbJoin error path
- Fail again endpoint Join in case of failure
  in programming the external connectivity
- In bridge, look for parent and child container configs
  in the generic data
- iptables.Exists() might be called before any other call to
  iptables.raw(). We need to call checkInit() then.

Introduced by 1638fbdf27

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-03-08 15:49:47 -08:00
Alessandro Boch
2cb645bf57 Fix iptables.Exists logic
- Fixed exists to attempt a raw exists check only when
  "iptables -C ..." execution returns error becasue of "unsupported option"
- Fixed raw exists to not match substring
- Added GetVersion method

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-02-22 11:20:36 -08:00
Alessandro Boch
defcd4afb9 Change in programming iptables in container
- iptables to provide a native API
- resolver.go to invoke the iptables native API
  when programming tables in the container

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-02-05 15:25:43 -08:00
Chun Chen
797c32bcac Clean up docker chain of filter table as well on driver init
Signed-off-by: Chun Chen <ramichen@tencent.com>
2016-01-05 13:02:16 +08:00
Alessandro Boch
95f1bcc249 Change isolation rules for multiple bridge networks
- From subnet to interface

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-23 15:45:27 -08:00
Zhang Wei
e4ce59b7aa Cleanup iptables after bridge network is removed
Fixed #570

Clean unused iptables rules after bridge network is removed

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2015-11-10 17:53:54 +08:00
Mohammad Banikazemi
12df37fdd0 Seperates the driver-specific and network-specific iptable operations
for the bridge driver.

Moves two config options, namely EnableIPTables and EnableUserlandProxy
from networks to the driver.

Closes #242
Signed-off-by: Mohammad Banikazemi <MBanikazemi@gmail.com>
2015-08-04 17:26:41 -04:00
Arnaud Porterie
9e7d2fe74e Fix duplicated iptables rules
The `iptables.Exists` function is wrong in two ways:
1. The iptables -C call doesn't add `-j DOCKER` and fails to match
2. The long path takes ordering into account in comparison and fails to match

This patch fixes issue 1 by including `-j DOCKER` in the check.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-06-16 10:46:47 -07:00
Madhu Venugopal
903fcbd154 enable hairpin mode on the bridge port & fix iptables rule
* When userland-proxy is disabled, enable hairpin mode on the host-side of the veth
* When userland-proxy is enabled, fix the iptable rules appropriately

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-11 19:23:02 -07:00
Madhu Venugopal
56375f3687 Porting https://github.com/docker/docker/pull/12437
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-19 15:28:48 -07:00
Alessandro Boch
902e8746d3 Optional Userland Proxy
- Port https://github.com/docker/docker/pull/12165 to libnetwork
- More tests will be added later

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-18 18:13:39 -07:00
Alessandro Boch
f16db2c3ad Remove pkg directory
- As recommended by Docker committers.
- Will introduce internal directory when go supports it

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-16 16:12:13 -07:00
Renamed from libnetwork/pkg/iptables/iptables.go (Browse further)