Fix network inspect IPv6 gateway address format #49520
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- 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 ...
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
- A picture of a cute animal (not mandatory but encouraged)