aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/handler.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-03-25 17:11:10 +0100
committerGravatar GitHub <noreply@github.com> 2018-03-25 17:11:10 +0100
commit5616fcb175865f2d8ede0460e2537c3b584debad (patch)
treed468f2bd8d9d64fffd9a2b659f18e767ec817832 /plugin/cache/handler.go
parent91413c25e12abdcdfcc3be9b1177251da905e882 (diff)
downloadcoredns-5616fcb175865f2d8ede0460e2537c3b584debad.tar.gz
coredns-5616fcb175865f2d8ede0460e2537c3b584debad.tar.zst
coredns-5616fcb175865f2d8ede0460e2537c3b584debad.zip
Fix dns-01-003 (#1634)
* plugin/{cache,forward,proxy}: don't allow responses that are bogus Responses that are not matching what we've been querying for should be dropped. They are converted into FormErrs by forward and proxy; as a 2nd backstop cache will also not cache these. * plug * add explicit test
Diffstat (limited to 'plugin/cache/handler.go')
-rw-r--r--plugin/cache/handler.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugin/cache/handler.go b/plugin/cache/handler.go
index e579aaffc..c2efdc9c7 100644
--- a/plugin/cache/handler.go
+++ b/plugin/cache/handler.go
@@ -46,7 +46,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
// When prefetching we loose the item i, and with it the frequency
// that we've gathered sofar. See we copy the frequencies info back
// into the new item that was stored in the cache.
- prr := &ResponseWriter{ResponseWriter: w, Cache: c, prefetch: true}
+ prr := &ResponseWriter{ResponseWriter: w, Cache: c, prefetch: true, state: state}
plugin.NextOrFailure(c.Name(), c.Next, ctx, prr, r)
if i1 := c.exists(qname, qtype, do); i1 != nil {
@@ -58,7 +58,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
return dns.RcodeSuccess, nil
}
- crr := &ResponseWriter{ResponseWriter: w, Cache: c}
+ crr := &ResponseWriter{ResponseWriter: w, Cache: c, state: state}
return plugin.NextOrFailure(c.Name(), c.Next, ctx, crr, r)
}
@@ -127,6 +127,13 @@ var (
Name: "prefetch_total",
Help: "The number of time the cache has prefetched a cached item.",
})
+
+ cacheDrops = prometheus.NewCounter(prometheus.CounterOpts{
+ Namespace: plugin.Namespace,
+ Subsystem: "cache",
+ Name: "drops_total",
+ Help: "The number responses that are not cached, because the reply is malformed.",
+ })
)
var once sync.Once