aboutsummaryrefslogtreecommitdiff
path: root/request
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-12-10 19:43:46 +0000
committerGravatar GitHub <noreply@github.com> 2018-12-10 19:43:46 +0000
commitfed307bfce18f01dba969a328eddcce339f660a5 (patch)
tree0729b3eb510f59ad82fab0dc95017a5243ed9ab2 /request
parent9abbf4a4a07a38af806791882566149418398d39 (diff)
downloadcoredns-fed307bfce18f01dba969a328eddcce339f660a5.tar.gz
coredns-fed307bfce18f01dba969a328eddcce339f660a5.tar.zst
coredns-fed307bfce18f01dba969a328eddcce339f660a5.zip
core: edns0 tweaks (#2385)
* core: edns0 tweaks Per comment thread in https://github.com/coredns/coredns/pull/2357 which spotted a bug; updated the code and added some comments. This function should probably be redone as some point or made obsolete. Signed-off-by: Miek Gieben <miek@miek.nl> * Remove setting options when m is EDNS0 record Assume upstream set them correctly or a plugin. Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'request')
-rw-r--r--request/request.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/request/request.go b/request/request.go
index 52bf8629b..6134fc99d 100644
--- a/request/request.go
+++ b/request/request.go
@@ -192,15 +192,13 @@ func (r *Request) Size() int {
}
// SizeAndDo adds an OPT record that the reflects the intent from request.
-// The returned bool indicated if an record was found and normalised.
+// The returned bool indicates if an record was found and normalised.
func (r *Request) SizeAndDo(m *dns.Msg) bool {
o := r.Req.IsEdns0()
if o == nil {
return false
}
- odo := o.Do()
-
if mo := m.IsEdns0(); mo != nil {
mo.Hdr.Name = "."
mo.Hdr.Rrtype = dns.TypeOPT
@@ -208,16 +206,15 @@ func (r *Request) SizeAndDo(m *dns.Msg) bool {
mo.SetUDPSize(o.UDPSize())
mo.Hdr.Ttl &= 0xff00 // clear flags
- if len(o.Option) > 0 {
- o.Option = supportedOptions(o.Option)
- }
+ // Assume if the message m has options set, they are OK and represent what an upstream can do.
- if odo {
+ if o.Do() {
mo.SetDo()
}
return true
}
+ // Reuse the request's OPT record and tack it to m.
o.Hdr.Name = "."
o.Hdr.Rrtype = dns.TypeOPT
o.SetVersion(0)
@@ -227,9 +224,6 @@ func (r *Request) SizeAndDo(m *dns.Msg) bool {
o.Option = supportedOptions(o.Option)
}
- if odo {
- o.SetDo()
- }
m.Extra = append(m.Extra, o)
return true
}