mirror of
https://github.com/coredns/coredns.git
synced 2026-10-17 07:45:42 -04:00
plugin/pkg/proxy: set IP_RECVERR on upstream UDP sockets (#8628)
Without IP_RECVERR, Linux passes only some ICMP errors, such as port unreachable, to a connected UDP socket. It drops net and host unreachable (net/ipv4/udp.c, __udp4_lib_err), so a query to an upstream behind an unreachable route waits out the read timeout before forward tries the next upstream, and health checks wait out theirs before marking it down. Set IP_RECVERR (IPV6_RECVERR for IPv6) on the UDP sockets for upstream queries and health checks, so the read fails when the ICMP error arrives. TCP sockets are left alone, and nothing changes outside Linux. The health check client gets an explicit 2s dial timeout, since a Dialer replaces dns.Client's default one. Because the Dialer now exists from the start, setDialer no longer creates a bare one when source_address is set, which also lost the dial timeout before. Fixes #8621 Signed-off-by: MohibShaikh <mohibuddin9@gmail.com>
This commit is contained in:
@@ -217,6 +217,10 @@ func TestHealthLocalAddress(t *testing.T) {
|
||||
if dnsClient.Dialer.LocalAddr.String() != "127.0.0.1:0" {
|
||||
t.Errorf("Expected local address to be 127.0.0.1:0, got %s", dnsClient.Dialer.LocalAddr.String())
|
||||
}
|
||||
// A Dialer replaces dns.Client's own dial timeout, so it must carry one.
|
||||
if dnsClient.Dialer.Timeout != 2*time.Second {
|
||||
t.Errorf("Expected dial timeout to be 2s, got %s", dnsClient.Dialer.Timeout)
|
||||
}
|
||||
|
||||
// check type of underlying transport
|
||||
_, ok := dnsClient.Dialer.LocalAddr.(*net.UDPAddr)
|
||||
|
||||
Reference in New Issue
Block a user