resolved: don't treat conn reset as packet loss

tcp reset / icmp port-unreachable are markedly different conditions than
packet loss. It doesn't make much sense to retry in this case. It's
actually not clear if there is any benefit at all retrying tcp
connections, which were presumably already retried as necessary by the
tcp stack.
This commit is contained in:
Ronan Pigott
2024-08-01 10:59:12 -07:00
committed by Yu Watanabe
parent b51b12af8d
commit ddd710a355
2 changed files with 7 additions and 1 deletions

View File

@@ -322,6 +322,12 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
return dns_stream_complete(s, -r);
}
if (revents & EPOLLERR) {
socklen_t errlen = sizeof(r);
if (getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &r, &errlen) == 0)
return dns_stream_complete(s, r);
}
if ((revents & EPOLLOUT) &&
s->write_packet &&
s->n_written < sizeof(s->write_size) + s->write_packet->size) {

View File

@@ -633,7 +633,7 @@ static int on_stream_complete(DnsStream *s, int error) {
if (ERRNO_IS_DISCONNECT(error) && s->protocol != DNS_PROTOCOL_LLMNR) {
log_debug_errno(error, "Connection failure for DNS TCP stream: %m");
if (s->transactions) {
if (error != ECONNRESET && s->transactions) {
DnsTransaction *t;
t = s->transactions;