Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
d60ce0c8
Commit
d60ce0c8
authored
Jun 17, 2022
by
Chris O'Haver
Committed by
GitHub
Jun 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retain response AD bit if requestor's AD bit was set (#5191)
Signed-off-by:
Chris O'Haver
<
cohaver@infoblox.com
>
parent
d679f2e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
8 deletions
+14
-8
plugin/cache/cache.go
plugin/cache/cache.go
+5
-2
plugin/cache/cache_test.go
plugin/cache/cache_test.go
+1
-1
plugin/cache/handler.go
plugin/cache/handler.go
+3
-2
plugin/cache/item.go
plugin/cache/item.go
+5
-3
No files found.
plugin/cache/cache.go
View file @
d60ce0c8
...
@@ -109,6 +109,7 @@ type ResponseWriter struct {
...
@@ -109,6 +109,7 @@ type ResponseWriter struct {
server
string
// Server handling the request.
server
string
// Server handling the request.
do
bool
// When true the original request had the DO bit set.
do
bool
// When true the original request had the DO bit set.
ad
bool
// When true the original request had the AD bit set.
prefetch
bool
// When true write nothing back to the client.
prefetch
bool
// When true write nothing back to the client.
remoteAddr
net
.
Addr
remoteAddr
net
.
Addr
}
}
...
@@ -185,8 +186,10 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
...
@@ -185,8 +186,10 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
res
.
Ns
=
filterRRSlice
(
res
.
Ns
,
ttl
,
w
.
do
,
false
)
res
.
Ns
=
filterRRSlice
(
res
.
Ns
,
ttl
,
w
.
do
,
false
)
res
.
Extra
=
filterRRSlice
(
res
.
Extra
,
ttl
,
w
.
do
,
false
)
res
.
Extra
=
filterRRSlice
(
res
.
Extra
,
ttl
,
w
.
do
,
false
)
if
!
w
.
do
{
if
!
w
.
do
&&
!
w
.
ad
{
res
.
AuthenticatedData
=
false
// unset AD bit if client is not OK with DNSSEC
// unset AD bit if requester is not OK with DNSSEC
// But retain AD bit if requester set the AD bit in the request, per RFC6840 5.7-5.8
res
.
AuthenticatedData
=
false
}
}
return
w
.
ResponseWriter
.
WriteMsg
(
res
)
return
w
.
ResponseWriter
.
WriteMsg
(
res
)
...
...
plugin/cache/cache_test.go
View file @
d60ce0c8
...
@@ -217,7 +217,7 @@ func TestCache(t *testing.T) {
...
@@ -217,7 +217,7 @@ func TestCache(t *testing.T) {
}
}
if
ok
{
if
ok
{
resp
:=
i
.
toMsg
(
m
,
time
.
Now
()
.
UTC
(),
state
.
Do
())
resp
:=
i
.
toMsg
(
m
,
time
.
Now
()
.
UTC
(),
state
.
Do
()
,
m
.
AuthenticatedData
)
if
err
:=
test
.
Header
(
tc
.
Case
,
resp
);
err
!=
nil
{
if
err
:=
test
.
Header
(
tc
.
Case
,
resp
);
err
!=
nil
{
t
.
Logf
(
"Cache %v"
,
resp
)
t
.
Logf
(
"Cache %v"
,
resp
)
...
...
plugin/cache/handler.go
View file @
d60ce0c8
...
@@ -17,6 +17,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
...
@@ -17,6 +17,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
rc
:=
r
.
Copy
()
// We potentially modify r, to prevent other plugins from seeing this (r is a pointer), copy r into rc.
rc
:=
r
.
Copy
()
// We potentially modify r, to prevent other plugins from seeing this (r is a pointer), copy r into rc.
state
:=
request
.
Request
{
W
:
w
,
Req
:
rc
}
state
:=
request
.
Request
{
W
:
w
,
Req
:
rc
}
do
:=
state
.
Do
()
do
:=
state
.
Do
()
ad
:=
r
.
AuthenticatedData
zone
:=
plugin
.
Zones
(
c
.
Zones
)
.
Matches
(
state
.
Name
())
zone
:=
plugin
.
Zones
(
c
.
Zones
)
.
Matches
(
state
.
Name
())
if
zone
==
""
{
if
zone
==
""
{
...
@@ -36,7 +37,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
...
@@ -36,7 +37,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
ttl
:=
0
ttl
:=
0
i
:=
c
.
getIgnoreTTL
(
now
,
state
,
server
)
i
:=
c
.
getIgnoreTTL
(
now
,
state
,
server
)
if
i
==
nil
{
if
i
==
nil
{
crr
:=
&
ResponseWriter
{
ResponseWriter
:
w
,
Cache
:
c
,
state
:
state
,
server
:
server
,
do
:
do
}
crr
:=
&
ResponseWriter
{
ResponseWriter
:
w
,
Cache
:
c
,
state
:
state
,
server
:
server
,
do
:
do
,
ad
:
ad
}
return
c
.
doRefresh
(
ctx
,
state
,
crr
)
return
c
.
doRefresh
(
ctx
,
state
,
crr
)
}
}
ttl
=
i
.
ttl
(
now
)
ttl
=
i
.
ttl
(
now
)
...
@@ -62,7 +63,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
...
@@ -62,7 +63,7 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
cw
:=
newPrefetchResponseWriter
(
server
,
state
,
c
)
cw
:=
newPrefetchResponseWriter
(
server
,
state
,
c
)
go
c
.
doPrefetch
(
ctx
,
state
,
cw
,
i
,
now
)
go
c
.
doPrefetch
(
ctx
,
state
,
cw
,
i
,
now
)
}
}
resp
:=
i
.
toMsg
(
r
,
now
,
do
)
resp
:=
i
.
toMsg
(
r
,
now
,
do
,
ad
)
w
.
WriteMsg
(
resp
)
w
.
WriteMsg
(
resp
)
return
dns
.
RcodeSuccess
,
nil
return
dns
.
RcodeSuccess
,
nil
...
...
plugin/cache/item.go
View file @
d60ce0c8
...
@@ -64,7 +64,7 @@ func newItem(m *dns.Msg, now time.Time, d time.Duration) *item {
...
@@ -64,7 +64,7 @@ func newItem(m *dns.Msg, now time.Time, d time.Duration) *item {
// So we're forced to always set this to 1; regardless if the answer came from the cache or not.
// So we're forced to always set this to 1; regardless if the answer came from the cache or not.
// On newer systems(e.g. ubuntu 16.04 with glib version 2.23), this issue is resolved.
// On newer systems(e.g. ubuntu 16.04 with glib version 2.23), this issue is resolved.
// So we may set this bit back to 0 in the future ?
// So we may set this bit back to 0 in the future ?
func
(
i
*
item
)
toMsg
(
m
*
dns
.
Msg
,
now
time
.
Time
,
do
bool
)
*
dns
.
Msg
{
func
(
i
*
item
)
toMsg
(
m
*
dns
.
Msg
,
now
time
.
Time
,
do
bool
,
ad
bool
)
*
dns
.
Msg
{
m1
:=
new
(
dns
.
Msg
)
m1
:=
new
(
dns
.
Msg
)
m1
.
SetReply
(
m
)
m1
.
SetReply
(
m
)
...
@@ -73,8 +73,10 @@ func (i *item) toMsg(m *dns.Msg, now time.Time, do bool) *dns.Msg {
...
@@ -73,8 +73,10 @@ func (i *item) toMsg(m *dns.Msg, now time.Time, do bool) *dns.Msg {
// just set it to true.
// just set it to true.
m1
.
Authoritative
=
true
m1
.
Authoritative
=
true
m1
.
AuthenticatedData
=
i
.
AuthenticatedData
m1
.
AuthenticatedData
=
i
.
AuthenticatedData
if
!
do
{
if
!
do
&&
!
ad
{
m1
.
AuthenticatedData
=
false
// when DNSSEC was not wanted, it can't be authenticated data.
// When DNSSEC was not wanted, it can't be authenticated data.
// However, retain the AD bit if the requester set the AD bit, per RFC6840 5.7-5.8
m1
.
AuthenticatedData
=
false
}
}
m1
.
RecursionAvailable
=
i
.
RecursionAvailable
m1
.
RecursionAvailable
=
i
.
RecursionAvailable
m1
.
Rcode
=
i
.
Rcode
m1
.
Rcode
=
i
.
Rcode
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment