mirror of
https://github.com/coredns/coredns.git
synced 2026-07-26 17:40:11 -04:00
plugin/forward: Fix UDP forwarding so a malformed upstream datagram wont block valid ones later (#8287)
* plugin/plugin: Fix UDP forwarding so a malformed upstream datagram wont block valid ones later This PR fixes UDP forwarding so a malformed upstream datagram does not prevent CoreDNS from accepting a subsequent valid response before the existing read deadline. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Address review and add additonal tests Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Cover branch Signed-off-by: Yong Tang <yong.tang.github@outlook.com> --------- Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -186,6 +186,12 @@ func (p *Proxy) lookupDNS(_ctx context.Context, state request.Request, opts Opti
|
||||
for {
|
||||
ret, err = pc.c.ReadMsg()
|
||||
if err != nil {
|
||||
if p.transport.transportTypeFromConn(pc) == typeUDP &&
|
||||
((ret == nil && errors.Is(err, dns.ErrShortRead)) ||
|
||||
(ret != nil && ret.Id != state.Req.Id)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if ret != nil && (state.Req.Id == ret.Id) && p.transport.transportTypeFromConn(pc) == typeUDP && shouldTruncateResponse(err) {
|
||||
// For UDP, if the error is an overflow, we probably have an upstream misbehaving in some way.
|
||||
// (e.g. sending >512 byte responses without an eDNS0 OPT RR).
|
||||
|
||||
Reference in New Issue
Block a user