aboutsummaryrefslogtreecommitdiff
path: root/plugin/file/lookup.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2020-12-09 03:44:31 -0500
committerGravatar GitHub <noreply@github.com> 2020-12-09 09:44:31 +0100
commit6bbb48d403ce3e0974809200ef1da2a20e969c70 (patch)
tree3bdce0d97f473360456b8a1b77ceb7aec99a58a2 /plugin/file/lookup.go
parent5ecf23ae7b3c2c913c3aca13480c4276628fea9c (diff)
downloadcoredns-6bbb48d403ce3e0974809200ef1da2a20e969c70.tar.gz
coredns-6bbb48d403ce3e0974809200ef1da2a20e969c70.tar.zst
coredns-6bbb48d403ce3e0974809200ef1da2a20e969c70.zip
plugin/file: Use NXDOMAIN response if CNAME target is NXDOMAIN (#4303)
* pass through nxdomain results Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * return srvfail and nodata results Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * cover more response cases Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/file/lookup.go')
-rw-r--r--plugin/file/lookup.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/plugin/file/lookup.go b/plugin/file/lookup.go
index 28da3d4d0..e036d809a 100644
--- a/plugin/file/lookup.go
+++ b/plugin/file/lookup.go
@@ -307,8 +307,9 @@ func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *
targetName := rrs[0].(*dns.CNAME).Target
elem, _ = z.Tree.Search(targetName)
if elem == nil {
- rrs = append(rrs, z.doLookup(ctx, state, targetName, qtype)...)
- return rrs, z.Apex.ns(do), nil, Success
+ lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
+ rrs = append(rrs, lookupRRs...)
+ return rrs, z.Apex.ns(do), nil, result
}
i := 0
@@ -326,8 +327,9 @@ Redo:
targetName := cname[0].(*dns.CNAME).Target
elem, _ = z.Tree.Search(targetName)
if elem == nil {
- rrs = append(rrs, z.doLookup(ctx, state, targetName, qtype)...)
- return rrs, z.Apex.ns(do), nil, Success
+ lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
+ rrs = append(rrs, lookupRRs...)
+ return rrs, z.Apex.ns(do), nil, result
}
i++
@@ -352,15 +354,24 @@ Redo:
return rrs, z.Apex.ns(do), nil, Success
}
-func (z *Zone) doLookup(ctx context.Context, state request.Request, target string, qtype uint16) []dns.RR {
+func (z *Zone) doLookup(ctx context.Context, state request.Request, target string, qtype uint16) ([]dns.RR, Result) {
m, e := z.Upstream.Lookup(ctx, state, target, qtype)
if e != nil {
- return nil
+ return nil, Success
}
if m == nil {
- return nil
+ return nil, Success
+ }
+ if m.Rcode == dns.RcodeNameError {
+ return m.Answer, NameError
+ }
+ if m.Rcode == dns.RcodeServerFailure {
+ return m.Answer, ServerFailure
+ }
+ if m.Rcode == dns.RcodeSuccess && len(m.Answer) == 0 {
+ return m.Answer, NoData
}
- return m.Answer
+ return m.Answer, Success
}
// additionalProcessing checks the current answer section and retrieves A or AAAA records