From 1e13f234cc2b569e249f66455f9686479b5c2600 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Wed, 17 Jul 2024 10:34:40 -0600 Subject: [PATCH] Fix nil pointer error: When in proxyDHCP mode if AllowNetboot is false Smee would panic because of this log line. This resolves this issue. Signed-off-by: Jacob Weinstock --- internal/dhcp/handler/proxy/proxy.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/dhcp/handler/proxy/proxy.go b/internal/dhcp/handler/proxy/proxy.go index 0de6f559..14d95eaf 100644 --- a/internal/dhcp/handler/proxy/proxy.go +++ b/internal/dhcp/handler/proxy/proxy.go @@ -187,7 +187,14 @@ func (h *Handler) Handle(ctx context.Context, conn *ipv4.PacketConn, dp data.Pac // check the backend, if PXE is NOT allowed, set the boot file name to "//not-allowed" _, n, err := h.Backend.GetByMac(ctx, dp.Pkt.ClientHWAddr) if err != nil || (n != nil && !n.AllowNetboot) { - log.V(1).Info("Ignoring packet", "error", err.Error(), "netbootAllowed", n.AllowNetboot) + l := log.V(1) + if err != nil { + l.WithValues("error", err.Error()) + } + if n != nil { + l.WithValues("netbootAllowed", n.AllowNetboot) + } + l.Info("Ignoring packet") span.SetStatus(codes.Ok, "netboot not allowed") return }