Commit graph

105 commits

Author SHA1 Message Date
Brian Goff
7186fd8a95 More libnetwork windows test fixes
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-02 16:53:24 +00:00
Brian Goff
4b981436fe Fixup libnetwork lint errors
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 23:48:32 +00:00
Brian Goff
a0a473125b Fix libnetwork imports
After moving libnetwork to this repo, we need to update all the import
paths for libnetwork to point to docker/docker/libnetwork instead of
docker/libnetwork.
This change implements that.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 21:51:23 +00:00
Benjamin Böhmke
a6d7b43dfc fixed IPv6 iptables rules for enabled firewalld
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2021-01-07 17:46:32 +01:00
Benjamin Böhmke
d14b7a5191 fixed ip6tables command in error message
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-12-11 11:10:55 +01:00
Benjamin Böhmke
9f98bd79d8 reworked comment of IPTable struct
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-22 15:08:22 +02:00
Billy Ridgway
8dbb5b5a7d Implement NAT IPv6 to fix the issue https://github.com/moby/moby/issues/25407
Signed-off-by: Billy Ridgway <wrridgwa@us.ibm.com>
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-19 16:16:51 +02:00
Arko Dasgupta
23d1ca4426 Add docker interfaces to firewalld docker zone
If firewalld is running, create a new docker zone and
add the docker interfaces to the docker zone to allow
container networking for distros with firewalld enabled

Fixes: https://github.com/moby/libnetwork/issues/2496

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2020-05-07 18:37:33 -07:00
Akihiro Suda
7ca71f2c49 vendor godbus/dbus v5
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-02-28 18:47:00 +09:00
Danny Milosavljevic
6b5dc55e93 Use fewer modprobes
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
2019-04-10 17:32:39 +02:00
Arko Dasgupta
068ca7d046 Revert "debian has iptables-legacy and iptables-nft now"
This reverts commit 7adcd856fe.

Libnetwork should only use the iptables binary. Iptables v1.8 and above
uses the nftables backend. The translations for all the rules used by
libnetwork is supported by the new iptables binary.

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2019-03-01 11:50:47 -08:00
Nathan Herald
7adcd856fe debian has iptables-legacy and iptables-nft now
Signed-off-by: Nathan Herald <me@nathanherald.com>
2018-10-31 09:14:35 -07:00
Josh Soref
a06f1b2c4e Spelling fixes
* addresses
* assigned
* at least
* attachments
* auxiliary
* available
* cleanup
* communicate
* communications
* configuration
* connection
* connectivity
* destination
* encountered
* endpoint
* example
* existing
* expansion
* expected
* external
* forwarded
* gateway
* implementations
* implemented
* initialize
* internally
* loses
* message
* network
* occurred
* operational
* origin
* overlapping
* reaper
* redirector
* release
* representation
* resolver
* retrieve
* returns
* sanbdox
* sequence
* succesful
* synchronizing
* update
* validates

Signed-off-by: Josh Soref <jsoref@gmail.com>
2018-07-12 12:54:44 -07:00
Chris Telfer
3df00a6c64 Add wait time into xtables lock warning
Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-04-26 14:21:36 -04:00
Chris Telfer
16e077b884 Filter xtable wait messages when using firewalld
This gets filtered for raw iptables calls, but not from calls made
through firewalld.   The patch just ensures consistency of operation.
It also adds a warning when xtables contention detected and truncates
the search string slightly as it appears that the suffix will be
changing in the near future.

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-04-25 16:26:08 -04:00
Wataru Ishida
2120ed2363 Support SCTP port mapping
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-02-13 16:01:03 +09:00
Brian Goff
1dcffbeb3f Disable hostname lookup on chain exists check
Without `-n`, iptables will attempt to lookup hostnames for IP
addresses, which can slow down the call dramatically.
Since we don't need this, and generally don't even care about the
output, use the `-n` flag to disable this.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-10-07 09:06:06 -04:00
Flavio Crisciani
729d45379f Fix lint issues
The package updated and now shows new warnings that had to be corrected
to let the CI pass

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-09-20 08:57:02 -07:00
Derek McGowan
710e0664c4 Update logrus to v1.0.1
Fix case sensitivity issue
Update docker and runc vendors

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-07 11:20:47 -07:00
Flavio Crisciani
daba67d67b Avoid flakiness of TestLinkContainers
Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-07-21 13:54:19 -07:00
Flavio Crisciani
65860255c6 Fixed code issues
Fixed issues highlighted by the new checks

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-06-12 11:31:35 -07:00
Jacob Wen
c348cebe99 Add a filter chain to allow persistent rules
Allow users to configure firewall policies in a way that persists
docker operations/restarts. Docker will not delete or modify any
pre-existing rules from the DOCKER-USER filter chain. This allows
the user to create in advance any rules required to further
restrict access from/to the containers.

Fixes docker/docker#29184
Fixes docker/docker#23987
Related to docker/docker#24848

Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
2017-05-16 10:24:56 +08:00
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
Alessandro Boch
e5c1a4cabd Remove firewalld running log
- The info it provides can be found elsewhere
  The logs gets printed too often becasue of
  the programming being done in the tasks

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-04-06 21:09:49 -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
Alexander Morozov
a971c561d1 Close dbus connection if firewalld is not started
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-09 09:31:22 -08: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
aboch
5c562e2c33 Merge pull request #591 from WeiZhang555/iptables-clean
Cleanup iptables after bridge network is removed
2015-11-25 09:12:10 -08:00
Antonio Murdaca
c1b67065e6 godeps: update coreos/go-systemd to v4 and godbus/dbus to v3
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2015-11-20 00:19:47 +01: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
David Calavera
cc02894a50 Move test specific functions to a testutils package.
This way we won't vendor test related functions in docker anymore.
It also moves netns related functions to a new ns package to be able to
call the ns init function in tests. I think this also helps with the
overall package isolation.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-09-07 13:33:28 -04: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
Madhu Venugopal
3a8213e40a Fixed the tests.
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-16 10:46:51 -07: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
Alessandro Boch
c70cfcb150 Provide interface to categorize errors
- Package types to define the interfaces libnetwork errors
  may implement, so that caller can categorize them.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-20 22:29:29 -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
1589c43f9d Restore anonymus import in iptables_test.go
- Which is needed when running make (test in container)

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-18 21:56:36 -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