dhcp: decrease read timeout and clamp backoff
This commit is contained in:
parent
d4d3f914e7
commit
295e02e4e9
@ -34,6 +34,7 @@ import (
|
|||||||
// RFC 2131 suggests using exponential backoff, starting with 4sec
|
// RFC 2131 suggests using exponential backoff, starting with 4sec
|
||||||
// and randomized to +/- 1sec
|
// and randomized to +/- 1sec
|
||||||
const resendDelay0 = 4 * time.Second
|
const resendDelay0 = 4 * time.Second
|
||||||
|
const resendDelayMax = 32 * time.Second
|
||||||
|
|
||||||
const (
|
const (
|
||||||
leaseStateBound = iota
|
leaseStateBound = iota
|
||||||
@ -308,8 +309,10 @@ func backoffRetry(f func() (*dhcp4.Packet, error)) (*dhcp4.Packet, error) {
|
|||||||
|
|
||||||
time.Sleep(baseDelay + jitter(time.Second))
|
time.Sleep(baseDelay + jitter(time.Second))
|
||||||
|
|
||||||
|
if baseDelay < resendDelayMax {
|
||||||
baseDelay *= 2
|
baseDelay *= 2
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil, errNoMoreTries
|
return nil, errNoMoreTries
|
||||||
}
|
}
|
||||||
@ -322,7 +325,7 @@ func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) {
|
|||||||
|
|
||||||
return dhcp4client.New(
|
return dhcp4client.New(
|
||||||
dhcp4client.HardwareAddr(link.Attrs().HardwareAddr),
|
dhcp4client.HardwareAddr(link.Attrs().HardwareAddr),
|
||||||
dhcp4client.Timeout(10*time.Second),
|
dhcp4client.Timeout(5*time.Second),
|
||||||
dhcp4client.Broadcast(false),
|
dhcp4client.Broadcast(false),
|
||||||
dhcp4client.Connection(pktsock),
|
dhcp4client.Connection(pktsock),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user