Skip to content

Commit

Permalink
Pull request: 4904 return dhcp msg size
Browse files Browse the repository at this point in the history
Merge in DNS/adguard-home from 4904-rm-padding to master

Updates AdguardTeam#4904.
Updates AdguardTeam#4903.

Squashed commit of the following:

commit 8533740
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Fri Sep 9 19:38:09 2022 +0300

    dhcpd: return dhcp msg size
  • Loading branch information
EugeneOne1 authored and heyxkhoa committed Mar 17, 2023
1 parent aee2a27 commit ba42cc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ and this project adheres to
## [v0.108.0] - 2022-12-01 (APPROX.)
-->

### Changed

- The minimum DHCP message size is reassigned back to BOOTP's constraint of 300
bytes ([#4904]).

### Security

- Weaker cipher suites that use the CBC (cipher block chaining) mode of
operation have been disabled ([#2993]).

[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993
[#4904]: https://github.com/AdguardTeam/AdGuardHome/issues/4904



Expand Down
16 changes: 0 additions & 16 deletions internal/dhcpd/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,12 +1086,6 @@ func (s *v4Server) packetHandler(conn net.PacketConn, peer net.Addr, req *dhcpv4
s.send(peer, conn, req, resp)
}

// minDHCPMsgSize is the minimum length of the encoded DHCP message in bytes
// according to RFC-2131.
//
// See https://datatracker.ietf.org/doc/html/rfc2131#section-2.
const minDHCPMsgSize = 576

// send writes resp for peer to conn considering the req's parameters according
// to RFC-2131.
//
Expand Down Expand Up @@ -1133,16 +1127,6 @@ func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DH
}

pktData := resp.ToBytes()
pktLen := len(pktData)
if pktLen < minDHCPMsgSize {
// Expand the packet to match the minimum DHCP message length. Although
// the dhpcv4 package deals with the BOOTP's lower packet length
// constraint, it seems some clients expecting the length being at least
// 576 bytes as per RFC 2131 (and an obsolete RFC 1533).
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/4337.
pktData = append(pktData, make([]byte, minDHCPMsgSize-pktLen)...)
}

log.Debug("dhcpv4: sending %d bytes to %s: %s", len(pktData), peer, resp.Summary())

Expand Down

0 comments on commit ba42cc8

Please sign in to comment.