From 992005a7a49c6d295bcff96064ac59af257111ea Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Wed, 8 Jan 2025 20:09:18 +0100 Subject: [PATCH] fix: request previous IP address in discovery 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 --- .../machined/pkg/controllers/network/operator/dhcp4.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/app/machined/pkg/controllers/network/operator/dhcp4.go b/internal/app/machined/pkg/controllers/network/operator/dhcp4.go index ba26fc536b..634db0e04d 100644 --- a/internal/app/machined/pkg/controllers/network/operator/dhcp4.go +++ b/internal/app/machined/pkg/controllers/network/operator/dhcp4.go @@ -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...)