From 6a2a33b00ace3bdfa95720d8a57d9b7b9fe253ca Mon Sep 17 00:00:00 2001 From: Siyuan Date: Tue, 14 Oct 2025 15:07:05 +0000 Subject: [PATCH] fix: ignore DHCP lease if not in DHCP mode --- pkg/nmlite/interface.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/nmlite/interface.go b/pkg/nmlite/interface.go index ba22b6ee..58bd7353 100644 --- a/pkg/nmlite/interface.go +++ b/pkg/nmlite/interface.go @@ -90,6 +90,11 @@ func NewInterfaceManager(ctx context.Context, ifaceName string, config *types.Ne // Set up DHCP client callbacks im.dhcpClient.SetOnLeaseChange(func(lease *types.DHCPLease) { + if im.config.IPv4Mode.String != "dhcp" { + im.logger.Warn().Str("mode", im.config.IPv4Mode.String).Msg("ignoring DHCP lease, current mode is not DHCP") + return + } + if err := im.applyDHCPLease(lease); err != nil { im.logger.Error().Err(err).Msg("failed to apply DHCP lease") }