From 50ef7409d1d351fdd0c7cafa8f382b6e17fa3a35 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Thu, 29 Nov 2018 20:02:32 +0000 Subject: [PATCH] Up to DNS version 1.1.0 (#2346) Upgrade to new dns lib version; that saw multiple improvements; some patch releases are in the pipeline. The big thing here is the removal of ErrTruncated, so we need to deal with this slightly different in the forward plugin. It removed the entire truncated.go logic and just checks the message for .Truncated (if there is a message) and retries with tcp. Signed-off-by: Miek Gieben --- Makefile | 2 +- plugin/forward/forward.go | 3 +-- plugin/forward/lookup.go | 1 - plugin/forward/truncated.go | 29 ----------------------------- 4 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 plugin/forward/truncated.go diff --git a/Makefile b/Makefile index d0531e60c..5efbaf8c8 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ godeps: go get -u github.com/prometheus/client_golang/prometheus/promhttp go get -u github.com/prometheus/client_golang/prometheus (cd $(GOPATH)/src/github.com/mholt/caddy && git checkout -q v0.11.1) - (cd $(GOPATH)/src/github.com/miekg/dns && git checkout -q v1.0.15) + (cd $(GOPATH)/src/github.com/miekg/dns && git checkout -q v1.1.0) (cd $(GOPATH)/src/github.com/prometheus/client_golang && git checkout -q v0.8.0) @ # for travis only, if this fails we don't care, but don't see benchmarks go get -u golang.org/x/tools/cmd/benchcmp || true diff --git a/plugin/forward/forward.go b/plugin/forward/forward.go index dfa1aaca1..66526509b 100644 --- a/plugin/forward/forward.go +++ b/plugin/forward/forward.go @@ -116,7 +116,7 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg continue } // Retry with TCP if truncated and prefer_udp configured. - if err == dns.ErrTruncated && !opts.forceTCP && f.opts.preferUDP { + if ret != nil && ret.Truncated && !opts.forceTCP && f.opts.preferUDP { opts.forceTCP = true continue } @@ -127,7 +127,6 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg child.Finish() } - ret, err = truncated(state, ret, err) upstreamErr = err if err != nil { diff --git a/plugin/forward/lookup.go b/plugin/forward/lookup.go index 855230b9a..f3eb8f34a 100644 --- a/plugin/forward/lookup.go +++ b/plugin/forward/lookup.go @@ -35,7 +35,6 @@ func (f *Forward) Forward(state request.Request) (*dns.Msg, error) { ret, err := proxy.Connect(context.Background(), state, f.opts) - ret, err = truncated(state, ret, err) upstreamErr = err if err != nil { diff --git a/plugin/forward/truncated.go b/plugin/forward/truncated.go deleted file mode 100644 index fb821d335..000000000 --- a/plugin/forward/truncated.go +++ /dev/null @@ -1,29 +0,0 @@ -package forward - -import ( - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// truncated looks at the error and if truncated return a nil error -// and a possible reconstructed dns message if that was nil. -func truncated(state request.Request, ret *dns.Msg, err error) (*dns.Msg, error) { - // If you query for instance ANY isc.org; you get a truncated query back which miekg/dns fails to unpack - // because the RRs are not finished. The returned message can be useful or useless. Return the original - // query with some header bits set that they should retry with TCP. - if err != dns.ErrTruncated { - return ret, err - } - - // We may or may not have something sensible... if not reassemble something to send to the client. - m := ret - if ret == nil { - m = new(dns.Msg) - m.SetReply(state.Req) - m.Truncated = true - m.Authoritative = true - m.Rcode = dns.RcodeSuccess - } - return m, nil -}