Commit graph

676 commits

Author SHA1 Message Date
Sebastiaan van Stijn
cdbca4061b
gofmt GoDoc comments with go1.19
Older versions of Go don't format comments, so committing this as
a separate commit, so that we can already make these changes before
we upgrade to Go 1.19.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 52c1a2fae8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-13 22:42:29 +02:00
Youfu Zhang
f70a9788c5 drivers/ipvlan: add ipvlan_flag option, support l3s ipvlan_mode
Signed-off-by: Youfu Zhang <zhangyoufu@gmail.com>
2022-06-28 19:28:49 +08:00
Martin Braun
5edfd6d081 bump netlink library
bump netlink to 1.2.1
change usages of netlink handle .Delete() to Close()
remove superfluous replace in vendor.mod
make requires of github.com/Azure/go-ansiterm direct

Signed-off-by: Martin Braun <braun@neuroforge.de>
2022-06-16 22:25:33 +02:00
Sebastiaan van Stijn
6e80c027c5
Merge pull request #43409 from vincentbernat/fix/udp-conntrack
bridge: also flush conntrack entries when setting up endpoints
2022-06-03 11:29:25 +02:00
Ameya Gawde
cba8cf34d2
Set ExternalPortReserved for dummy proxy
Signed-off-by: Ameya Gawde <agawde@mirantis.com>
2022-05-25 07:12:43 -07:00
Eng Zer Jun
7873c27cfb
all: replace strings.Replace with strings.ReplaceAll
strings.ReplaceAll(s, old, new) is a wrapper function for
strings.Replace(s, old, new, -1). But strings.ReplaceAll is more
readable and removes the hardcoded -1.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-05-09 19:45:40 +08:00
Vincent Bernat
e5812117a5 bridge: also flush conntrack entries when setting up endpoints
There is a race condition between the local proxy and iptables rule
setting. When we have a lot of UDP traffic, the kernel will create
conntrack entries to the local proxy and will ignore the iptables
rules set after that.

Related to PR #32505. Fix #8795.

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
2022-03-23 08:34:26 +01:00
Martin Dojcak
feab0cca9f libnetwork/overlay:fix join sandbox deadlock
Operations performed on overlay network sandboxes are handled by
dispatching operations send through a channel. This allows for
asynchronous operations to be performed which, since they are
not called from within another function, are able to operate in
an idempotent manner with a known/measurable starting state from
which an identical series of iterative actions can be performed.

However, it was possible in some cases for an operation dispatched
from this channel to write a message back to the channel in the
case of joining a network when a sufficient volume of sandboxes
were operated on.

A goroutine which is simultaneously reading and writing to an
unbuffered channel can deadlock if it sends a message to a channel
then waits for it to be consumed and completed, since the only
available goroutine is more or less "talking to itself". In order
to break this deadlock, in the observed race, a goroutine is now
created to send the message to the channel.

Signed-off-by: Martin Dojcak <martin.dojcak@lablabs.io>
Signed-off-by: Ryan Barry <rbarry@mirantis.com>
2022-03-22 11:15:14 -04:00
Sebastiaan van Stijn
1b3fef5333
Windows: require Windows Server RS5 / ltsc2019 (build 17763) as minimum
Windows Server 2016 (RS1) reached end of support, and Docker Desktop requires
Windows 10 V19H2 (version 1909, build 18363) as a minimum.

This patch makes Windows Server RS5 /  ltsc2019 (build 17763) the minimum version
to run the daemon, and removes some hacks for older versions of Windows.

There is one check remaining that checks for Windows RS3 for a workaround
on older versions, but recent changes in Windows seemed to have regressed
on the same issue, so I kept that code for now to check if we may need that
workaround (again);

085c6a98d5/daemon/graphdriver/windows/windows.go (L319-L341)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-18 22:58:28 +01:00
Sebastiaan van Stijn
25594c33b9
libnetwork: replace consul with boltdb in test
Based on randomLocalStore() in libnetwork/ipam/allocator_test.go

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-06 18:45:07 +01:00
Albin Kerouanton
c721bad8cc
Fix flaky TestPortMappingV6Config
Since moby/libnetwork#2635 has been merged, allocatePortsInternal()
checks if IPv6 is enabled by calling IsV6Listenable(). This function
calls `net.Listen("tcp6", "[::1]:0")` and returns false when
net.Listen() fails.

TestPortMappingV6Config() starts by setting up a new net ns to run into
it. The loopback interface is not bring up in this net ns, thus
net.Listen() fails and IsV6Listenable() returns false. This change takes
care of bringing loopback iface up right after moving to the new net ns.

This test has been reported has flaky on s390x in #42468. For some
reason, this test seems to be consistently green on the CI (on amd64
arch) and when running `hack/test/unit` locally. However it consistently
fails when running `TESTFLAGS='-shuffle on' hack/test/unit` locally.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2021-11-16 09:37:34 +01:00
Eng Zer Jun
c55a4ac779
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated in Go 1.16. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-08-27 14:56:57 +08:00
Sebastiaan van Stijn
686be57d0a
Update to Go 1.17.0, and gofmt with Go 1.17
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-24 23:33:27 +02:00
Sebastiaan van Stijn
427ad30c05
libnetwork: remove unused "testutils" imports
Perhaps the testutils package in the past had an `init()` function to set up
specific things, but it no longer has. so these imports were doing nothing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-18 14:20:37 +02:00
Brian Goff
116f200737
Fix gosec complaints in libnetwork
These were purposefully ignored before but this goes ahead and "fixes"
most of them.
Note that none of the things gosec flagged are problematic, just
quieting the linter here.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-25 18:02:03 +02:00
yalpul
967ec6f2e8 Fix typo in macvlan_setup.go
Signed-off-by: yalpul <yalpul@gmail.com>
2021-06-19 11:36:16 +03:00
Sebastiaan van Stijn
76640e5d39
drivers/bridge: format comments
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-10 18:06:07 +02:00
Sebastiaan van Stijn
da0a006b14
drivers/bridge: dont use types.ParseCIDR() for fixed value
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-10 18:06:04 +02:00
Sebastiaan van Stijn
508a0979d9
bridge: remove unused "others" argument from isolateNetwork()
This argument was used to detect conflicts, but was later removed in
1c73b1c99c14d7f048a2318a3caf589865c76fad.

However, it was never removed, and we were still getting a list
of all networks, without using the results.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-09 22:23:38 +02: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
00b2c13a1b Fix some windows issues in libnetwork tests
Fix build constraints for linux-only network drivers

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 23:48:23 +00:00
Brian Goff
20fd1dd7d2 Skip some windows network driver tests
These are failing in CI because something is not enabled.
Its not clear that these tests ever worked because they were not
actually running while in the libnetwork repo, which was only testing
Linux.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 22:15:10 +00:00
Brian Goff
72c4a7b496 Fix issues running libnetwork tests.
libnetwork does different stuff depending on if you are running the
tests in a container or not... without telling it we are in a container
a bunch of the tests actually fail.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 22:14:41 +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
Akihiro Suda
325668315c fix port forwarding with ipv6.disable=1
Make `docker run -p 80:80` functional again on environments with kernel boot parameter `ipv6.disable=1`.

Fix moby/moby issue 42288

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-04-27 15:46:07 +09:00
Arko Dasgupta
5d3b0102f7 Use hostIP to decide on Portmapper version
Use HostIP to decide which portmapper object to store the binding
in consistently in the allocate and release method (b506539e9c/drivers/bridge/port_mapping.go (L208))

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2021-01-23 12:00:46 -08:00
Arko Dasgupta
4f9af99194 Fix regression in docker-proxy
Allow proxying IPv6 traffic to the container's IPv4 interface
if `--ipv6` is disabled and the container does not have a
IPv6 address, when the docker-proxy / `userland-proxy` is enabled
on `dockerd`

Relates to https://github.com/moby/libnetwork/issues/2607

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2021-01-14 17:51:09 -08:00
Arko Dasgupta
33a82a26a8 Fix IPv6 Port Forwarding for the Bridge Driver
1. Allocate either a IPv4 and/or IPv6 Port Binding (HostIP, HostPort, ContainerIP,
ContainerPort) based on the input and system parameters
2. Update the userland proxy as well as dummy proxy (inside port mapper) to
specifically listen on either the IPv4 or IPv6 network

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2020-12-14 18:46:22 -08:00
Arko Dasgupta
09be71b900 Merge pull request #2603 from bboehmke/ipv6_portmapper_chain
Fixed IPv6 portmapper iptables chain initialization
2020-12-11 10:39:35 -08:00
Benjamin Böhmke
06308f4d37 setup IPv4 and IPv6 iptables chain
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-12-11 11:12:41 +01:00
Arko Dasgupta
b7c663c2ec Make sure IPv6 is enabled for IP6tables
Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2020-12-11 00:39:42 -08:00
Arko Dasgupta
dc6cbb55b4 Merge pull request #2572 from bboehmke/ipv6_nat
Enable IPv6 NAT (rebase of #2023)
2020-10-29 14:13:58 -07:00
Tibor Vass
20c88eb92f Merge pull request #2583 from thaJeztah/update_docker_alt
vendor: update docker to 7ca355652f and reduce dependency graph
2020-09-17 13:29:33 -07:00
Sebastiaan van Stijn
3e1e9e878c vendor: gotest.tools v3.0.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-09-12 03:22:18 +02:00
Sebastiaan van Stijn
bf28003c99 Replace use of deprecated functions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-09-12 01:49:42 +02:00
Sebastiaan van Stijn
6dde6cb0b0 drivers/macvlan: skip kernel version check
All distros that are supported by Docker now have at least
kernel version 3.10, so this check should no longer be needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-31 20:45:02 +02:00
Sebastiaan van Stijn
02d313ca15 drivers/bridge: skip kernel version check
All distros that are supported by Docker now have at least
kernel version 3.10, so this check should no longer be needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-31 20:44:51 +02:00
Benjamin Böhmke
34f4706174 added TODOs for open IPv6 point
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-23 16:52:40 +02:00
Benjamin Böhmke
648d891827 reworked allocatePorts
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-22 15:43:02 +02:00
Benjamin Böhmke
1e1408f421 additional EnableIPTables check in isolateNetwork
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-22 15:06:19 +02:00
Benjamin Böhmke
a4fcced708 enabled ipv6 parameter in TestSetupIPForwarding
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-22 15:05:51 +02:00
Benjamin Böhmke
4d1c92c155 resorted EnableIP6Tables in driver configure
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-21 18:50:03 +02:00
Benjamin Böhmke
9bc2f88f04 isolateNetwork for both IP version
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-21 18:14:19 +02:00
Benjamin Böhmke
ccad03a139 split setupIPTables into setupIP4Tables and setupIP6Tables
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-21 18:14:07 +02:00
Benjamin Böhmke
9cf5335269 default DROP policy on firewall reload also for IPv6
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-21 15:24:20 +02:00
Benjamin Böhmke
ec7df93731 replace string.Contains* with net.IP.To4() check
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-21 15:23:33 +02:00
Benjamin Böhmke
3475f006b7 moved some ipv6 config to setupIPForwarding
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-19 16:17:02 +02:00
Benjamin Böhmke
dfd1925ed1 Renamed driver config variable to EnableIP6Tables
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-19 16:17:02 +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
Sebastiaan van Stijn
27345e8f8f log error instead if disabling IPv6 router advertisement failed
Previously, failing to disable IPv6 router advertisement prevented the daemon to
start.

An issue was reported by a user that started docker using `systemd-nspawn "machine"`,
which produced an error;

    failed to start daemon: Error initializing network controller:
    Error creating default "bridge" network: libnetwork:
    Unable to disable IPv6 router advertisement:
    open /proc/sys/net/ipv6/conf/docker0/accept_ra: read-only file system

This patch changes the error to a log-message instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-12 19:32:18 +02:00