mirror of
https://github.com/moby/moby.git
synced 2025-10-24 09:13:09 +03:00
Fix issue in --ip6 validation for docker create
This fix tries to address the issue raised in comment: https://github.com/docker/docker/pull/25943#discussion_r76843081 Previously, the validation for `ip6` is done by checking ParseIP().To16(). However, in case an IPv4 address or an IPv4-mapped Ipv6 address has been provided, the validation will pass (should fail). This fix first check if `--ip6` is passed with a valid IP address and returns error for invalid IP addresses. It then check if an IPv4 or IPv4-mapped Ipv6 address is passed, and return error accordingly. This fix adds two more cases in the tests. One for IPv4 address passed to `--ip6` and another for Ipv4-mapped IPv6 address passed to `--ip6`. In both cases, without this fix the validation will pass through. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -1749,4 +1749,10 @@ func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *check.C) {
|
||||
c.Assert(err.Error(), checker.Contains, "invalid IPv4 address")
|
||||
_, _, err = dockerCmdWithError("run", "--net=mynet", "--ip", "172.28.99.99", "--ip6", "mynet_ip6", "busybox", "top")
|
||||
c.Assert(err.Error(), checker.Contains, "invalid IPv6 address")
|
||||
// This is a case of IPv4 address to `--ip6`
|
||||
_, _, err = dockerCmdWithError("run", "--net=mynet", "--ip6", "172.28.99.99", "busybox", "top")
|
||||
c.Assert(err.Error(), checker.Contains, "invalid IPv6 address")
|
||||
// This is a special case of an IPv4-mapped IPv6 address
|
||||
_, _, err = dockerCmdWithError("run", "--net=mynet", "--ip6", "::ffff:172.28.99.99", "busybox", "top")
|
||||
c.Assert(err.Error(), checker.Contains, "invalid IPv6 address")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user