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
be8b29cd
Commit
be8b29cd
authored
Apr 08, 2019
by
Kun Chang
Committed by
Miek Gieben
Apr 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[plugin/cache] cache failures (#2720)
* cache failures * use ServerError
parent
58c703f5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
8 deletions
+46
-8
plugin/cache/cache.go
plugin/cache/cache.go
+4
-1
plugin/cache/cache_test.go
plugin/cache/cache_test.go
+28
-0
plugin/pkg/response/typify.go
plugin/pkg/response/typify.go
+14
-7
No files found.
plugin/cache/cache.go
View file @
be8b29cd
...
@@ -163,6 +163,9 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
...
@@ -163,6 +163,9 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
var
duration
time
.
Duration
var
duration
time
.
Duration
if
mt
==
response
.
NameError
||
mt
==
response
.
NoData
{
if
mt
==
response
.
NameError
||
mt
==
response
.
NoData
{
duration
=
computeTTL
(
msgTTL
,
w
.
minnttl
,
w
.
nttl
)
duration
=
computeTTL
(
msgTTL
,
w
.
minnttl
,
w
.
nttl
)
}
else
if
mt
==
response
.
ServerError
{
// use default ttl which is 5s
duration
=
minTTL
}
else
{
}
else
{
duration
=
computeTTL
(
msgTTL
,
w
.
minpttl
,
w
.
pttl
)
duration
=
computeTTL
(
msgTTL
,
w
.
minpttl
,
w
.
pttl
)
}
}
...
@@ -206,7 +209,7 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration
...
@@ -206,7 +209,7 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration
i
:=
newItem
(
m
,
w
.
now
(),
duration
)
i
:=
newItem
(
m
,
w
.
now
(),
duration
)
w
.
pcache
.
Add
(
key
,
i
)
w
.
pcache
.
Add
(
key
,
i
)
case
response
.
NameError
,
response
.
NoData
:
case
response
.
NameError
,
response
.
NoData
,
response
.
ServerError
:
i
:=
newItem
(
m
,
w
.
now
(),
duration
)
i
:=
newItem
(
m
,
w
.
now
(),
duration
)
w
.
ncache
.
Add
(
key
,
i
)
w
.
ncache
.
Add
(
key
,
i
)
...
...
plugin/cache/cache_test.go
View file @
be8b29cd
...
@@ -87,6 +87,34 @@ var cacheTestCases = []cacheTestCase{
...
@@ -87,6 +87,34 @@ var cacheTestCases = []cacheTestCase{
},
},
shouldCache
:
true
,
shouldCache
:
true
,
},
},
{
RecursionAvailable
:
true
,
Authoritative
:
false
,
Case
:
test
.
Case
{
Rcode
:
dns
.
RcodeServerFailure
,
Qname
:
"example.org."
,
Qtype
:
dns
.
TypeA
,
Ns
:
[]
dns
.
RR
{},
},
in
:
test
.
Case
{
Rcode
:
dns
.
RcodeServerFailure
,
Qname
:
"example.org."
,
Qtype
:
dns
.
TypeA
,
Ns
:
[]
dns
.
RR
{},
},
shouldCache
:
true
,
},
{
RecursionAvailable
:
true
,
Authoritative
:
false
,
Case
:
test
.
Case
{
Rcode
:
dns
.
RcodeNotImplemented
,
Qname
:
"example.org."
,
Qtype
:
dns
.
TypeA
,
Ns
:
[]
dns
.
RR
{},
},
in
:
test
.
Case
{
Rcode
:
dns
.
RcodeNotImplemented
,
Qname
:
"example.org."
,
Qtype
:
dns
.
TypeA
,
Ns
:
[]
dns
.
RR
{},
},
shouldCache
:
true
,
},
{
{
RecursionAvailable
:
true
,
Authoritative
:
true
,
RecursionAvailable
:
true
,
Authoritative
:
true
,
Case
:
test
.
Case
{
Case
:
test
.
Case
{
...
...
plugin/pkg/response/typify.go
View file @
be8b29cd
...
@@ -15,6 +15,8 @@ const (
...
@@ -15,6 +15,8 @@ const (
NoError
Type
=
iota
NoError
Type
=
iota
// NameError is a NXDOMAIN in header, SOA in auth.
// NameError is a NXDOMAIN in header, SOA in auth.
NameError
NameError
// ServerError is a set of errors we want to cache, for now it containers SERVFAIL and NOTIMPL.
ServerError
// NoData indicates name found, but not the type: NOERROR in header, SOA in auth.
// NoData indicates name found, but not the type: NOERROR in header, SOA in auth.
NoData
NoData
// Delegation is a msg with a pointer to another nameserver: NOERROR in header, NS in auth, optionally fluff in additional (not checked).
// Delegation is a msg with a pointer to another nameserver: NOERROR in header, NS in auth, optionally fluff in additional (not checked).
...
@@ -30,6 +32,7 @@ const (
...
@@ -30,6 +32,7 @@ const (
var
toString
=
map
[
Type
]
string
{
var
toString
=
map
[
Type
]
string
{
NoError
:
"NOERROR"
,
NoError
:
"NOERROR"
,
NameError
:
"NXDOMAIN"
,
NameError
:
"NXDOMAIN"
,
ServerError
:
"SERVERERROR"
,
NoData
:
"NODATA"
,
NoData
:
"NODATA"
,
Delegation
:
"DELEGATION"
,
Delegation
:
"DELEGATION"
,
Meta
:
"META"
,
Meta
:
"META"
,
...
@@ -106,6 +109,10 @@ func Typify(m *dns.Msg, t time.Time) (Type, *dns.OPT) {
...
@@ -106,6 +109,10 @@ func Typify(m *dns.Msg, t time.Time) (Type, *dns.OPT) {
return
NameError
,
opt
return
NameError
,
opt
}
}
if
m
.
Rcode
==
dns
.
RcodeServerFailure
||
m
.
Rcode
==
dns
.
RcodeNotImplemented
{
return
ServerError
,
opt
}
if
ns
>
0
&&
m
.
Rcode
==
dns
.
RcodeSuccess
{
if
ns
>
0
&&
m
.
Rcode
==
dns
.
RcodeSuccess
{
return
Delegation
,
opt
return
Delegation
,
opt
}
}
...
...
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