Skip to content

Commit

Permalink
fix: request previous IP address in discovery
Browse files Browse the repository at this point in the history
This ensures that even in the event of a DHCP downtime that exceeds the
lease time, the current IP can be maintained.

Signed-off-by: TomyLobo <[email protected]>
  • Loading branch information
TomyLobo authored Jan 8, 2025
1 parent 32c67c2 commit 5832497
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,14 @@ func (d *DHCP4) requestRenew(ctx context.Context, hostname network.HostnameStatu
case d.lease != nil && d.lease.Offer != nil:
d.logger.Debug("DHCP REQUEST FROM OFFER", zap.String("link", d.linkName))
d.lease, err = client.RequestFromOffer(ctx, d.lease.Offer, mods...)
case len(d.AddressSpecs()) >= 1:
d.logger.Debug("DHCP REQUEST WITH PREVIOUS IP", zap.String("link", d.linkName))

var firstIPAddress net.IP = d.AddressSpecs()[0].Address.Addr().AsSlice()

d.lease, err = client.Request(ctx, dhcpv4.PrependModifiers(mods,
dhcpv4.WithOption(dhcpv4.OptRequestedIPAddress(firstIPAddress)),
)...)
default:
d.logger.Debug("DHCP REQUEST", zap.String("link", d.linkName))
d.lease, err = client.Request(ctx, mods...)
Expand Down

0 comments on commit 5832497

Please sign in to comment.