summaryrefslogtreecommitdiffhomepage
path: root/test/iptables/iptables_util.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-03-11 18:17:20 -0700
committergVisor bot <gvisor-bot@google.com>2020-03-11 18:17:20 -0700
commita9c6135ed73c99686a6de1d7160dc874dd0ab5ca (patch)
tree5f9a795855b666e4cbbdee00ba4f6ca2042599a9 /test/iptables/iptables_util.go
parent81675b850e27ea9d6c853a73bd667fc16901a5e8 (diff)
parent4054b021f05cb0902e9877ba82403978fd8d6405 (diff)
Merge pull request #2108 from kevinGC:prepare-ipt-tests
PiperOrigin-RevId: 300449422
Diffstat (limited to 'test/iptables/iptables_util.go')
-rw-r--r--test/iptables/iptables_util.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/test/iptables/iptables_util.go b/test/iptables/iptables_util.go
index 32cf5a417..1f8dac4f1 100644
--- a/test/iptables/iptables_util.go
+++ b/test/iptables/iptables_util.go
@@ -125,26 +125,23 @@ func listenTCP(port int, timeout time.Duration) error {
return nil
}
-// connectTCP connects the TCP server over specified local port, server IP and remote/server port.
-func connectTCP(ip net.IP, remotePort, localPort int, timeout time.Duration) error {
+// connectTCP connects to the given IP and port from an ephemeral local address.
+func connectTCP(ip net.IP, port int, timeout time.Duration) error {
contAddr := net.TCPAddr{
IP: ip,
- Port: remotePort,
+ Port: port,
}
// The container may not be listening when we first connect, so retry
// upon error.
callback := func() error {
- localAddr := net.TCPAddr{
- Port: localPort,
- }
- conn, err := net.DialTCP("tcp4", &localAddr, &contAddr)
+ conn, err := net.DialTCP("tcp4", nil, &contAddr)
if conn != nil {
conn.Close()
}
return err
}
if err := testutil.Poll(callback, timeout); err != nil {
- return fmt.Errorf("timed out waiting to send IP, most recent error: %v", err)
+ return fmt.Errorf("timed out waiting to connect IP, most recent error: %v", err)
}
return nil