mirror of
https://github.com/moby/moby.git
synced 2026-08-07 08:31:39 +00:00
Merge pull request #49520 from robmry/inspect_gw6_not_cidr
Fix network inspect IPv6 gateway address format
This commit is contained in:
@@ -751,9 +751,13 @@ func buildIPAMResources(nw *libnetwork.Network) networktypes.IPAM {
|
||||
if info.IPAMData.Pool == nil {
|
||||
continue
|
||||
}
|
||||
var gw string
|
||||
if info.IPAMData.Gateway != nil {
|
||||
gw = info.IPAMData.Gateway.IP.String()
|
||||
}
|
||||
ipamConfig = append(ipamConfig, networktypes.IPAMConfig{
|
||||
Subnet: info.IPAMData.Pool.String(),
|
||||
Gateway: info.IPAMData.Gateway.String(),
|
||||
Gateway: gw,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func TestDaemonDefaultBridgeIPAM_Docker0(t *testing.T) {
|
||||
},
|
||||
expIPAMConfig: []network.IPAMConfig{
|
||||
{Subnet: "192.168.176.0/24", Gateway: "192.168.176.1"},
|
||||
{Subnet: "fdd1:8161:2d2c::/64", Gateway: "fdd1:8161:2d2c::1/64"},
|
||||
{Subnet: "fdd1:8161:2d2c::/64", Gateway: "fdd1:8161:2d2c::1"},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1542,3 +1542,21 @@ func TestAdvertiseAddresses(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestNetworkInspectGateway checks that gateways reported in inspect output are parseable as addresses.
|
||||
func TestNetworkInspectGateway(t *testing.T) {
|
||||
ctx := setupTest(t)
|
||||
c := testEnv.APIClient()
|
||||
|
||||
const netName = "test-inspgw"
|
||||
nid, err := network.Create(ctx, c, netName, network.WithIPv6())
|
||||
assert.NilError(t, err)
|
||||
defer network.RemoveNoError(ctx, t, c, netName)
|
||||
|
||||
insp, err := c.NetworkInspect(ctx, nid, networktypes.InspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
for _, ipamCfg := range insp.IPAM.Config {
|
||||
_, err := netip.ParseAddr(ipamCfg.Gateway)
|
||||
assert.Check(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user