Skip to content

Commit

Permalink
dhcpd: do not panic
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed May 14, 2021
1 parent 4236789 commit eb68a21
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/dhcpd/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,13 @@ func (s *v4Server) processDecline(req, resp *dhcpv4.DHCPv4) (err error) {
newLease, err := s.allocateLease(mac)
if err != nil {
return fmt.Errorf("allocating new lease for %s: %w", mac, err)
} else if newLease == nil {
log.Info("dhcpv4: allocating new lease for %s: no more ip addresses", mac)

resp.YourIPAddr = make([]byte, 4)
resp.UpdateOption(dhcpv4.OptMessageType(dhcpv4.MessageTypeAck))

return nil
}

newLease.Hostname = oldLease.Hostname
Expand Down

0 comments on commit eb68a21

Please sign in to comment.