aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-04-12 11:01:15 -0400
committerGravatar GitHub <noreply@github.com> 2022-04-12 11:01:15 -0400
commite60c179194cc1ff85d24fe9b887d901aea74641d (patch)
tree4baf531fdee7372c1cc5c16a1cc0609bda0e8857
parent83021637b35b0ef0ba09640e6f3d902cad8cdfb7 (diff)
downloadcoredns-e60c179194cc1ff85d24fe9b887d901aea74641d.tar.gz
coredns-e60c179194cc1ff85d24fe9b887d901aea74641d.tar.zst
coredns-e60c179194cc1ff85d24fe9b887d901aea74641d.zip
plugin/k8s_external: Set authoritative bit in responses (#5284)
set authoritative bit in responses Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
-rw-r--r--plugin/k8s_external/apex.go2
-rw-r--r--plugin/k8s_external/apex_test.go3
-rw-r--r--plugin/k8s_external/external.go1
-rw-r--r--plugin/k8s_external/external_test.go3
4 files changed, 9 insertions, 0 deletions
diff --git a/plugin/k8s_external/apex.go b/plugin/k8s_external/apex.go
index 0ce00a7c3..935876cf8 100644
--- a/plugin/k8s_external/apex.go
+++ b/plugin/k8s_external/apex.go
@@ -11,6 +11,7 @@ import (
func (e *External) serveApex(state request.Request) (int, error) {
m := new(dns.Msg)
m.SetReply(state.Req)
+ m.Authoritative = true
switch state.QType() {
case dns.TypeSOA:
m.Answer = []dns.RR{e.soa(state)}
@@ -37,6 +38,7 @@ func (e *External) serveSubApex(state request.Request) (int, error) {
m := new(dns.Msg)
m.SetReply(state.Req)
+ m.Authoritative = true
// base is either dns. of ns1.dns (or another name), if it's longer return nxdomain
switch labels := dns.CountLabel(base); labels {
diff --git a/plugin/k8s_external/apex_test.go b/plugin/k8s_external/apex_test.go
index 45b835e3a..57513e3f8 100644
--- a/plugin/k8s_external/apex_test.go
+++ b/plugin/k8s_external/apex_test.go
@@ -41,6 +41,9 @@ func TestApex(t *testing.T) {
if resp == nil {
t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name)
}
+ if !resp.Authoritative {
+ t.Error("Expected authoritative answer")
+ }
if err := test.SortAndCheck(resp, tc); err != nil {
t.Error(err)
}
diff --git a/plugin/k8s_external/external.go b/plugin/k8s_external/external.go
index ee1bdca15..1096c2ea7 100644
--- a/plugin/k8s_external/external.go
+++ b/plugin/k8s_external/external.go
@@ -89,6 +89,7 @@ func (e *External) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
m := new(dns.Msg)
m.SetReply(state.Req)
+ m.Authoritative = true
if len(svc) == 0 {
m.Rcode = rcode
diff --git a/plugin/k8s_external/external_test.go b/plugin/k8s_external/external_test.go
index cf8e0e61c..558c894f6 100644
--- a/plugin/k8s_external/external_test.go
+++ b/plugin/k8s_external/external_test.go
@@ -45,6 +45,9 @@ func TestExternal(t *testing.T) {
if resp == nil {
t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name)
}
+ if !resp.Authoritative {
+ t.Error("Expected authoritative answer")
+ }
if err = test.SortAndCheck(resp, tc); err != nil {
t.Error(err)
}