aboutsummaryrefslogtreecommitdiff
path: root/request
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-12-04 20:15:57 +0000
committerGravatar corbot[bot] <corbot[bot]@users.noreply.github.com> 2018-12-04 20:15:57 +0000
commit59a49c5ff7eeb6dad2e38ce8ccd5c4682e087005 (patch)
tree2bbb94f67f9299a246dc2f5c30eafa54e950e47b /request
parentb53cc51f5310b82e04d687b8b25783cfd972383c (diff)
downloadcoredns-59a49c5ff7eeb6dad2e38ce8ccd5c4682e087005.tar.gz
coredns-59a49c5ff7eeb6dad2e38ce8ccd5c4682e087005.tar.zst
coredns-59a49c5ff7eeb6dad2e38ce8ccd5c4682e087005.zip
Scrub: Do more to avoid fragmentation (#2333)
Automatically submitted.
Diffstat (limited to 'request')
-rw-r--r--request/request.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/request/request.go b/request/request.go
index 260d73f5e..105cd8528 100644
--- a/request/request.go
+++ b/request/request.go
@@ -240,6 +240,23 @@ func (r *Request) Scrub(reply *dns.Msg) *dns.Msg {
reply.Compress = false
rl := reply.Len()
if size >= rl {
+ if r.Proto() != "udp" {
+ return reply
+ }
+
+ // Last ditch attempt to avoid fragmentation, if the size is bigger than the v4/v6 UDP fragmentation
+ // limit and sent via UDP compress it (in the hope we go under that limit). Limits taken from NSD:
+ //
+ // .., 1480 (EDNS/IPv4), 1220 (EDNS/IPv6), or the advertized EDNS buffer size if that is
+ // smaller than the EDNS default.
+ // See: https://open.nlnetlabs.nl/pipermail/nsd-users/2011-November/001278.html
+ if rl > 1480 && r.Family() == 1 {
+ reply.Compress = true
+ }
+ if rl > 1220 && r.Family() == 2 {
+ reply.Compress = true
+ }
+
return reply
}