aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-07-09plugin/cache: Unset AD flag when DO is not set for cache miss (#4736)Gravatar Chris O'Haver 2-1/+10
* unset AD bit when client DO is 0 Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add flag check to existing tests Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2021-05-17reverse zone: fix Normalize (#4621)Gravatar Miek Gieben 1-10/+1
Make normalize return multiple "hosts" (= reverse zones) when a non-octet boundary cidr is given. Added pkg/cidr package that holds the cidr calculation routines; felt they didn't really fit dnsutil. This change means the IPNet return parameter isn't needed, the hosts are all correct. The tests that tests this is also removed: TestSplitHostPortReverse The fallout was that zoneAddr _also_ doesn't need the IPNet member, that in turn make it visible that zoneAddr in address.go duplicated a bunch of stuff from register.go; removed/refactored that too. Created a plugin.OriginsFromArgsOrServerBlock to help plugins do the right things, by consuming ZONE arguments; this now expands reverse zones correctly. This is mostly mechanical. Remove the reverse test in plugin/kubernetes which is a copy-paste from a core test (which has since been fixed). Remove MustNormalize as it has no plugin users. This change is not backwards compatible to plugins that have a ZONE argument that they parse in the setup util. All in-tree plugins have been updated. Signed-off-by: Miek Gieben <miek@miek.nl>
2021-03-21Add cache eviction metrics to the cache plugin (#4411)Gravatar Frank Riley 3-2/+14
Signed-off-by: Frank Riley <fhriley@gmail.com>
2021-01-24Fix import ordering presubmit test (#4422)Gravatar Miek Gieben 1-0/+1
Automatically submitted.
2021-01-20Fix some typos (#4412)Gravatar ZouYu 1-1/+1
Signed-off-by: zouyu <zouy.fnst@cn.fujitsu.com>
2021-01-15Prevent race from prefetching (#4368)Gravatar sschepens 1-20/+16
Automatically submitted.
2020-12-11Move .LocalAddr() out of goroutine (#4281)Gravatar Miek Gieben 1-1/+2
I don't have theory why this panics, but concurrency has something to do with it, so get the address before we call the goroutine. See #4271 Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-15cache: do the msg copy right (#4207)Gravatar Miek Gieben 2-19/+16
Not sure why this is proving so difficult.. pointers are hard? [Was tempted to rollback all tweaks here, but the original issue we're fixing it too important to not have a proper fix]. But we need to make a copy of the message at the earliest point in the handler because we are changing it (adding an opt rr). If we do this on the original message (which is a pointer) we change it (obvs). When undoing those changes we do work on a copy. Re: testing. There isn't a explicit test for this, so I've added on to the top-level test/ directory, which indeed makes the issue visible: master: ~~~ go test -v -run=TestLookupCacheWithoutEdns === RUN TestLookupCacheWithoutEdns cache_test.go:154: Expected no OPT RR, but got: ;; OPT PSEUDOSECTION: ; EDNS: version 0; flags: do; udp: 2048 --- FAIL: TestLookupCacheWithoutEdns (0.01s) FAIL ~~~ This branch: ~~~ % go test -v -run=TestLookupCacheWithoutEdns === RUN TestLookupCacheWithoutEdns --- PASS: TestLookupCacheWithoutEdns (0.01s) PASS ok github.com/coredns/coredns/test 0.109s ~~~ Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-14plugin/cache: fix removing OPT (#4190)Gravatar Miek Gieben 3-6/+9
By checking state.Do() were are checking if the request had DO, but we are _always_ adding Do now - do we need to save the DO from the ORIGINAL request, which must be done in the ResponseWriter. Also skip OPT records in filterDNSSEC as we can't set the TTL on those records, this prevents writing a number to OPT's MBZ. Note none of the tests have changed and still PASS. This is due to the fact that CoreDNSServerAndPorts isn't a full server as we start in main, it lacks the scrubwriter for instance. This is not bad per se, but should be documented in the test code. Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-28plugin/cache: Fix filtering (#4148)Gravatar Miek Gieben 6-162/+174
The filtering of DNSSEC records in the cache plugin was not done correctly. Also the change to introduced this bug didn't take into account that the cache - by virtue of differentiating between DNSSEC and no-DNSSEC - relied on not copying the data from the cache. This change copies and then filters the data and factors the filtering into a function that is used in two places (albeit with on ugly boolean parameters to prevent copying things twice). Add tests, do_test.go is moved to test/cache_test.go because the OPT handing is done outside of the cache plugin. The core server re-attaches the correct OPT when replying, so that makes for a better e2e test. Added small unit test for filterRRslice and an explicit test that asks for DNSSEC first and then plain, and vice versa to test cache behavior. Fixes: #4146 Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-24For caddy v1 in our org (#4018)Gravatar Miek Gieben 2-3/+2
* For caddy v1 in our org This RP changes all imports for caddyserver/caddy to coredns/caddy. This is the v1 code of caddy. For the coredns/caddy repo the following changes have been made: * anything not needed by us is deleted * all `telemetry` stuff is deleted * all its import paths are also changed to point to coredns/caddy * the v1 branch has been moved to the master branch * a v1.1.0 tag has been added to signal the latest release Signed-off-by: Miek Gieben <miek@miek.nl> * Fix imports Signed-off-by: Miek Gieben <miek@miek.nl> * Group coredns/caddy with out plugins Signed-off-by: Miek Gieben <miek@miek.nl> * remove this file Signed-off-by: Miek Gieben <miek@miek.nl> * Relax import ordering github.com/coredns is now also a coredns dep, this makes github.com/coredns/caddy fit more natural in the list. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix final import Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-17cache: default to DNSSEC (#4085)Gravatar Miek Gieben 6-44/+204
* cache: default to DNSSEC This change does away with the DNS/DNSSEC distinction the cache currently makes. Cache will always make coredns perform a DNSSEC query and store that result. If a client just needs plain DNS, the DNSSEC records are stripped from the response. It should also be more memory efficient, because we store a reply once and not one DNS and another for DNSSEC. Fixes: #3836 Signed-off-by: Miek Gieben <miek@miek.nl> * Change OPT RR when one is present in the msg. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix comment for isDNSSEC Signed-off-by: Miek Gieben <miek@miek.nl> * Update plugin/cache/handler.go Co-authored-by: Chris O'Haver <cohaver@infoblox.com> * Update plugin/cache/item.go Co-authored-by: Chris O'Haver <cohaver@infoblox.com> * Code review; fix comment for isDNSSEC Signed-off-by: Miek Gieben <miek@miek.nl> * Update doc and set AD to false Set Authenticated Data to false when DNSSEC was not wanted. Also update the readme with the new behavior. Signed-off-by: Miek Gieben <miek@miek.nl> * Update plugin/cache/handler.go Co-authored-by: Chris O'Haver <cohaver@infoblox.com> Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
2020-07-25using promauto package to ensure all created metrics are properly registered ↵Gravatar Zou Nengren 2-14/+7
(#4025) Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-06-24plugin/cache/forward: Clean up grammar/wording in forward & cache metrics ↵Gravatar Chris O'Haver 2-2/+2
descriptions. (#3971) * tweak language Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * tweak language Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * typo Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-06-24completed metrics of cache and forward (#3962)Gravatar Zou Nengren 1-0/+1
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-04-03correct metrics name of cache size (#3805)Gravatar Zou Nengren 2-2/+2
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-03-31introduce metric naming test (#3789)Gravatar Zou Nengren 2-45/+52
* introduce metric naming test Signed-off-by: zounengren <zounengren@cmss.chinamobile.com> * Update metrics.go Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-03-26Fix plugin name in project README (#3683)Gravatar Chris O'Haver 1-1/+1
* Update README.md Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix readme occurances Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-03-20plugin/cache: fix negative cache masking cases (#3744)Gravatar Chris O'Haver 3-3/+107
* fix negative cache masking cases Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * remove unecessary param Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-02-29explain drop metric (#3706)Gravatar Chris O'Haver 1-1/+1
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-01-30presubmit: check import path ordering (#3636)Gravatar Miek Gieben 1-1/+1
Add a test for this as well as it's annoying to point out in every code review. Fix all the import paths that are flagged by this new test. Fixes: #3634 Signed-off-by: Miek Gieben <miek@miek.nl>
2020-01-03plugin/cache: update comment to conform to the implementation (#3573)Gravatar Zheng Xie 1-1/+6
Signed-off-by: zheng xie <xiez1989@gmail.com>
2020-01-03registry cache_miss logic (#3578)Gravatar Zou Nengren 1-0/+1
Signed-off-by: zouyee <zounyee1989@gmail.com>
2019-11-29Add a serve_stale option for plugin/cache (#3468)Gravatar Gonzalo Paniagua Javier 6-15/+166
Automatically submitted.
2019-11-29Move to CODEOWNERS (#3489)Gravatar Miek Gieben 1-6/+0
* Move to CODEOWNERS No change in who own what; just a move to CODEOWNERS. This allows dreck cleanups. Added .dreck.yaml for alias and exec. Fixes: #3486 Signed-off-by: Miek Gieben <miek@miek.nl> * stickler bot Signed-off-by: Miek Gieben <miek@miek.nl> * sort the file Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-08Directive -> plugin (#3363)Gravatar Miek Gieben 1-2/+2
Caught my eye, we name things directive still, esp when talking about the prometheus *plugin*. Rename everything that needs to be plugin to 'plugin'. Also make sure Metrics is a H2 section (not H1). Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-07kubernetes: brush up README, rename metric (#3360)Gravatar Miek Gieben 1-1/+1
Other latency metrics have `_duration` in the name change this metric to be in sync with the other ones. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-04Make request.Request smaller (#3351)Gravatar Miek Gieben 1-1/+1
* Make request.Request smaller This makes the request struct smaller and removes the pointer to the do boolean (tri-bool) as size == 0 will indicate if we have cached it. Family can be a int8 because it only carries 3 values, Size itself is just a uint16 under the covers. This is a more comprehensive fix than #3292 Closes #3292 Signed-off-by: Miek Gieben <miek@miek.nl> * cache: fix test this now needs a valid response writter Signed-off-by: Miek Gieben <miek@miek.nl>
2019-10-03cache: move goroutine closure to separate function to save memory (#3353)Gravatar Miek Gieben 1-20/+25
The goroutine closure was causing objects to be heap allocated. Moving it to a separate function fixes that. ```benchmark old ns/op new ns/op delta BenchmarkCacheResponse/NoPrefetch-12 773 713 -7.76% BenchmarkCacheResponse/Prefetch-12 878 837 -4.67% BenchmarkHash-12 9.17 9.18 +0.11% benchmark old allocs new allocs delta BenchmarkCacheResponse/NoPrefetch-12 9 8 -11.11% BenchmarkCacheResponse/Prefetch-12 9 8 -11.11% BenchmarkHash-12 0 0 +0.00% benchmark old bytes new bytes delta BenchmarkCacheResponse/NoPrefetch-12 471 327 -30.57% BenchmarkCacheResponse/Prefetch-12 471 327 -30.57% BenchmarkHash-12 0 0 +0.00% ``` Signed-off-by: Charlie Vieth <charlie.vieth@gmail.com> Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-26fix mis-spelling (#3310)Gravatar xieyanker 1-1/+1
Signed-off-by: xieyanker <xjsisnice@gmail.com>
2019-09-20all: simply registering plugins (#3287)Gravatar Miek Gieben 1-6/+1
Abstract the caddy call and make it simpler. See #3261 for some part of the discussion. Go from: ~~~ go func init() { caddy.RegisterPlugin("any", caddy.Plugin{ ServerType: "dns", Action: setup, }) } ~~~ To: ~~~ go func init() { plugin.Register("any", setup) } ~~~ This requires some external documents in coredns.io to be updated as well; the old way still works, so it's backwards compatible. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-09-19update doc to not use the root zone for everything (#3288)Gravatar Miek Gieben 1-7/+7
Update all documentation in the tree to use example.org as an example configuration (in so far possible). As to get out of the just use "." and fallthrough and things would be fine. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-25fuzz: revert setup function (#3189)Gravatar Miek Gieben 1-1/+1
This can't be used in its current form; revert the entire PR. Revert "fuzzing: allow setup function to be called (#3175)" This reverts commit 62451fd3eb68cef5dcdafe6e4228f08cf52d84fc.
2019-08-25fuzz: use gofuzz build tag instead of fuzz (#3185)Gravatar Muhammad Falak R Wani 1-1/+1
* fuzz: use gofuzz build tag instead of fuzz Since go-fuzz does not support Go modules yet, vendor dependencies. Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> * fuzz: avoid vendoring code for go-fuzz Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2019-08-24fuzzing: allow setup function to be called (#3175)Gravatar Miek Gieben 1-1/+1
This allows to fuzzing of more interesting targets that require setup. Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-19fix mis-spelling in item.go (#3156)Gravatar AllenZMC 1-1/+1
2019-07-03Update Caddy to 1.0.1, and update import path (#2961)Gravatar Yong Tang 2-2/+2
* Update Caddy to 1.0.1, and update import path This fix updates caddy to 1.0.1 and also updates the import path to github.com/caddyserver/caddy This fix fixes 2959 Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Also update plugin.cfg Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update and bump zplugin.go Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-06-13plugin/cache: remove item.Autoritative (#2885)Gravatar Miek Gieben 2-12/+12
* plugin/cache: remove item.Autoritative Confuses clients if not set; remove it. Signed-off-by: Miek Gieben <miek@miek.nl> * Add extra comments on why we do this Signed-off-by: Miek Gieben <miek@miek.nl>
2019-04-08[plugin/cache] cache failures (#2720)Gravatar Kun Chang 2-1/+32
* cache failures * use ServerError
2019-03-04Move *proxy* to external (#2651)Gravatar Yong Tang 1-2/+3
* Move *proxy* to external move the proxy plugin into coredns/proxy and remove it as a default plugin. Link the proxy to deprecated in plugin.cfg coredns/proxy doesn't compile because of the vendoring :( Signed-off-by: Miek Gieben <miek@miek.nl> * Add github.com/coredns/proxy Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-02-17Fix some typos (#2560)Gravatar Nguyen Quang Huy 2-2/+2
* Fix some typos Corect some words for reading more easily * Update NOERROR response code NOERROR is a response code so I revert the typo checking for it
2019-02-07Fix some spelling errors in comment (#2533)Gravatar JoeWrightss 1-1/+1
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-01-19Stop importing testing in the main binary (#2479)Gravatar Miek Gieben 1-9/+8
* Stop importing testing in the main binary Stop importing "testing" into the main binary: * test/helpers.go imported it; remote that and change function signature * update all tests that use this Signed-off-by: Miek Gieben <miek@miek.nl> * Drop import testing from metrics plugin Signed-off-by: Miek Gieben <miek@miek.nl> * more fiddling Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-01remove trailing whitespace (#2260)Gravatar Chris O'Haver 1-2/+2
2018-10-29cache: some optimizations (#2247)Gravatar Miek Gieben 2-21/+10
Remove some optimization and lowercasing of the qname (in the end miekg/dns should provide a fast and OK function for it). * remove the make([]byte, 2) allocation in the key() * use already lowercased qname in hash key calculation. % benchcmp old.txt new.txt benchmark old ns/op new ns/op delta BenchmarkCacheResponse-4 9599 8735 -9.00% Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-29plugin/cache: Document actual cache defaults (#2249)Gravatar Chris O'Haver 1-3/+4
2018-10-22make default min ttl 5 (#2227)Gravatar Chris O'Haver 2-4/+4
2018-10-19plugin/cache: fix TTL for negative DNS responses (#2197)Gravatar Ruslan Drozhdzh 1-2/+1
2018-10-16plugin/cache: Set min TTL default to zero (#2199)Gravatar Chris O'Haver 2-4/+4
* set min ttl default to zero * add short TTL test case
2018-09-19Ensure Re-register of metrics variables after a reload (#2080)Gravatar Francois Tur 2-8/+3
* - ensure plugins that use prometheus.MustRegister, re-register after reload - removing once.Do on the startup function was simplest way to do it. * - fix underscored names (advice of bot) * - tune existing UT for reload, and add a test verifying failing reload does not prevent correct registering for metrics * - ensure different ports for tests that can run in same time ..