From fffe9fc5667aa01e8b2fc482407f50f4c49fb751 Mon Sep 17 00:00:00 2001 From: Gavin Luo Date: Mon, 5 Jan 2026 16:47:26 +0800 Subject: [PATCH] Fix reset buffer in dhcp response loop Previously, the buffer was not reset within the response loop. If a packet handle failed or completed, the buffer retained its state. Specifically, if `ReadPacketFrom` returned `io.ErrShortBuffer`, the error was ignored via `continue`, but the buffer remained full. This caused the next read attempt to immediately fail with the same error, creating a tight busy-wait loop that consumed 100% CPU. Validates `buffer.Reset()` is called at the start of each iteration to ensure a clean state for 'ReadPacketFrom'. --- dns/transport/dhcp/dhcp.go | 1 + 1 file changed, 1 insertion(+) diff --git a/dns/transport/dhcp/dhcp.go b/dns/transport/dhcp/dhcp.go index f55d547e0..d25b081f9 100644 --- a/dns/transport/dhcp/dhcp.go +++ b/dns/transport/dhcp/dhcp.go @@ -243,6 +243,7 @@ func (t *Transport) fetchServersResponse(iface *control.Interface, packetConn ne defer buffer.Release() for { + buffer.Reset() _, _, err := buffer.ReadPacketFrom(packetConn) if err != nil { if errors.Is(err, io.ErrShortBuffer) {