summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv6')
-rw-r--r--dhcpv6/client.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/dhcpv6/client.go b/dhcpv6/client.go
index 24b6e0d..79653c8 100644
--- a/dhcpv6/client.go
+++ b/dhcpv6/client.go
@@ -1,6 +1,7 @@
package dhcpv6
import (
+ "errors"
"fmt"
"net"
"time"
@@ -127,8 +128,12 @@ func (c *Client) sendReceive(ifname string, packet DHCPv6, expectedType MessageT
return nil, err
}
defer conn.Close()
- // wait for the listener to be ready
+ // wait for the listener to be ready, fail if it takes too much time
+ deadline := time.Now().Add(time.Second)
for {
+ if now := time.Now(); now.After(deadline) {
+ return nil, errors.New("Timed out waiting for listener to be ready")
+ }
if conn.LocalAddr() != nil {
break
}