Commit graph

35 commits

Author SHA1 Message Date
Sebastiaan van Stijn
f714730c40
libnetwork/portallocator: PortAllocator.ReleasePort: remove unused err-return
This function never returned an error, and was not matching an interface, so
remove the error-return.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-02 11:00:22 +01:00
Sebastiaan van Stijn
214ab2caef
libnetwork/portmapper: PortMapper.MapRange: inline "cleanup" closure
The cleanup function never returns an error, so didn't add much value. This
patch removes the closure, and calls it inline to remove the extra
indirection, and removes the error which would never be returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-29 14:30:42 +01:00
Sebastiaan van Stijn
6ae6dcfc53
libnetwork/portmapper: PortMapper.MapRange: fix defer
The defer was set after the switch, but various code-paths inside the switch
could return with an error after the port was allocated / reserved, which
could result in those ports not being released.

This patch moves the defer into each individual branch of the switch to set
it immediately after succesfully reserving the port.

We can also remove a redundant ReleasePort from the cleanup function, as
it's only called if an error occurs, and the defers already take care of
that.

Note that the cleanup function was handling errors returned by ReleasePort,
but this function never returns an error, so it was fully redundant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-29 14:26:56 +01:00
Sebastiaan van Stijn
8712c6df22
libnetwork/portmapper: PortMapper.MapRange: rename err-return
Prevent accidentally shadowing the error, which is used in a defer.
Also re-format the code to make it more clear we're not acting on
a locally-scoped "allocatedHostPort" variable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-29 14:26:06 +01:00
Sebastiaan van Stijn
cff4f20c44
migrate to github.com/containerd/log v0.1.0
The github.com/containerd/containerd/log package was moved to a separate
module, which will also be used by upcoming (patch) releases of containerd.

This patch moves our own uses of the package to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 17:52:23 +02:00
Sebastiaan van Stijn
f5d6af13d0
libnetwork/portmapper: un-export PortMapper.Allocator
It was only accessed through methods on PortMapper, and in tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-13 18:38:53 +02:00
Sebastiaan van Stijn
863909a749
libnetwork/portmapper: New(): remove unused argument
None of the code using this function was setting the value, so let's
simplify and remove the argument.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-13 18:12:53 +02:00
Brian Goff
74da6a6363 Switch all logging to use containerd log pkg
This unifies our logging and allows us to propagate logging and trace
contexts together.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-06-24 00:23:44 +00:00
Sebastiaan van Stijn
f6be7f2945
portmapper: minor linting fix, and comment purpose of newProxy variable
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-17 10:27:31 +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
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
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
Benjamin Böhmke
4886e5e5b1 Added improved IP validation for port mapper
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-11-20 23:03:35 +01:00
Benjamin Böhmke
648d891827 reworked allocatePorts
Signed-off-by: Benjamin Böhmke <benjamin@boehmke.net>
2020-07-22 15:43: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
Sascha Grunert
c5c8653912 Update sctp package
This commit updates the vendored ishidawataru/sctp and adapts its used
types.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-06-24 17:26:33 +02:00
Pradip Dhara
1909ecb27a Pick a random host port if the user does not specify a host port.
For overlay, l2bridge, and l2tunnel, if the user does not specify a host port, windows driver will select a random port for them.  This matches linux behavior.
For ics and nat networks the windows OS will choose the port.

Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
2019-04-22 17:43:27 +00: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
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
Antonio Murdaca
38338863dc bridge,portmapper: custom docker-proxy path
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-09-25 18:07:58 +02:00
Michael Stapelberg
1b899469a6 portmapper: touch iptables only for IPv4
split out of https://github.com/docker/docker/pull/20315
in order to fix https://github.com/docker/docker/issues/11518

Signed-off-by: Michael Stapelberg <stapelberg@google.com>
2016-07-31 00:29:24 +02:00
Justin Cormack
5202f95604 Make the docker proxy a standalone binary not a re-exec
Rather than re-execing docker as the proxy, create a new command docker-proxy
that is much smaller to save memory in the case where there are a lot of
procies being created. Also allows the proxy to be replaced, for example
in Docker for Mac we have a proxy that proxies to osx instead of locally.

This is the vendoring pull for https://github.com/docker/docker/pull/23312

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2016-07-04 13:17:16 +01:00
Daniel Dao
44cb162f3d lock port mapper when reapply iptables rules
Make sure that port mapper state is not updated while we are trying to remap
everything.

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-08-26 22:12:40 +00:00
Don Kjer
8d73de9722 Adding libnetwork support to publish on custom host port ranges.
See https://github.com/docker/docker/pull/12927 for docker portion.

Signed-off-by: Don Kjer <don.kjer@gmail.com>
2015-08-08 00:23:03 +00: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
Alec Benson
21b0927720 Fix ICC on Firewalld enabled fedora systems, add in missing firewalld functionality to re-apply configuration when reloaded
Signed-off-by: Alec Benson <albenson@redhat.com>
2015-07-24 13:20:48 -04:00
Alexander Morozov
97adea5b77 Add dummy proxy on port map
It is needed in cases when mapped port is already bound, or another
application bind mapped port. All this will be undetected because we use
iptables and not net.Listen.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-05-22 12:38:28 -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
Jana Radhakrishnan
4a3c7e1bb5 Changed portallocator New() method to Get()
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-14 21:59:17 +00:00
Jana Radhakrishnan
9714bcac87 Brought in iptables package into libnetwork.
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-06 23:52:50 +00:00
bin liu
a004b52ab3 fix some typos
Signed-off-by: bin liu <liubin0329@gmail.com>
2015-04-20 04:12:54 +00:00
Alessandro Boch
3e6a889cd6 Port Allocator as a libnetwork package
DESCRIPTION:
  As part of bringing libnetwork bridge driver features
  in parity with docker/daemon/network/driver/bridge
  features (Issue #46), this commit addresses the
  bridge.RequestPort() API.

  Currenlty docker/api/server.go needs an hold of port
  allocator in order to reserve a transport port which
  will be used by the http server on the host machine,
  so that portallocator does not give out that port when
  queried by portmapper as part of network driver operations.

ISSUE:
  Current implementation in docker is server.go directly
  access portmapper and then portallocator from bridge pkg
  calling bridge.RequestPort(). This also forces that function
  to trigger portmapper initialization (in case bridge init()
  was not executed yet), while portmapper life cycle should
  only be controlled by bridge network driver.
  We cannot mantain this behavior with libnetwrok as this
  violates the modularization of networking code which
  libnetwork is bringing in.

FIX:
  Make portallocator a singleton, now both docker core and
  portmapper code can initialize it and get the only one instance
  (Change in docker core code will happen when docker code
  will migrate to use libnetwork), given it is being used for
  host specific needs.

NOTE:
  Long term fix is having multiple portallocator instances (so
  no more singleton) each capable to be in sync with OS regarding
  current port allocation.
  When this change comes, no change whould be required on portallocator'
  clients side, changes will be confined to portallocator package.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-04-16 17:29:13 -07:00
Alessandro Boch
1f3f37b2f8 Sync libnetwork code to latest docker/master
- Update: portmapper, portallocator, ipallocator
- Remove stale godep dependencies
- Update pkg/iptables and others godep to latest
- Update bridge code and test after above changes
- Merge with latest changes in libnetwork

The code is updated up to docker/master commit SHA 86d66d6273

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-04-10 13:50:58 -07:00
Alessandro Boch
5d7b430801 Issue #33: Move portmapper and portallocator into libnetwork
- As they provide network translation functionalities,
  they should be part of libnetwork
- In driver/bridge/setup_ip_tables.go remove depenency
  on docker/daemon/networkdriver

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-04-09 11:05:02 -07:00