From 72eb3a8853540b06ee1096decf50e836b539fe45 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Thu, 30 Sep 2021 18:03:19 +0300 Subject: [PATCH] dhcpd: imp code readability --- internal/dhcpd/conn_unix.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/dhcpd/conn_unix.go b/internal/dhcpd/conn_unix.go index 6094f41524f..8f8e7ed5091 100644 --- a/internal/dhcpd/conn_unix.go +++ b/internal/dhcpd/conn_unix.go @@ -201,6 +201,7 @@ func (c *dhcpConn) buildEtherPkt(payload []byte, peer *dhcpUnicastAddr) (pkt []b dhcpLayer := gopacket.NewPacket(payload, layers.LayerTypeDHCPv4, gopacket.DecodeOptions{ NoCopy: true, }).Layer(layers.LayerTypeDHCPv4) + // Check if the decoding succeeded and the resulting layer doesn't // contain any errors. It should guarantee panic-safe converting of the // layer into gopacket.SerializableLayer. @@ -220,6 +221,7 @@ func (c *dhcpConn) buildEtherPkt(payload []byte, peer *dhcpUnicastAddr) (pkt []b SrcIP: c.srcIP, DstIP: peer.yiaddr, } + // Ignore the error since it's only returned for invalid network layer's // type. _ = udpLayer.SetNetworkLayerForChecksum(ipv4Layer)