summaryrefslogtreecommitdiffhomepage
path: root/pkg/test/dockerutil/container.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-07-28 18:01:54 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-28 18:01:54 -0700
commit1e829a7c860756a9f24aac09c6880733f864499b (patch)
treeb0e698d4157266a31a53ebe376c220540cd99cec /pkg/test/dockerutil/container.go
parentc1c643abe7be45991c8004d0de2b31716702d527 (diff)
parentd9c9420335a78b54bc04ec0639d89539b4c3972c (diff)
Merge pull request #3025 from kevinGC:ipv6-iptables-testing2
PiperOrigin-RevId: 323692144
Diffstat (limited to 'pkg/test/dockerutil/container.go')
-rw-r--r--pkg/test/dockerutil/container.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/test/dockerutil/container.go b/pkg/test/dockerutil/container.go
index b59503188..441173ec2 100644
--- a/pkg/test/dockerutil/container.go
+++ b/pkg/test/dockerutil/container.go
@@ -360,13 +360,18 @@ func (c *Container) SandboxPid(ctx context.Context) (int, error) {
}
// FindIP returns the IP address of the container.
-func (c *Container) FindIP(ctx context.Context) (net.IP, error) {
+func (c *Container) FindIP(ctx context.Context, ipv6 bool) (net.IP, error) {
resp, err := c.client.ContainerInspect(ctx, c.id)
if err != nil {
return nil, err
}
- ip := net.ParseIP(resp.NetworkSettings.DefaultNetworkSettings.IPAddress)
+ var ip net.IP
+ if ipv6 {
+ ip = net.ParseIP(resp.NetworkSettings.DefaultNetworkSettings.GlobalIPv6Address)
+ } else {
+ ip = net.ParseIP(resp.NetworkSettings.DefaultNetworkSettings.IPAddress)
+ }
if ip == nil {
return net.IP{}, fmt.Errorf("invalid IP: %q", ip)
}