diff --git a/pkg/nmlite/jetdhcpc/client.go b/pkg/nmlite/jetdhcpc/client.go index 155ea249..102d3bee 100644 --- a/pkg/nmlite/jetdhcpc/client.go +++ b/pkg/nmlite/jetdhcpc/client.go @@ -111,6 +111,7 @@ type Client struct { var ( defaultTimerDuration = 1 * time.Second defaultLinkUpTimeout = 30 * time.Second + defaultDHCPTimeout = 5 * time.Second // DHCP request timeout (not link up timeout) maxRenewalAttemptDuration = 2 * time.Hour ) @@ -125,11 +126,11 @@ func NewClient(ctx context.Context, ifaces []string, c *Config, l *zerolog.Logge } if cfg.Timeout == 0 { - cfg.Timeout = defaultLinkUpTimeout + cfg.Timeout = defaultDHCPTimeout } if cfg.Retries == 0 { - cfg.Retries = 3 + cfg.Retries = 4 } return &Client{ @@ -153,9 +154,15 @@ func NewClient(ctx context.Context, ifaces []string, c *Config, l *zerolog.Logge }, nil } -func resetTimer(t *time.Timer, l *zerolog.Logger) { - l.Debug().Dur("delay", defaultTimerDuration).Msg("will retry later") - t.Reset(defaultTimerDuration) +func resetTimer(t *time.Timer, attempt int, l *zerolog.Logger) { + // Exponential backoff: 1s, 2s, 4s, 8s, max 8s + backoffAttempt := attempt + if backoffAttempt > 3 { + backoffAttempt = 3 + } + delay := time.Duration(1<