Skip to content

Commit b60e3ea

Browse files
feat: enhance DHCP server logging for UDP communications
Adds detailed logging for incoming and outgoing DHCP packets (Discover, Offer, Request, Ack) to help diagnose IP assignment issues. - Logs the full packet content at INFO level. - Includes IPPool reference in log messages for better context.
1 parent 81d10a4 commit b60e3ea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/dhcp/dhcp.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ func (a *DHCPAllocator) dhcpHandlerPerPool(conn net.PacketConn, peer net.Addr, m
236236
return
237237
}
238238

239-
logrus.Tracef("(dhcp.dhcpHandlerPerPool) INCOMING PACKET=%s on IPPool: %s", m.Summary(), ipPoolRef)
239+
// Enhanced logging for incoming packet
240+
logrus.Infof("(dhcp.dhcpHandlerPerPool) INCOMING DHCP PACKET on IPPool %s: %s", ipPoolRef, m.String())
240241

241242
if m.OpCode != dhcpv4.OpcodeBootRequest {
242243
logrus.Errorf("(dhcp.dhcpHandlerPerPool) not a BootRequest! IPPool: %s", ipPoolRef)
@@ -314,6 +315,9 @@ func (a *DHCPAllocator) dhcpHandlerPerPool(conn net.PacketConn, peer net.Addr, m
314315
return
315316
}
316317

318+
// Enhanced logging for outgoing packet
319+
logrus.Infof("(dhcp.dhcpHandlerPerPool) OUTGOING DHCP REPLY on IPPool %s: %s", ipPoolRef, reply.String())
320+
317321
if _, err := conn.WriteTo(reply.ToBytes(), peer); err != nil {
318322
logrus.Errorf("(dhcp.dhcpHandlerPerPool) Cannot reply to client for IPPool %s: %v", ipPoolRef, err)
319323
}

0 commit comments

Comments
 (0)