mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/network: use netip types as appropriate
And generate the ServiceInfo struct from the Swagger spec. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
ef31514a9f
commit
a90adb6dc1
@@ -71,8 +71,7 @@ func TestCreateWithIPv6DefaultsToULAPrefix(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
|
||||
for _, ipam := range nw.IPAM.Config {
|
||||
ipr := netip.MustParsePrefix(ipam.Subnet)
|
||||
if netip.MustParsePrefix("fd00::/8").Overlaps(ipr) {
|
||||
if netip.MustParsePrefix("fd00::/8").Overlaps(ipam.Subnet) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -98,8 +97,7 @@ func TestCreateWithIPv6WithoutEnableIPv6Flag(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
|
||||
for _, ipam := range nw.IPAM.Config {
|
||||
ipr := netip.MustParsePrefix(ipam.Subnet)
|
||||
if netip.MustParsePrefix("fd00::/8").Overlaps(ipr) {
|
||||
if netip.MustParsePrefix("fd00::/8").Overlaps(ipam.Subnet) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -680,13 +678,13 @@ func TestLegacyLink(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "no link",
|
||||
host: svrAddr,
|
||||
host: svrAddr.String(),
|
||||
expect: "download timed out",
|
||||
},
|
||||
{
|
||||
name: "access by address",
|
||||
links: []string{svrName},
|
||||
host: svrAddr,
|
||||
host: svrAddr.String(),
|
||||
expect: "404 Not Found", // Got a response, but the server has nothing to serve.
|
||||
},
|
||||
{
|
||||
@@ -773,7 +771,7 @@ func TestRemoveLegacyLink(t *testing.T) {
|
||||
|
||||
// Check the icc=false rules now block access by address.
|
||||
svrAddr := inspSvr.NetworkSettings.Networks["bridge"].IPAddress
|
||||
res = ctr.ExecT(ctx, t, c, clientId, []string{"wget", "-T3", "http://" + svrAddr})
|
||||
res = ctr.ExecT(ctx, t, c, clientId, []string{"wget", "-T3", "http://" + svrAddr.String()})
|
||||
assert.Check(t, is.Contains(res.Stderr(), "download timed out"))
|
||||
}
|
||||
|
||||
@@ -1109,22 +1107,22 @@ func TestBridgeIPAMStatus(t *testing.T) {
|
||||
network.CreateNoError(ctx, t, c, netName,
|
||||
network.WithIPv4(true),
|
||||
network.WithIPAMConfig(networktypes.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: ipv4Range,
|
||||
Gateway: ipv4gw,
|
||||
AuxAddress: map[string]string{
|
||||
"reserved": auxIPv4FromRange,
|
||||
"reserved_1": auxIPv4OutOfRange,
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix(ipv4Range),
|
||||
Gateway: netip.MustParseAddr(ipv4gw),
|
||||
AuxAddress: map[string]netip.Addr{
|
||||
"reserved": netip.MustParseAddr(auxIPv4FromRange),
|
||||
"reserved_1": netip.MustParseAddr(auxIPv4OutOfRange),
|
||||
},
|
||||
}),
|
||||
network.WithIPv6(),
|
||||
network.WithIPAMConfig(networktypes.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: ipv6Range,
|
||||
Gateway: ipv6gw,
|
||||
AuxAddress: map[string]string{
|
||||
"reserved1": auxIPv6FromRange,
|
||||
"reserved2": auxIPv6OutOfRange,
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix(ipv6Range),
|
||||
Gateway: netip.MustParseAddr(ipv6gw),
|
||||
AuxAddress: map[string]netip.Addr{
|
||||
"reserved1": netip.MustParseAddr(auxIPv6FromRange),
|
||||
"reserved2": netip.MustParseAddr(auxIPv6OutOfRange),
|
||||
},
|
||||
}),
|
||||
)
|
||||
@@ -1205,7 +1203,7 @@ func TestBridgeIPAMStatus(t *testing.T) {
|
||||
network.WithIPv4(false),
|
||||
network.WithIPv6(),
|
||||
network.WithIPAMConfig(networktypes.IPAMConfig{
|
||||
Subnet: cidr.String(),
|
||||
Subnet: cidr,
|
||||
}),
|
||||
)
|
||||
defer c.NetworkRemove(ctx, netName)
|
||||
|
||||
@@ -49,12 +49,12 @@ func TestInspectNetwork(t *testing.T) {
|
||||
|
||||
networkName := "Overlay" + t.Name()
|
||||
cidrv4 := netip.MustParsePrefix("192.168.0.0/24")
|
||||
const ipv4Range = "192.168.0.0/25"
|
||||
ipv4Range := netip.MustParsePrefix("192.168.0.0/25")
|
||||
|
||||
overlayID := network.CreateNoError(ctx, t, c1, networkName,
|
||||
network.WithDriver("overlay"),
|
||||
network.WithIPAMConfig(networktypes.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
Subnet: cidrv4,
|
||||
IPRange: ipv4Range,
|
||||
}),
|
||||
)
|
||||
@@ -133,8 +133,8 @@ func TestInspectNetwork(t *testing.T) {
|
||||
|
||||
assert.Check(t, nw.IPAM.Config != nil)
|
||||
for _, cfg := range nw.IPAM.Config {
|
||||
assert.Assert(t, cfg.Gateway != "")
|
||||
assert.Assert(t, cfg.Subnet != "")
|
||||
assert.Assert(t, cfg.Gateway.IsValid())
|
||||
assert.Assert(t, cfg.Subnet.IsValid())
|
||||
}
|
||||
|
||||
if d.CachedInfo.Swarm.ControlAvailable {
|
||||
|
||||
@@ -271,15 +271,15 @@ func testIpvlanL2MultiSubnet(t *testing.T, ctx context.Context, client dclient.A
|
||||
c1, err := client.ContainerInspect(ctx, id1)
|
||||
assert.NilError(t, err)
|
||||
// Inspect the v4 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c1.NetworkSettings.Networks[netName].Gateway, ""))
|
||||
assert.Check(t, !c1.NetworkSettings.Networks[netName].Gateway.IsValid())
|
||||
// Inspect the v6 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c1.NetworkSettings.Networks[netName].IPv6Gateway, ""))
|
||||
assert.Check(t, !c1.NetworkSettings.Networks[netName].IPv6Gateway.IsValid())
|
||||
|
||||
// verify ipv4 connectivity to the explicit --ip address second to first
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks[netName].IPAddress})
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks[netName].IPAddress.String()})
|
||||
assert.NilError(t, err)
|
||||
// verify ipv6 connectivity to the explicit --ip6 address second to first
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks[netName].GlobalIPv6Address})
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks[netName].GlobalIPv6Address.String()})
|
||||
assert.NilError(t, err)
|
||||
|
||||
// start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.102.0/24 and 2001:db8:abc4::/64
|
||||
@@ -297,21 +297,21 @@ func testIpvlanL2MultiSubnet(t *testing.T, ctx context.Context, client dclient.A
|
||||
assert.NilError(t, err)
|
||||
if parent == "" {
|
||||
// Inspect the v4 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks[netName].Gateway, ""))
|
||||
assert.Check(t, !c3.NetworkSettings.Networks[netName].Gateway.IsValid())
|
||||
// Inspect the v6 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks[netName].IPv6Gateway, ""))
|
||||
assert.Check(t, !c3.NetworkSettings.Networks[netName].IPv6Gateway.IsValid())
|
||||
} else {
|
||||
// Inspect the v4 gateway to ensure the proper explicitly assigned default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks[netName].Gateway, "172.28.202.254"))
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks[netName].Gateway, netip.MustParseAddr("172.28.202.254")))
|
||||
// Inspect the v6 gateway to ensure the proper explicitly assigned default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks[netName].IPv6Gateway, "2001:db8:abc6::254"))
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks[netName].IPv6Gateway, netip.MustParseAddr("2001:db8:abc6::254")))
|
||||
}
|
||||
|
||||
// verify ipv4 connectivity to the explicit --ip address from third to fourth
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks[netName].IPAddress})
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks[netName].IPAddress.String()})
|
||||
assert.NilError(t, err)
|
||||
// verify ipv6 connectivity to the explicit --ip6 address from third to fourth
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks[netName].GlobalIPv6Address})
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks[netName].GlobalIPv6Address.String()})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
@@ -342,10 +342,10 @@ func testIpvlanL3MultiSubnet(t *testing.T, ctx context.Context, client dclient.A
|
||||
assert.NilError(t, err)
|
||||
|
||||
// verify ipv4 connectivity to the explicit --ipv address second to first
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks[netName].IPAddress})
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks[netName].IPAddress.String()})
|
||||
assert.NilError(t, err)
|
||||
// verify ipv6 connectivity to the explicit --ipv6 address second to first
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks[netName].GlobalIPv6Address})
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks[netName].GlobalIPv6Address.String()})
|
||||
assert.NilError(t, err)
|
||||
|
||||
// start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.102.0/24 and 2001:db8:abc4::/64
|
||||
@@ -363,20 +363,20 @@ func testIpvlanL3MultiSubnet(t *testing.T, ctx context.Context, client dclient.A
|
||||
assert.NilError(t, err)
|
||||
|
||||
// verify ipv4 connectivity to the explicit --ipv address from third to fourth
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks[netName].IPAddress})
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks[netName].IPAddress.String()})
|
||||
assert.NilError(t, err)
|
||||
// verify ipv6 connectivity to the explicit --ipv6 address from third to fourth
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks[netName].GlobalIPv6Address})
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks[netName].GlobalIPv6Address.String()})
|
||||
assert.NilError(t, err)
|
||||
|
||||
// Inspect the v4 gateway to ensure no next hop is assigned in L3 mode
|
||||
assert.Equal(t, c1.NetworkSettings.Networks[netName].Gateway, "")
|
||||
assert.Check(t, !c1.NetworkSettings.Networks[netName].Gateway.IsValid())
|
||||
// Inspect the v6 gateway to ensure the explicitly specified default GW is ignored per L3 mode enabled
|
||||
assert.Equal(t, c1.NetworkSettings.Networks[netName].IPv6Gateway, "")
|
||||
assert.Check(t, !c1.NetworkSettings.Networks[netName].IPv6Gateway.IsValid())
|
||||
// Inspect the v4 gateway to ensure no next hop is assigned in L3 mode
|
||||
assert.Equal(t, c3.NetworkSettings.Networks[netName].Gateway, "")
|
||||
assert.Check(t, !c3.NetworkSettings.Networks[netName].Gateway.IsValid())
|
||||
// Inspect the v6 gateway to ensure the explicitly specified default GW is ignored per L3 mode enabled
|
||||
assert.Equal(t, c3.NetworkSettings.Networks[netName].IPv6Gateway, "")
|
||||
assert.Check(t, !c3.NetworkSettings.Networks[netName].IPv6Gateway.IsValid())
|
||||
}
|
||||
|
||||
// Verify ipvlan l2 mode sets the proper default gateway routes via netlink
|
||||
@@ -495,11 +495,11 @@ func TestIpvlanIPAM(t *testing.T) {
|
||||
net.WithIPv4(tc.enableIPv4),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: subnetv4.String(),
|
||||
Subnet: subnetv4,
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: subnetv6.String(),
|
||||
IPRange: "2001:db8:abcd::100/120",
|
||||
Subnet: subnetv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::100/120"),
|
||||
},
|
||||
),
|
||||
}
|
||||
@@ -608,16 +608,16 @@ func TestIpvlanIPAMOverlap(t *testing.T) {
|
||||
net.WithIPv6(),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: "192.168.0.0/25",
|
||||
Gateway: "192.168.0.1",
|
||||
AuxAddress: map[string]string{
|
||||
"reserved": "192.168.0.100",
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix("192.168.0.0/25"),
|
||||
Gateway: netip.MustParseAddr("192.168.0.1"),
|
||||
AuxAddress: map[string]netip.Addr{
|
||||
"reserved": netip.MustParseAddr("192.168.0.100"),
|
||||
},
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: "2001:db8:abcd::/124",
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::/124"),
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -640,12 +640,12 @@ func TestIpvlanIPAMOverlap(t *testing.T) {
|
||||
net.WithIPv6(),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: "192.168.0.0/24",
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix("192.168.0.0/24"),
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: "2001:db8:abcd::/120",
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::/120"),
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -669,12 +669,12 @@ func TestIpvlanIPAMOverlap(t *testing.T) {
|
||||
net.WithIPv6(),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: "192.168.0.128/25",
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix("192.168.0.128/25"),
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: "2001:db8:abcd::80/124",
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::80/124"),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@@ -359,15 +359,15 @@ func testMacvlanMultiSubnet(t *testing.T, ctx context.Context, client client.API
|
||||
c1, err := client.ContainerInspect(ctx, id1)
|
||||
assert.NilError(t, err)
|
||||
// Inspect the v4 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c1.NetworkSettings.Networks["dualstackbridge"].Gateway, ""))
|
||||
assert.Check(t, !c1.NetworkSettings.Networks["dualstackbridge"].Gateway.IsValid())
|
||||
// Inspect the v6 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c1.NetworkSettings.Networks["dualstackbridge"].IPv6Gateway, ""))
|
||||
assert.Check(t, !c1.NetworkSettings.Networks["dualstackbridge"].IPv6Gateway.IsValid())
|
||||
|
||||
// verify ipv4 connectivity to the explicit --ip address second to first
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks["dualstackbridge"].IPAddress})
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks["dualstackbridge"].IPAddress.String()})
|
||||
assert.NilError(t, err)
|
||||
// verify ipv6 connectivity to the explicit --ip6 address second to first
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks["dualstackbridge"].GlobalIPv6Address})
|
||||
_, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks["dualstackbridge"].GlobalIPv6Address.String()})
|
||||
assert.NilError(t, err)
|
||||
|
||||
// start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.102.0/24 and 2001:db8:abc4::/64
|
||||
@@ -385,21 +385,21 @@ func testMacvlanMultiSubnet(t *testing.T, ctx context.Context, client client.API
|
||||
assert.NilError(t, err)
|
||||
if parent == "" {
|
||||
// Inspect the v4 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks["dualstackbridge"].Gateway, ""))
|
||||
assert.Check(t, !c3.NetworkSettings.Networks["dualstackbridge"].Gateway.IsValid())
|
||||
// Inspect the v6 gateway to ensure no default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks["dualstackbridge"].IPv6Gateway, ""))
|
||||
assert.Check(t, !c3.NetworkSettings.Networks["dualstackbridge"].IPv6Gateway.IsValid())
|
||||
} else {
|
||||
// Inspect the v4 gateway to ensure the proper explicitly assigned default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks["dualstackbridge"].Gateway, "172.28.102.254"))
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks["dualstackbridge"].Gateway, netip.MustParseAddr("172.28.102.254")))
|
||||
// Inspect the v6 gateway to ensure the proper explicitly assigned default GW was assigned
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks["dualstackbridge"].IPv6Gateway, "2001:db8:abc4::254"))
|
||||
assert.Check(t, is.Equal(c3.NetworkSettings.Networks["dualstackbridge"].IPv6Gateway, netip.MustParseAddr("2001:db8:abc4::254")))
|
||||
}
|
||||
|
||||
// verify ipv4 connectivity to the explicit --ip address from third to fourth
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks["dualstackbridge"].IPAddress})
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks["dualstackbridge"].IPAddress.String()})
|
||||
assert.NilError(t, err)
|
||||
// verify ipv6 connectivity to the explicit --ip6 address from third to fourth
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks["dualstackbridge"].GlobalIPv6Address})
|
||||
_, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks["dualstackbridge"].GlobalIPv6Address.String()})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
@@ -492,17 +492,17 @@ func TestMacvlanIPAM(t *testing.T) {
|
||||
net.WithIPv4(tc.enableIPv4),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: subnetv4.String(),
|
||||
IPRange: "10.66.77.64/30",
|
||||
Gateway: "10.66.77.1",
|
||||
AuxAddress: map[string]string{
|
||||
"inrange": "10.66.77.65",
|
||||
"outofrange": "10.66.77.128",
|
||||
Subnet: subnetv4,
|
||||
IPRange: netip.MustParsePrefix("10.66.77.64/30"),
|
||||
Gateway: netip.MustParseAddr("10.66.77.1"),
|
||||
AuxAddress: map[string]netip.Addr{
|
||||
"inrange": netip.MustParseAddr("10.66.77.65"),
|
||||
"outofrange": netip.MustParseAddr("10.66.77.128"),
|
||||
},
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: subnetv6.String(),
|
||||
IPRange: "2001:db8:abcd::/120",
|
||||
Subnet: subnetv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::/120"),
|
||||
},
|
||||
),
|
||||
}
|
||||
@@ -611,16 +611,16 @@ func TestMacvlanIPAMOverlap(t *testing.T) {
|
||||
net.WithIPv6(),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: "192.168.0.0/25",
|
||||
Gateway: "192.168.0.1",
|
||||
AuxAddress: map[string]string{
|
||||
"reserved": "192.168.0.100",
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix("192.168.0.0/25"),
|
||||
Gateway: netip.MustParseAddr("192.168.0.1"),
|
||||
AuxAddress: map[string]netip.Addr{
|
||||
"reserved": netip.MustParseAddr("192.168.0.100"),
|
||||
},
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: "2001:db8:abcd::/124",
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::/124"),
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -643,12 +643,12 @@ func TestMacvlanIPAMOverlap(t *testing.T) {
|
||||
net.WithIPv6(),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: "192.168.0.0/24",
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix("192.168.0.0/24"),
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: "2001:db8:abcd::/120",
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::/120"),
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -672,12 +672,12 @@ func TestMacvlanIPAMOverlap(t *testing.T) {
|
||||
net.WithIPv6(),
|
||||
net.WithIPAMConfig(
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv4.String(),
|
||||
IPRange: "192.168.0.128/25",
|
||||
Subnet: cidrv4,
|
||||
IPRange: netip.MustParsePrefix("192.168.0.128/25"),
|
||||
},
|
||||
network.IPAMConfig{
|
||||
Subnet: cidrv6.String(),
|
||||
IPRange: "2001:db8:abcd::80/124",
|
||||
Subnet: cidrv6,
|
||||
IPRange: netip.MustParsePrefix("2001:db8:abcd::80/124"),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestHostIPv4BridgeLabel(t *testing.T) {
|
||||
out.IPAM.Config[0].Subnet, ipv4SNATAddr)
|
||||
assert.Check(t, is.Contains(chain, exp))
|
||||
} else {
|
||||
testutil.RunCommand(ctx, "iptables", "-t", "nat", "-C", "POSTROUTING", "-s", out.IPAM.Config[0].Subnet, "!", "-o", bridgeName, "-j", "SNAT", "--to-source", ipv4SNATAddr).Assert(t, icmd.Success)
|
||||
testutil.RunCommand(ctx, "iptables", "-t", "nat", "-C", "POSTROUTING", "-s", out.IPAM.Config[0].Subnet.String(), "!", "-o", bridgeName, "-j", "SNAT", "--to-source", ipv4SNATAddr).Assert(t, icmd.Success)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
// Verify bridge network's subnet
|
||||
out, err := c.NetworkInspect(ctx, "bridge", client.NetworkInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.30.0.0/16")
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, netip.MustParsePrefix("175.30.0.0/16"))
|
||||
|
||||
// Create a bridge network and verify its subnet is the second default pool
|
||||
name := "elango" + t.Name()
|
||||
@@ -94,7 +94,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
out, err = c.NetworkInspect(ctx, name, client.NetworkInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, "175.33.0.0/24"))
|
||||
assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, netip.MustParsePrefix("175.33.0.0/24")))
|
||||
|
||||
// Create a bridge network and verify its subnet is the third default pool
|
||||
name = "saanvi" + t.Name()
|
||||
@@ -104,7 +104,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
||||
defer network.RemoveNoError(ctx, t, c, name)
|
||||
out, err = c.NetworkInspect(ctx, name, client.NetworkInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, "175.33.1.0/24"))
|
||||
assert.Check(t, is.Equal(out.IPAM.Config[0].Subnet, netip.MustParsePrefix("175.33.1.0/24")))
|
||||
}
|
||||
|
||||
func TestDaemonRestartWithExistingNetwork(t *testing.T) {
|
||||
@@ -220,7 +220,7 @@ func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) {
|
||||
out, err := c.NetworkInspect(ctx, "bridge", client.NetworkInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
// Make sure BIP IP doesn't get override with new default address pool .
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "172.60.0.0/16")
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, netip.MustParsePrefix("172.60.0.0/16"))
|
||||
}
|
||||
|
||||
func TestServiceWithPredefinedNetwork(t *testing.T) {
|
||||
@@ -451,13 +451,13 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
|
||||
// pool (whereas before, the subnet for the ingress network was hard-coded.
|
||||
// This means that the ingress network gets the subnet 20.20.0.0/24, and
|
||||
// the network we just created gets subnet 20.20.1.0/24.
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.1.0/24")
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, netip.MustParsePrefix("20.20.1.0/24"))
|
||||
|
||||
// Also inspect ingress network and make sure its in the same subnet
|
||||
out, err = cli.NetworkInspect(ctx, "ingress", client.NetworkInspectOptions{Verbose: true})
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, len(out.IPAM.Config) > 0)
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.0.0/24")
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, netip.MustParsePrefix("20.20.0.0/24"))
|
||||
|
||||
err = cli.ServiceRemove(ctx, serviceID)
|
||||
poll.WaitOn(t, noServices(ctx, cli), swarm.ServicePoll)
|
||||
|
||||
Reference in New Issue
Block a user