From 782de99a0ae71a3d4b3b9ec08f3c27842013d8d9 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Fri, 9 Sep 2022 19:44:27 +0300 Subject: [PATCH] Pull request: 4904 return dhcp msg size Merge in DNS/adguard-home from 4904-rm-padding to master Updates #4904. Updates #4903. Squashed commit of the following: commit 85337402ad64395704028534f17ac1887cff64e8 Author: Eugene Burkov Date: Fri Sep 9 19:38:09 2022 +0300 dhcpd: return dhcp msg size --- CHANGELOG.md | 6 ++++++ internal/dhcpd/v4.go | 16 ---------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67835936..ddad8fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/internal/dhcpd/v4.go b/internal/dhcpd/v4.go index 4d6c817b..5eec00bd 100644 --- a/internal/dhcpd/v4.go +++ b/internal/dhcpd/v4.go @@ -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. // @@ -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())