Commit graph

116 commits

Author SHA1 Message Date
Grant Spence
997c7f9539
plugin/cache: key cache on Checking Disabled (CD) bit (#6354)
* plugin/cache: key cache on Checking Disabled (CD) bit

Key the cache on CD bit, which effectively separates the entries for
queries with CD disabled or enabled.

Signed-off-by: Grant Spence <gspence@redhat.com>
2023-11-10 10:00:47 -05:00
Zhizhen He
2fe5890d8b
Fix typos (#6235)
* Fix typos and add todo to fix spelling of dnsutil.MaximumDefaulTTL

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-08-10 11:06:48 -04:00
Chris O'Haver
6c8581445e
fix keepttl parsing (#6250)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2023-08-09 08:32:50 -04:00
Arthur Outhenin-Chalandre
bf7c2cf37b
plugin/cache: add a new keepttl option (#5879)
adds a new option `keepttl` to the cache plugin

Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
2023-01-27 11:35:24 -05:00
Grant Spence
403e979934
plugin/cache: cache now uses source query DNSSEC option for upstream refresh (#5671)
Signed-off-by: Grant Spence <gspence@redhat.com>

Signed-off-by: Grant Spence <gspence@redhat.com>
2022-10-21 11:29:04 -04:00
Chris O'Haver
b56b080a7c
plugin/view: Advanced routing interface and new 'view' plugin (#5538)
* introduce new interface "dnsserver.Viewer", that allows a plugin implementing it to decide if a query should be routed into its server block.
* add new plugin "view", that uses the new interface to enable a user to define expression based conditions that must be met for a query to be routed to its server block.

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-09-08 14:56:27 -04:00
Chris O'Haver
95fcf2c480
plugin/cache: Add cache disable option (#5540)
* add cache disable options

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-07-28 10:51:08 -04:00
coredns[bot]
0e4ca22f44 auto go fmt
Signed-off-by: coredns[bot] <bot@bot.coredns.io>
2022-07-11 10:31:48 +00:00
Ondřej Benkovský
c2dbb7141a
add golangci-lint linter (#5499) 2022-07-10 11:06:33 -07:00
Chris O'Haver
83adb8fa22
plugin/file/cache: Add metadata for wildcard record responses (#5308)
For responses synthesized by known wildcard records, publish metadata containing the wildcard record name

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-07-07 17:07:04 -04:00
Chris O'Haver
dded10420b
plugin/cache: Add option to adjust SERVFAIL response cache TTL (#5320)
* add servfail cache opt

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-06-17 15:48:57 -04:00
Chris O'Haver
d60ce0c8d4
retain response AD bit if requestor's AD bit was set (#5191)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-06-17 15:47:35 -04:00
Chris O'Haver
d679f2e7d0
fix 'verify' option name in readme (#5441)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-06-17 15:31:16 -04:00
Chris O'Haver
4690d10f87
plugin/cache: Reword serve_stale docs for clarity (#5394)
* reword for clarity; use consistent terminology

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-06-07 09:43:03 -04:00
Antoine Tollenaere
66f2ac7568
plugin/cache: Add refresh mode setting to serve_stale (#5131)
This PR adds an optional REFRESH_MODE parameter on the serve_stale configuration directive of the
cache plugin, which verifies that the upstream is still unavailable before returning stale entries.

Signed-off-by: Antoine Tollenaere <atollena@gmail.com>
2022-05-02 13:16:33 -04:00
Chris O'Haver
c4bc1a5471
plugin/cache: Fix cache poisoning exploit (#5174) 2022-05-01 05:57:03 -07:00
Qasim Sarfraz
74b84a1377
update all +build statements (#5271)
* update all +build statements

Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com>

* remove old +build style

Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com>
2022-03-18 07:11:14 -07:00
Elijah Andrews
80195c399f
add zones label to cache metrics (#5124)
* add zones to cache metrics

Signed-off-by: Elijah Andrews <elijahcandrews@gmail.com>
2022-02-14 12:10:30 -05:00
xuweiwei
5f900b86f5
cleanup some code (#4989)
Automatically submitted.
2021-11-19 16:15:58 +00:00
Ben Kochie
7d542fec67
Update cache metrics (#4781)
Add a total cache request counter to follow Prometheus conventions[0].
Mark the existing cache miss metric as deprecated.

> Similarly, with hit or miss for caches, it’s better to have one
> metric for total and another for hits.

[0]: https://prometheus.io/docs/instrumenting/writing_exporters/#naming

Signed-off-by: SuperQ <superq@gmail.com>
2021-08-16 13:54:36 +08:00
Chris O'Haver
002b748ccd
plugin/cache: Unset AD flag when DO is not set for cache miss (#4736)
* 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-07-09 10:53:50 +02:00
Miek Gieben
5f41d8eb1f
reverse zone: fix Normalize (#4621)
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-05-17 13:19:54 -07:00
Frank Riley
5b9b079dab
Add cache eviction metrics to the cache plugin (#4411)
Signed-off-by: Frank Riley <fhriley@gmail.com>
2021-03-21 16:58:16 +01:00
Miek Gieben
38d4dacb88
Fix import ordering presubmit test (#4422)
Automatically submitted.
2021-01-24 17:28:49 +00:00
ZouYu
66fcaaeafc
Fix some typos (#4412)
Signed-off-by: zouyu <zouy.fnst@cn.fujitsu.com>
2021-01-20 08:59:03 +01:00
sschepens
b2a22eff04
Prevent race from prefetching (#4368)
Automatically submitted.
2021-01-15 12:32:49 +00:00
Miek Gieben
108d26ebea
Move .LocalAddr() out of goroutine (#4281)
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-12-11 08:49:47 -08:00
Miek Gieben
268781d355
cache: do the msg copy right (#4207)
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-15 07:47:07 -07:00
Miek Gieben
be09f47305
plugin/cache: fix removing OPT (#4190)
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-10-14 10:11:22 +08:00
Miek Gieben
35b40a84f2
plugin/cache: Fix filtering (#4148)
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-28 07:53:00 -07:00
Miek Gieben
b003d06003
For caddy v1 in our org (#4018)
* 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-24 18:14:41 +02:00
Miek Gieben
acf9a0fa19
cache: default to DNSSEC (#4085)
* 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-09-17 07:28:43 -07:00
Zou Nengren
4166dcc2fe
using promauto package to ensure all created metrics are properly registered (#4025)
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-07-25 08:06:28 -07:00
Chris O'Haver
47d6e86f58
plugin/cache/forward: Clean up grammar/wording in forward & cache metrics 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-24 07:49:42 -07:00
Zou Nengren
73e927d6a8
completed metrics of cache and forward (#3962)
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-06-24 06:54:03 +02:00
Zou Nengren
4ccd55e95e
correct metrics name of cache size (#3805)
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-04-03 09:30:06 -07:00
Zou Nengren
87214a4c5c
introduce metric naming test (#3789)
* 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-31 08:07:36 +02:00
Chris O'Haver
5cd8472384
Fix plugin name in project README (#3683)
* 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-26 10:24:56 -04:00
Chris O'Haver
40c7b9174b
plugin/cache: fix negative cache masking cases (#3744)
* 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-03-20 10:05:09 +01:00
Chris O'Haver
1339b89a8b
explain drop metric (#3706)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2020-02-29 07:07:49 +00:00
Miek Gieben
995179a6c6
presubmit: check import path ordering (#3636)
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-30 09:19:26 +00:00
Zheng Xie
f81f28d97b plugin/cache: update comment to conform to the implementation (#3573)
Signed-off-by: zheng xie <xiez1989@gmail.com>
2020-01-03 14:26:53 +01:00
Zou Nengren
99e7c3dee7 registry cache_miss logic (#3578)
Signed-off-by: zouyee <zounyee1989@gmail.com>
2020-01-03 10:06:37 +01:00
Gonzalo Paniagua Javier
b4df2d0d4c Add a serve_stale option for plugin/cache (#3468)
Automatically submitted.
2019-11-29 15:17:50 +00:00
Miek Gieben
24176a97e6
Move to CODEOWNERS (#3489)
* 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-11-29 13:17:05 +00:00
Miek Gieben
65458b2de2
Directive -> plugin (#3363)
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-08 10:20:48 +01:00
Miek Gieben
ffe6225ff6 kubernetes: brush up README, rename metric (#3360)
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-07 08:38:46 -07:00
Miek Gieben
03ea2ae955
Make request.Request smaller (#3351)
* 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-04 09:44:58 +01:00
Miek Gieben
f8551df272
cache: move goroutine closure to separate function to save memory (#3353)
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-10-03 15:05:44 +01:00
xieyanker
9a5e4fa1a0 fix mis-spelling (#3310)
Signed-off-by: xieyanker <xjsisnice@gmail.com>
2019-09-26 13:19:45 +01:00