diff options
author | 2021-09-14 04:08:22 -0400 | |
---|---|---|
committer | 2021-09-14 10:08:22 +0200 | |
commit | 158ad2d73839632f8866b2934006ca4515581840 (patch) | |
tree | 3310a269c6e108efb1f9c54d1056475df2bd1f0d /plugin/file/file.go | |
parent | 8f7162c42b9de0a4a4f57b8869c31349b2ab4907 (diff) | |
download | coredns-158ad2d73839632f8866b2934006ca4515581840.tar.gz coredns-158ad2d73839632f8866b2934006ca4515581840.tar.zst coredns-158ad2d73839632f8866b2934006ca4515581840.zip |
plugin/file/auto: Write CNAME answer to client even if target lookup is SERVFAIL (#4863)
* write cname answer to client even if target lookup is servfail
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* fix existing unit test expectations
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/file/file.go')
-rw-r--r-- | plugin/file/file.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/plugin/file/file.go b/plugin/file/file.go index 0834ddc4d..f50c3d091 100644 --- a/plugin/file/file.go +++ b/plugin/file/file.go @@ -99,7 +99,14 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i case Delegation: m.Authoritative = false case ServerFailure: - return dns.RcodeServerFailure, nil + // If the result is SERVFAIL and the answer is non-empty, then the SERVFAIL came from an + // external CNAME lookup and the answer contains the CNAME with no target record. We should + // write the CNAME record to the client instead of sending an empty SERVFAIL response. + if len(m.Answer) == 0 { + return dns.RcodeServerFailure, nil + } + // The rcode in the response should be the rcode received from the target lookup. RFC 6604 section 3 + m.Rcode = dns.RcodeServerFailure } w.WriteMsg(m) |