mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
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
This commit is contained in:
@@ -19,9 +19,9 @@ type Request struct {
|
|||||||
// Cache size after first call to Size or Do.
|
// Cache size after first call to Size or Do.
|
||||||
size int
|
size int
|
||||||
do int // 0: not, 1: true: 2: false
|
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
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,19 +135,31 @@ func (r *Request) SizeAndDo(m *dns.Msg) bool {
|
|||||||
if o == nil {
|
if o == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
o.Hdr.Name = "."
|
|
||||||
o.Hdr.Rrtype = dns.TypeOPT
|
odo := o.Do()
|
||||||
o.SetVersion(0)
|
|
||||||
if mo := m.IsEdns0(); mo != nil {
|
if mo := m.IsEdns0(); mo != nil {
|
||||||
mo.Hdr.Name = "."
|
mo.Hdr.Name = "."
|
||||||
mo.Hdr.Rrtype = dns.TypeOPT
|
mo.Hdr.Rrtype = dns.TypeOPT
|
||||||
mo.SetVersion(0)
|
mo.SetVersion(0)
|
||||||
mo.SetUDPSize(o.UDPSize())
|
mo.SetUDPSize(o.UDPSize())
|
||||||
if o.Do() {
|
mo.Hdr.Ttl &= 0xff00 // clear flags
|
||||||
|
|
||||||
|
if odo {
|
||||||
mo.SetDo()
|
mo.SetDo()
|
||||||
}
|
}
|
||||||
return true
|
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)
|
m.Extra = append(m.Extra, o)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user