diff options
author | 2016-10-02 17:23:25 +0100 | |
---|---|---|
committer | 2016-10-02 17:23:25 +0100 | |
commit | 560f11d1484c7fe0a729832ba3f6c3ef4f6f58e0 (patch) | |
tree | 784bdb95d8ee986783ae0b4e24488b91431ae02d /request | |
parent | 4096c4906d5835292b9968d5261b91a1db9d89b6 (diff) | |
download | coredns-560f11d1484c7fe0a729832ba3f6c3ef4f6f58e0.tar.gz coredns-560f11d1484c7fe0a729832ba3f6c3ef4f6f58e0.tar.zst coredns-560f11d1484c7fe0a729832ba3f6c3ef4f6f58e0.zip |
EDNS0 unknown flags handling (#313)
Fix the unknown flags handling when receiving such message. We should
zero out all of the Z bits in the OPT record before returning.
Current behavior:
dig +norec +noad +ednsflags=0x80 soa miek.nl @deb.atoom.net
...
; EDNS: version: 0, flags:; MBZ: 0080 , udp: 4096
New:
dig +norec +noad +ednsflags=0x80 soa miek.nl @localhost -p 2053
...
; EDNS: version: 0, flags:; udp: 4096
Take care no to overwrite the Do bit.
We still accept *all* EDNS option; I do not consider that a bug in
itself.
Fixes #306
Diffstat (limited to 'request')
-rw-r--r-- | request/request.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/request/request.go b/request/request.go index 999acc256..50b990897 100644 --- a/request/request.go +++ b/request/request.go @@ -19,9 +19,9 @@ type Request struct { // Cache size after first call to Size or Do. size int do int // 0: not, 1: true: 2: false - // TODO(miek): opt record itself as well. + // TODO(miek): opt record itself as well? - // Cache name as (lowercase) well + // Cache lowercase qname. name string } @@ -135,19 +135,31 @@ func (r *Request) SizeAndDo(m *dns.Msg) bool { if o == nil { return false } - o.Hdr.Name = "." - o.Hdr.Rrtype = dns.TypeOPT - o.SetVersion(0) + + odo := o.Do() + if mo := m.IsEdns0(); mo != nil { mo.Hdr.Name = "." mo.Hdr.Rrtype = dns.TypeOPT mo.SetVersion(0) mo.SetUDPSize(o.UDPSize()) - if o.Do() { + mo.Hdr.Ttl &= 0xff00 // clear flags + + if odo { mo.SetDo() } return true } + + o.Hdr.Name = "." + o.Hdr.Rrtype = dns.TypeOPT + o.SetVersion(0) + o.Hdr.Ttl &= 0xff00 // clear flags + + if odo { + o.SetDo() + } + m.Extra = append(m.Extra, o) return true } |