Skip to content

Commit

Permalink
dhcpd: imp code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Sep 30, 2021
1 parent 2d1fbc4 commit 72eb3a8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/dhcpd/conn_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 72eb3a8

Please sign in to comment.