Skip to content

libnet/pms/nat: don't bind IPv6 ports if not supported by port driver#51616

Merged
thaJeztah merged 2 commits intomoby:masterfrom
akerouanton:fix-51591
Nov 28, 2025
Merged

libnet/pms/nat: don't bind IPv6 ports if not supported by port driver#51616
thaJeztah merged 2 commits intomoby:masterfrom
akerouanton:fix-51591

Conversation

@akerouanton
Copy link
Member

@akerouanton akerouanton commented Nov 28, 2025

- What I did

In rootless mode, the Engine needs to call the rootless port driver to know which IP address it should bind to inside of its network namespace.

The slirp4netns port drivers doesn't support binding to IPv6 address, so we need to detect that before listening on the port.

Before commit 201968c, this wasn't a problem because the Engine was binding the port, then calling rootless port driver to learn whether the proto/IP family was supported, and listen on the port if so.

Starting with that commit, the Engine does bind + listen in one go, and then calls the port driver — this is too late. Fix the bug by checking if the port driver supports the PortBindingReq, and only allocate the port if so.

- How to verify it

Start a rootless daemon with DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns, then docker run -p 80:80 alpine.

- Human readable description for the release notes

Fix a bug preventing port mappings in rootless mode when slirp4netns is used

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

In rootless mode, the Engine needs to call the rootless port driver to
know which IP address it should bind to inside of its network namespace.

The slirp4netns port drivers doesn't support binding to IPv6 address, so
we need to detect that before listening on the port.

Before commit 201968c, this wasn't a problem because the Engine was
binding the port, then calling rootless port driver to learn whether the
proto/IP family was supported, and listen on the port if so.

Starting with that commit, the Engine does bind + listen in one go, and
then calls the port driver — this is too late. Fix the bug by checking
if the port driver supports the PortBindingReq, and only allocate the
port if so.

Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
@akerouanton akerouanton changed the title libnet/pm/nat: don't bind IPv6 ports if not supported by port driver libnet/pms/nat: don't bind IPv6 ports if not supported by port driver Nov 28, 2025
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 2faf258 into moby:master Nov 28, 2025
289 of 291 checks passed
@akerouanton akerouanton deleted the fix-51591 branch November 30, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After update (29.0.x) networking fails with rootless Docker (DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns)

4 participants