64000 max limit to DNS messages since there is overhead
Added debug log to give information about truncation.
This commit is contained in:
parent
06afb4d02c
commit
b672707552
15
agent/dns.go
15
agent/dns.go
|
@ -715,9 +715,10 @@ func syncExtra(index map[string]dns.RR, resp *dns.Msg) {
|
|||
|
||||
// trimTCPResponse limit the MaximumSize of messages to 64k as it is the limit
|
||||
// of DNS responses
|
||||
func trimTCPResponse(req, resp *dns.Msg) (trimmed bool) {
|
||||
func (d *DNSServer) trimTCPResponse(req, resp *dns.Msg) (trimmed bool) {
|
||||
hasExtra := len(resp.Extra) > 0
|
||||
maxSize := 65535
|
||||
// There is some overhead, 65535 does not work
|
||||
maxSize := 64000
|
||||
|
||||
// We avoid some function calls and allocations by only handling the
|
||||
// extra data when necessary.
|
||||
|
@ -726,6 +727,8 @@ func trimTCPResponse(req, resp *dns.Msg) (trimmed bool) {
|
|||
index = make(map[string]dns.RR, len(resp.Extra))
|
||||
indexRRs(resp.Extra, index)
|
||||
}
|
||||
originalSize := resp.Len()
|
||||
originalNumRecords := len(resp.Answer)
|
||||
truncated := false
|
||||
|
||||
// This enforces the given limit on 64k, the max limit for DNS messages
|
||||
|
@ -736,6 +739,12 @@ func trimTCPResponse(req, resp *dns.Msg) (trimmed bool) {
|
|||
syncExtra(index, resp)
|
||||
}
|
||||
}
|
||||
if truncated {
|
||||
d.logger.Printf("[DEBUG] dns: TCP answer to %v too large truncated recs:=%d/%d, size:=%d/%d",
|
||||
req.Question,
|
||||
len(resp.Answer), originalNumRecords, resp.Len(), originalSize)
|
||||
|
||||
}
|
||||
return truncated
|
||||
}
|
||||
|
||||
|
@ -796,7 +805,7 @@ func (d *DNSServer) trimDNSResponse(network string, req, resp *dns.Msg) (trimmed
|
|||
if network != "tcp" {
|
||||
trimmed = trimUDPResponse(req, resp, d.config.UDPAnswerLimit)
|
||||
} else {
|
||||
trimmed = trimTCPResponse(req, resp)
|
||||
trimmed = d.trimTCPResponse(req, resp)
|
||||
}
|
||||
// Flag that there are more records to return in the UDP response
|
||||
if trimmed && d.config.EnableTruncate {
|
||||
|
|
Loading…
Reference in New Issue