From 3764c1dfe497a150d09272257065ea5b5a49ecf6 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 25 Mar 2021 17:21:00 +0300 Subject: [PATCH] Pull request: dnsforward: fix nxdomain for internal aaaa reqs Updates #2393. Squashed commit of the following: commit 5ea4d3c2f217ed800da79c3d87184d8e0956e56c Author: Ainar Garipov Date: Thu Mar 25 17:01:08 2021 +0300 dnsforward: fix nxdomain for internal aaaa reqs --- internal/dnsforward/dns.go | 6 +++++- internal/dnsforward/dns_test.go | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index b5f6c4ecd0e..d86bda42875 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -192,7 +192,11 @@ func (s *Server) onDHCPLeaseChanged(flags int) { func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) { req := dctx.proxyCtx.Req q := req.Question[0] - if q.Qtype != dns.TypeA { + + // Go on processing the AAAA request despite the fact that we don't + // support it yet. The expected behavior here is to respond with an + // empty asnwer and not NXDOMAIN. + if q.Qtype != dns.TypeA && q.Qtype != dns.TypeAAAA { return resultCodeSuccess } diff --git a/internal/dnsforward/dns_test.go b/internal/dnsforward/dns_test.go index 682a12c531f..188d07050c8 100644 --- a/internal/dnsforward/dns_test.go +++ b/internal/dnsforward/dns_test.go @@ -52,6 +52,14 @@ func TestServer_ProcessInternalHosts(t *testing.T) { wantIP: nil, qtyp: dns.TypeA, wantRes: resultCodeSuccess, + }, { + name: "success_internal_aaaa", + host: "example.lan", + suffix: defaultAutohostSuffix, + wantErrMsg: "", + wantIP: nil, + qtyp: dns.TypeAAAA, + wantRes: resultCodeSuccess, }} for _, tc := range testCases { @@ -92,7 +100,14 @@ func TestServer_ProcessInternalHosts(t *testing.T) { } pctx := dctx.proxyCtx - if tc.wantIP == nil { + if tc.qtyp == dns.TypeAAAA { + // TODO(a.garipov): Remove this special handling + // when we fully support AAAA. + require.NotNil(t, pctx.Res) + + ans := pctx.Res.Answer + require.Len(t, ans, 0) + } else if tc.wantIP == nil { assert.Nil(t, pctx.Res) } else { require.NotNil(t, pctx.Res)