Commit Graph

1630 Commits

Author SHA1 Message Date
Ilya Kulakov
25eb456b57 plugin/file: fix less is not up to RFC 1034 and 4034 (#8503)
* plugin/file: fix less to follow RFC 1034 and RFC 4034 matching and ordering requirements

- Ensure comparison is left-justified
- Ensure case folding applies only to A-Z
- Decode \DDD without allocations

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>

* plugin/file: faster exit for less when a == b

Avoid two calls and two reslices.

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>

* plugin/file: consolidate less tests

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>

* plugin/file: exit less early when there are no more labels

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>

* plugin/file: match dns.PackDomainName in handling \-escapes

Compare unterminated names as root-terminating

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>

* plugin/file: More tests of less.

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>

---------

Signed-off-by: Ilya Kulakov <kulakov.ilya@gmail.com>
2026-09-16 17:51:15 -07:00
houyuwushang
b93e449b2f Add opt-in JSON logging with structured DNS query fields (#8553)
* plugin/pkg/log: add opt-in JSON logging backend

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

* plugin/log: emit typed query records in JSON mode

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

* coremain: expose process-wide JSON logging

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

---------

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-09-16 17:50:39 -07:00
houyuwushang
84a93a0b89 plugin/file: reject SOA owners that do not match the zone (#8555)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-09-16 17:49:58 -07:00
Baltasar Blanco
14ed42bd1f plugin/hosts: don't drop over-long fields silently (#8551)
#8496 fixed a silent truncation here and named the invariant in its own commit
message: entries were dropped and the hosts file simply looked shorter than it
is, with nothing in the log.

#8516 replaced that mechanism with a streaming parser bounded by maxFieldSize.
The error log #8496 added is still in parse(), but it can no longer report a
dropped entry: bufio.ErrBufferFull is consumed by the read loop, so only a real
I/O error reaches it. A field over maxFieldSize is discarded in lineParser with
no log at all, and when that field is the address the whole line goes with it.

Report both cases, once per dropped field, with the line number and the source
the entries came from.

Signed-off-by: Baltasar Blanco <baltasarblanco.dev@gmail.com>
2026-09-15 19:24:23 -07:00
Sakıp Han Dursun
8de7a8b89d fix(kubernetes): include structured key/value context in client-go logs (#8490) 2026-09-15 00:42:44 -07:00
Saleh
b0b317fdd6 plugin/dnstap: tap deferred error responses (#8549)
When the plugin chain returns an error rcode without writing a response
(it falls off the end, or returns SERVFAIL/REFUSED/FORMERR/NOTIMP), the
server generates and sends the error to the client after dnstap's ServeDNS
returns, so ResponseWriter.WriteMsg is never called and no CLIENT_RESPONSE
dnstap message is emitted. dnstap consumers then see a CLIENT_QUERY with no
matching CLIENT_RESPONSE.

Synthesize the deferred response and tap it as a CLIENT_RESPONSE, mirroring
the deferred-response handling already added to plugin/log.

Fixes #6532

Signed-off-by: Saleh <root@lr0.org>
2026-09-14 17:25:11 -07:00
Paco Cartones
22351a0d3c fix(metrics): release listener on TLS startup failure (#8527) 2026-09-13 17:57:30 -07:00
Ilya Kulakov
5bd1701376 plugin/tls: document that dig supports DoT (#8539) 2026-09-13 17:56:16 -07:00
Yong Tang
19adcd8b96 Fix etcd library update issue (#8542)
This PR fixes etcd library update issue in 8492 where additional lint fix
is needed to take the latest etcd dependency.

This PR supersede 8492.

This PR closes 8492.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-09-10 23:59:33 -07:00
houyuwushang
b51e6d254b plugin/azure: allow startup with unavailable zones (#8524)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-09-10 20:54:12 -07:00
Yong Tang
4382b80a35 core: upgrade Go requirement to 1.26.0 (#8466)
* core: upgrade Go requirement to 1.26.0

As golang 1.27 has been released, this PR
- Bump Go version requirement to 1.26.0
- Update Go build version to 1.27.0

This is also for solving the issue encountered in 8092 of k8s update

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Bump golang ci

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Fix

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Fix

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Fix

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Migrate faillint to forbidigo, as failint has not bee updated for more than a year

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

---------

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-09-10 19:34:44 -07:00
Paco Cartones
5ac0ca4fad fix(ready): release lock before server shutdown (#8526)
Signed-off-by: Paco Cartones <pacocartones@users.noreply.github.com>
Co-authored-by: Paco Cartones <pacocartones@users.noreply.github.com>
2026-09-08 13:15:00 -07:00
Baltasar Blanco
dea2f90f24 plugin/file: return SERVFAIL on self-referential CNAME loops (#8475)
A CNAME whose target is its own owner name is chased by externalLookup
until the depth cap, appending the same record on every pass. The reply
was NOERROR with the CNAME repeated ten times.

Self-referential DNAME already returns SERVFAIL, as do wildcard CNAME
loops. Return SERVFAIL here too. The check runs on the CNAME chase path
only, so normal responses are unaffected.

Fixes #6421

Signed-off-by: baltasarblanco <baltablanco9008@gmail.com>
2026-09-08 12:21:54 -07:00
houyuwushang
e1d3fe6bc6 plugin/forward: support DNS-over-QUIC upstreams (#8474)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-09-07 21:51:18 -07:00
Baltasar Blanco
71a60e140b plugin/loadbalance: validate the response before dereferencing it in WriteMsg (#8523) 2026-09-07 20:50:54 -07:00
sam lockart
9fb1859b23 fix(reload): broadcast shutdown signal (#8504)
* fix(reload): broadcast shutdown signal

Signed-off-by: alam0rt <sam@samlockart.com>

* fix(reload): scope shutdown state to instances

Signed-off-by: alam0rt <sam@samlockart.com>

---------

Signed-off-by: alam0rt <sam@samlockart.com>
2026-09-06 19:40:07 -07:00
myohannes
2b8c305203 plugin/https: Add max_streams to limit HTTP/2 concurrent streams (#8522)
Add a max_streams option to the *https* plugin to limit the number of
concurrent HTTP/2 streams per DoH connection. This lets operators cap
per-connection concurrency (guarding against resource exhaustion) or
raise it above the Go default for high-fan-in clients that multiplex
many requests over a single connection.

Semantics match the existing *https3* plugin's max_streams:
- omitted  -> Go HTTP/2 server default is used
- 0        -> use the underlying HTTP/2 transport default
- positive -> advertise exactly that many concurrent streams
- negative -> rejected at config parse time

The limit is applied via the standard library http.Server.HTTP2
(HTTP2Config.MaxConcurrentStreams) so it is advertised in the server's
SETTINGS frame.

Signed-off-by: Mekias Yohannes <mmyohannes@gmail.com>
2026-09-06 19:16:44 -07:00
Paco Cartones
558c9757a9 plugin/hosts: parse hosts files with bufio.Reader (#8516) 2026-09-05 17:39:42 -07:00
Zhao Jianing
b564fcd869 plugin/autopath: Fixes a nil pointer dereference panic in autopath during search path walk (#8517)
* plugin/autopath: Fixes a nil pointer dereference panic in autopath during search path walk

When a plugin later in the chain returns a ClientWrite rcode without
writing a response (for example acl's drop action, which returns
(dns.RcodeSuccess, nil) without calling WriteMsg), autopath dereferences
a nil nw.Msg at nw.Msg.Rcode and panics. The final fallback
w.WriteMsg(firstReply) can also receive a nil firstReply for the same
reason.

Skip search path elements that produced no message, and only write the
first reply when it is non-nil. This mirrors the nil guards recently
added in plugin/minimal (#8506), plugin/dns64 (#8511) and plugin/cache
(#8512).

Signed-off-by: zjncs <18910855655@163.com>

* plugin/autopath: silence unused-parameter lint and assert no client write

Address review feedback on #8517: rename the unused 'w' parameter in
TestAutoPathNilMsgFromNext to '_w' so the revive unused-parameter check
passes, and assert that the recorder receives no message so the intended
drop/no-client-write behavior is explicit.

Signed-off-by: zjncs <18910855655@163.com>

---------

Signed-off-by: zjncs <18910855655@163.com>
2026-09-05 02:20:27 -07:00
houyuwushang
b6987aeb4a request: stop echoing unhandled EDNS options (#8514)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-09-04 18:14:53 -07:00
houyuwushang
895eab37e8 plugin/kubernetes: isolate NS address test fixtures (#8513)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-09-04 18:14:27 -07:00
Zhao Jianing
99b203f6bb plugin/k8s_external: Fixes a nil pointer dereference panic when upstream lookup returns no response (#8518)
* plugin/k8s_external: Fixes a nil pointer dereference panic when upstream lookup returns no response

When a CNAME-hosted service is resolved, k8s_external performs internal
upstream lookups for the target name. Upstream.Lookup can return a nil
message with a nil error when the internal self-query's plugin chain
returns a ClientWrite rcode without writing a response (for example
acl's drop action), and the a/aaaa/srv handlers then dereference
resp.Answer on a nil resp and panic.

Guard all four lookups with err == nil && resp != nil, matching the nil
checks already used in plugin/backend_lookup.go and the guard recently
added to plugin/dns64 (#8511).

Signed-off-by: zjncs <18910855655@163.com>

* plugin/k8s_external: silence unused-parameter lint in nil upstream test

The CI lint flagged the test handler's unused 'w' parameter. Rename it
to '_' so golangci-lint (revive unused-parameter) passes. No behavior
change.

Signed-off-by: zjncs <18910855655@163.com>

---------

Signed-off-by: zjncs <18910855655@163.com>
2026-09-04 18:03:47 -07:00
Zhao Jianing
fe9dffcd13 plugin/rewrite: Fixes a nil pointer dereference panic in ResponseReverter.WriteMsg (#8519)
ResponseReverter.WriteMsg calls res1.Copy() without checking res1 for
nil, so any plugin further down the chain that writes a nil response
(for example a handler returning (dns.RcodeSuccess, nil) after
w.WriteMsg(nil)) panics here.

Return an error instead, mirroring the nil guard recently added to
plugin/cache's ResponseWriter.WriteMsg (#8512).

Signed-off-by: zjncs <18910855655@163.com>
2026-09-04 18:02:52 -07:00
Yong Tang
c2e309e2e4 plugin/cache: Prevents a nil pointer dereference panic in the cache prefetch (#8512)
* plugin/cache: Prevents a nil pointer dereference panic in the cache prefetch

This PR prevents a nil pointer dereference panic in the cache prefetch, by
adding nil guards

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Address comment

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

---------

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-09-03 01:11:33 -07:00
Ilya Kulakov
c942ca7c36 plugin: use Zones.Contains when any match suffices (#8505) 2026-09-02 23:59:58 -07:00
Yong Tang
f1d835aa51 plugin/dns64: Fixes a nil pointer dereference panic in dns64 during response (#8511)
This PR fixes a nil pointer dereference panic in dns64 during response,
when the internal A-record upstream re-lookup returns a nil response.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-09-02 21:07:28 -07:00
Yong Tang
88ab058ba2 plugin/minimal: Fixes a nil pointer dereference panic in minimal prefetch response processing (#8506)
* plugin/minimal: Fixes a nil pointer dereference panic in minimal prefetch response processing

This PR fixes a nil pointer dereference panic in minimal prefetch response processing

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Fix lint

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

---------

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2026-09-02 07:58:49 -07:00
Paco Cartones
85aa27cd9c plugin/hosts: don't drop entries after an over-long line (#8496)
bufio.Scanner stops at the first line longer than its 64KiB default
buffer and reports bufio.ErrTooLong from Err(). parse() never checked
Err(), so that line and every entry after it were dropped silently: the
hosts file simply looked shorter than it is, with nothing in the log.

Raise the scanner's limit to 1MiB (the scanner still grows its buffer
lazily, so nothing is preallocated up front) and log an error if the
scan does stop early, so the truncation is at least visible.

Signed-off-by: Paco Cartones <pacocartones@users.noreply.github.com>
Co-authored-by: Paco Cartones <pacocartones@users.noreply.github.com>
2026-09-01 00:01:04 -07:00
houyuwushang
789b8d1665 plugin/tsig: expose validated TSIG key identity (#8471)
Store the normalized key name in the request context only after successful TSIG verification. This lets downstream plugins distinguish unsigned requests from authenticated requests and authorize by key without relying on the stripped TSIG RR or exposing secret material.

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-08-26 14:13:48 -07:00
houyuwushang
b8720090b5 plugin/etcd: allow disabling legacy apex fallback (#8468)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-08-23 17:56:12 -07:00
Michée lengronne
3b9f85bb71 feat(siit): Initial version (#8188)
* feat(siit): Initial version

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* cleaner readme

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* linting and generating

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* improving README and removing a useless case

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* improvements

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* improvements

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* linting

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* New fixes

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* improvements

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

* improvements

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>

---------

Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>
2026-08-23 17:55:27 -07:00
Baltasar Blanco
234f5fd378 plugin/cache: stop setting AA on answers served from cache (#8419)
* plugin/cache: stop setting AA on answers served from cache

toMsg hardcoded m1.Authoritative = true, so a reply rebuilt from a cache entry claimed authority the answer that populated it never had.

The hardcoding was a workaround for legacy stub resolvers that dropped non-authoritative answers, but it only ever ran on the cache hit path: the same query still returned AA=0 on every miss and after every TTL expiry, so those clients were never actually protected.

Signed-off-by: baltasarblanco <baltablanco9008@gmail.com>

* plugin/cache: pin the AA=1 side of the cache round trip

Signed-off-by: baltasarblanco <baltablanco9008@gmail.com>

* plugin/cache: assert AA=0 on verified stale refresh and prove the cache hit

Signed-off-by: baltasarblanco <baltablanco9008@gmail.com>

* plugin/cache: count backend calls in TestCachePreservesAA

Signed-off-by: baltasarblanco <baltablanco9008@gmail.com>

---------

Signed-off-by: baltasarblanco <baltablanco9008@gmail.com>
2026-08-23 17:54:41 -07:00
houyuwushang
4b26cced32 plugin/etcd: avoid apex fallback on backend errors (#8465)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-08-20 02:24:12 -07:00
Manuel Rüger
992d4c20db plugin/loadbalance: reduce roundRobin allocations for homogeneous address sets (#8375)
* perf(loadbalance): fast-path zero-allocation roundRobin for homogeneous record sets

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* plugin/loadbalance: copy before shuffling in the fast path

The fast path shuffled the caller's slice in place, which is not safe.
roundRobin must not modify its input: a backend may hand back a slice it
owns rather than one built for the response. plugin/file does exactly that
- Lookup returns elem.Type(qtype), which is the zone tree's own []dns.RR -
so an in-place shuffle reorders the zone itself, visible to every other
query and racing with the ones running concurrently.

Copy the records into a fresh slice and shuffle that instead. This is still
a single allocation rather than the four slices the partitioning path builds,
so most of the gain is kept:

    name          old time/op    new time/op    delta
    RoundRobin      353 ns         244 ns       -31%

    name          old alloc/op   new alloc/op   delta
    RoundRobin      118 B           54 B        -54%

    name          old allocs/op  new allocs/op  delta
    RoundRobin        5              4          -20%

Also reorder the type check so a response led by a CNAME is rejected on the
first record instead of scanning the whole answer section first.

TestRoundRobinDoesNotMutateInput pins the contract; it fails against the
in-place version.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

---------

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2026-08-19 20:27:35 -07:00
Manuel Rüger
50ffa1ecf9 plugin/rewrite: drop the per-record dot-prefixed temporary in remapStringRewriter (#8382)
remapStringRewriter matches a record name against orig and its sub domains. The
sub domain check was strings.HasSuffix(src, "."+r.orig), which built the
dot-prefixed string on every call and threw it away. Match the label boundary by
index instead: src is a sub domain of orig when orig sits at the end of src with
a "." immediately before it, which is exactly what the HasSuffix call tested.

Go concatenates short strings into a 32-byte stack buffer, so "."+orig only
reached the heap once orig passed 31 bytes. Below that the temporary was free
and this saves a few ns per record. Above it, 48 B was allocated per record.
Kubernetes service names are past the threshold -
my-service.my-namespace.svc.cluster.local. is 42 bytes - and those are the names
an auto rule rewrites to when a Corefile maps an external name onto an
in-cluster one. orig is the name the question was rewritten to, so whether a
deployment sees the allocation is a property of its Corefile, not its queries.

Caching "."+orig on the rewriter instead does not work: responseRuleFor
constructs a new rewriter for every request an auto name rule rewrites, so the
concatenation would run once per request rather than once per rule, and escapes
to the heap from there. That buys per-record work with a per-request allocation
and regresses every response short enough not to amortize it.

Per record, one rewriteString call on an existing rewriter:

    name                                master          this PR
    RemapStringRewriter/short/match     186.6n 16 B/1   120.4n 16 B/1   -35%
    RemapStringRewriter/short/nomatch    61.5n  0 B/0    16.5n  0 B/0   -73%
    RemapStringRewriter/long/match      381.9n 72 B/2   165.3n 24 B/1   -57%
    RemapStringRewriter/long/nomatch    219.1n 48 B/1    18.7n  0 B/0   -91%

Per request - rewrite the question, build the response rules, apply them to the
answer:

    name                                  master           this PR
    AutoNameRuleResponse/exact             935n   96 B/4    945n   96 B/4    ~
    AutoNameRuleResponse/subdomain        1.248µ 112 B/5   1.242µ 112 B/5    ~
    AutoNameRuleResponse/nomatch          1.016µ  96 B/4    945n   96 B/4   -7%
    AutoNameRuleResponse/subdomain-8      3.376µ 224 B/12  2.891µ 224 B/12 -14%
    AutoNameRuleResponse/k8s/subdomain    1.611µ 176 B/6   1.380µ 128 B/5  -14%
    AutoNameRuleResponse/k8s/subdomain-8  5.144µ 672 B/20  3.305µ 288 B/12 -36%

benchstat over 8 runs, i7-1065G7. With short names this is flat at the request
level: one rewriteString call is small next to the four allocations that
building the rules costs. The saving is per record and per byte of name, so it
shows up where responses carry several records and the rewritten-to name is
long.

This applies to exact, prefix, substring and regex name rules with answer auto.
suffix rules build a suffixStringRewriter instead and are not affected.

TestRemapStringRewriter pins the label boundary semantics the index arithmetic
now carries, notably that notexample.com. is not a sub domain of example.com.
It passes against the previous implementation too.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2026-08-19 20:27:19 -07:00
Andri Yngvason
a1154dcee5 Templates with expr-lang (#8450)
* plugin/template: Add expr-lang variables

Signed-off-by: Andri Yngvason <andri@yngvason.is>

* plugin/template: Add extra expressions that must match

Signed-off-by: Andri Yngvason <andri@yngvason.is>

* plugin/template: README: Add embedded device resolution example

Signed-off-by: Andri Yngvason <andri@yngvason.is>

---------

Signed-off-by: Andri Yngvason <andri@yngvason.is>
2026-08-19 20:27:03 -07:00
Sueun Cho
9a623cdeed plugin/rewrite: apply rcode rewrites to responses with no records (#8421)
* plugin/rewrite: apply rcode rewrites to record-less responses

An rcode rewrite rewrites the message-level RCODE, but the reverter only ran
response rules from inside the per-record loops in WriteMsg. When a response
carries no answer, authority or additional records - for example a bare
SERVFAIL that a downstream plugin returns to a non-EDNS client - none of the
loops iterate, so the rcode rewrite was silently skipped and the client
received the original RCODE.

Apply message-level response rules once when the response has no records, using
a small marker interface that mirrors the existing requestExtraRevertRule
pattern. This fixes the plugin's documented SERVFAIL-to-NOERROR use case for
responses without records.

Signed-off-by: Sueun Cho <sueun.dev@gmail.com>

* plugin/rewrite: apply fallback rcode rewrites for continue

Signed-off-by: Sueun Cho <sueun.dev@gmail.com>

---------

Signed-off-by: Sueun Cho <sueun.dev@gmail.com>
2026-08-18 11:12:32 +08:00
Pujitha Paladugu
897b4ce643 plugin/azure: don't hold zMu across zone Lookup (#8447) 2026-08-17 05:11:16 -07:00
Sueun Cho
29ef323f82 plugin/cache: preserve AD when storing cache entries (#8438) 2026-08-14 20:28:20 -07:00
Nitin Nizhawan
87ccb6f90e plugin/cache: add prefer_positive stale policy (#8378)
* plugin/cache: add prefer_positive stale policy

Add an opt-in serve_stale_policy that prefers an eligible success-cache
answer over denial-cache entries while serve_stale is enabled. Preserve the
existing ncache-first behavior when the policy is absent.

Also classify SOA-backed CNAME NODATA responses in the cache so incomplete
answers cannot be selected as positive stale responses.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25da81ab-92dd-4663-b480-efd6262090c6
Signed-off-by: Nitin Nizhawan <nnizhawan@microsoft.com>

* plugin/cache: retain last-known-good positive answers

Keep an answering success-cache item reachable when a later NOERROR or
referral response overwrites the visible cache key without answering the
question. This lets prefer_positive survive empty responses, referrals, and
additional-only data while leaving policy-off lookup behavior unchanged.

Return the exact accepted verify refresh item instead of re-reading an
ambiguous cache key, avoiding expired TTL wraparound for uncacheable replies.
Add regression coverage for non-answer refreshes, NODATA, SERVFAIL, NOTIMP,
stale-window expiry, and bounded verify reply shaping.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25da81ab-92dd-4663-b480-efd6262090c6
Signed-off-by: Nitin Nizhawan <nnizhawan@microsoft.com>

* plugin/cache: validate preferred stale answers

Reject truncated, DNSSEC-expired, mismatched-class, unrelated ANY, and ambiguous CNAME refreshes before replacing a stale last-known-good answer. Precompute answer eligibility when cache items are created so prefer_positive hits avoid repeated CNAME walks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 25da81ab-92dd-4663-b480-efd6262090c6
Signed-off-by: Nitin Nizhawan <nnizhawan@microsoft.com>

---------

Signed-off-by: Nitin Nizhawan <nnizhawan@microsoft.com>
Co-authored-by: Nitin Nizhawan <nnizhawan@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25da81ab-92dd-4663-b480-efd6262090c6
2026-08-14 01:18:39 -07:00
houyuwushang
9520d725d6 plugin/cache: configure stale TTL and failure recheck (#8411)
* plugin/cache: configure stale response TTL

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

* plugin/cache: delay stale refresh retries

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

* plugin/cache: validate stale refresh responses

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

---------

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-08-13 23:27:42 -07:00
Manuel Rüger
bc74540f54 plugin/kubernetes: copy Labels in Pod.DeepCopyObject (#8415)
* plugin/kubernetes: copy Labels in Pod.DeepCopyObject

Pod.DeepCopyObject built the copy field by field and left Labels out, so
every copy came back unlabelled. Every other object in this package copies
all of its fields; Pod was the only one missing any.

Labels feeds the kubernetes/client-label/<key> metadata, so anything that
reached a pod through a deep copy would see no labels at all rather than an
error. Nothing does today - DefaultProcessor stores the converted object
straight into the indexer without copying it, which is why this has not
surfaced - so this is a latent bug rather than a live one.

Clone the map instead of assigning it, so the copy does not alias the
original. maps.Clone returns nil for a nil map, so an unlabelled pod stays
unlabelled and a round trip does not turn a nil map into an empty one.

The test covers every runtime.Object in the package rather than just Pod,
and refuses to pass if a fixture leaves a field at its zero value. Adding a
field to any of these types therefore fails the test until the fixture sets
it, which is what makes the round-trip assertion cover the new field too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* plugin/kubernetes/object: deep copy the Service and ServiceImport ports

The deepcopy tests claimed a package-wide guarantee that a copy shares nothing
with its original, but only checked it for Pod and a hand-written Endpoints
value. Both api.ServicePort and mcs.ServicePort hold an AppProtocol *string, so
the elementwise copy(s1.Ports, s.Ports) in Service.DeepCopyObject and
ServiceImport.DeepCopyObject left the copy pointing at the original's string.
Mutating it through either side was visible from the other, and the tests still
passed.

Copy the ports with the generated DeepCopyInto so the copy owns everything it
can reach, and make the guarantee real: TestDeepCopyObjectIsDeep now runs over
every case in deepCopyCases, mutates every value reachable through a pointer,
slice, or map, and requires the copy to still equal a pristine fixture. A type
that gains a reference-bearing field is covered as soon as assertAllFieldsSet
forces the fixture to populate it, rather than needing a new hand-written case.

Failure messages render as JSON, because %+v prints an aliased pointer field as
an address and hides the value that actually differs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Manuel Rüger <manuel@rueg.eu>

---------

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 23:24:43 -07:00
houyuwushang
ea2eea57a7 plugin/file: stop self-referential DNAME loops (#8418) 2026-08-10 13:26:01 -07:00
rpb-ant
c2ca1b2c23 plugin/kubernetes: Add support for topology-aware headless services via "az-pinned" subdomains (#8388) 2026-08-10 13:24:50 -07:00
Michael Wolf
c7e5424e7c Support IPv6 service endpoints in trace plugin (#8410)
Use net.JoinHostPort rather than string concatenation to support
both ipv4, ipv6, and hostname service endpoints for the trace
plugin. Previously, ipv6 bind addresses in the coredns configuration
would fail to be parsed, as the ipv6 address was not surrounded in
brackets.

Signed-off-by: Michael Wolf <mwolf@cloudflare.com>

Closes #8409

Co-authored-by: Michael Wolf <mwolf@cloudflare.com>
2026-08-05 21:10:34 -07:00
Manuel Rüger
19cd5fe0c3 plugin/hosts: pre-convert Origins to plugin.Zones in setup (#8383)
* test: add benchmark cases for Request IP/Port and parseRequest

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* test(kubernetes): add BenchmarkServices and BenchmarkServicesHeadless

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* perf(hosts): pre-convert Origins to plugin.Zones in hosts setup

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* style: fix gofmt trailing line formatting

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

---------

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2026-08-03 18:50:45 -07:00
Saleh
097ef7ef91 plugin/file: run additional processing for CNAME/DNAME answers (#8337)
externalLookup, which resolves the chase for ordinary CNAME, wildcard
CNAME, and DNAME answers, returned a nil additional section. So a chased
SRV/MX/SVCB/HTTPS answer with an in-bailiwick target was missing the
target's A/AAAA glue, unlike the direct path.

Run additionalProcessing at externalLookup's return points so all three
callers add the glue, and add ordinary-CNAME, wildcard-CNAME, and DNAME
regression cases.

Fixes #6628

Signed-off-by: Saleh <root@lr0.org>
2026-08-03 18:49:50 -07:00
houyuwushang
0fa6c66797 plugin/forward: cap default connect attempts (#8365)
Default to two connect attempts per configured upstream so fast failures cannot spin until the request deadline. Track whether max_connect_attempts was explicitly configured so zero still opts into the legacy unbounded behavior.

Fixes #7723

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
2026-08-03 18:49:29 -07:00
Yash Singh
dc1e3a96ad kubernetes: add tests for endpoint/service-import equivalence checks (#8368)
Signed-off-by: yashsingh74 <yashsingh1774@gmail.com>
2026-08-03 18:49:05 -07:00
Karan V
aeaadc0f8c plugin/kubernetes: skip zone serial bump on DNS neutral pod updates (#8338)
* plugin/kubernetes: skip zone serial bump on DNS neutral pod updates

In pods verified mode every pod update event bumped the zone modified
timestamp, even when the pod IP did not change. Pod records only depend
on the pod IP, so routine status churn (conditions, container statuses,
labels) caused spurious SOA serial changes and needless zone transfer
activity, even though pod records are not part of transfers at all.

Only bump the modified timestamp when the pod IP changes, mirroring how
service and endpoint updates are already filtered. Also update the pods
verified documentation to describe the actual overhead: modest memory
for a stripped down pod object, plus watch load on the API server.

Ref #8043

Signed-off-by: Karan V <karanvknarayanan@gmail.com>

* plugin/kubernetes: keep pods verified cost description neutral

Avoid characterizing the memory overhead as modest until benchmark
data quantifies it. State only what the code does: the watch requires
additional memory in CoreDNS and adds load to the API server.

Signed-off-by: Karan V <karanvknarayanan@gmail.com>

---------

Signed-off-by: Karan V <karanvknarayanan@gmail.com>
2026-08-03 18:46:10 -07:00