Skip to content

Conversation

@robmry
Copy link
Contributor

@robmry robmry commented Feb 22, 2025

- What I did

Spotted in-passing ...

When an IPv6 network is first created with no specific IPAM config, network inspect adds a CIDR range to the gateway address. For example ...

# docker network create --ipv6 b46
# docker network inspect b46
       ...
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                },
                {
                    "Subnet": "fdcf:eadc:be2c::/64",
                    "Gateway": "fdcf:eadc:be2c::1/64"
                }
            ]
        },
        ...

After the daemon has been restarted, it's just a plain address - "Gateway": "fdcf:eadc:be2c::1".

Before 27.0 (#47853), it wasn't possible to create an IPv6 network without supplying at-least a subnet (or including IPv6 ranges in default-address-pools). So, there was always IPAM config and, until a daemon restart, no gateway address was reported in inspect output.

Since that change, the IPv6 gateway address has been reported incorrectly (with a CIDR suffix) until a daemon restart.

When the daemon's restated, the IPAM "info" (running state) becomes "config" (it shouldn't!), and the "config" address is reported correctly.

- How I did it

Make the IPv6 code to report the gateway from IPAM "info" use net.IPNet.IP instead of the whole net.IPNet - like the IPv4 code.

- How to verify it

New test.

- Human readable description for the release notes

- Fix `docker network inspect` reporting an IPv6 gateway with CIDR suffix for a newly created network with no specific IPAM config, until a daemon restart.

- A picture of a cute animal (not mandatory but encouraged)

When an IPv6 network is first created with no specific IPAM config,
network inspect adds a CIDR range to the gateway address. After the
daemon has been restarted, it's just a plain address.

Once the daaemon's been restated, "info" becomes "config", and the
address is reported correctly from "config".

Make the IPv6 code to report the gateway from "info" use net.IPNet.IP
instead of the whole net.IPNet - like the IPv4 code.

Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry force-pushed the inspect_gw6_not_cidr branch from a2f16f3 to 3cf4ff9 Compare February 22, 2025 12:25
@vvoland
Copy link
Contributor

vvoland commented Feb 24, 2025

For changelog:

Fix `docker network inspect` reporting an IPv6 gateway with CIDR suffix for a newly created network with no specific IPAM config, before the daemon restart.

WDYT?

@robmry
Copy link
Contributor Author

robmry commented Feb 24, 2025

For changelog:

Fix `docker network inspect` reporting an IPv6 gateway with CIDR suffix for a newly created network with no specific IPAM config, before the daemon restart.

WDYT?

Looks good, thank you - I've updated it (except with "until a daemon restart" instead of "before the daemon restart").

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

double-checked the swagger.yml, and AFAICS looks like examples there are in the correct format there

@thaJeztah thaJeztah merged commit 0de01f7 into moby:master Feb 24, 2025
153 checks passed
@robmry robmry deleted the inspect_gw6_not_cidr branch February 26, 2025 14:48
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.

3 participants