From: Lennart Poettering Date: Mon, 7 Oct 2024 11:03:51 +0000 (+0200) Subject: resolved: fix fastopen fallback X-Git-Tag: v257-rc1~278^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5699e4c2d470a12c922c4b7c86a8987837911626;p=thirdparty%2Fsystemd.git resolved: fix fastopen fallback We should not invalidate the socket address size before we use it. Fixes: #34579 --- diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index 8c1512006af..c3e825abf43 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -205,6 +205,7 @@ static int dns_stream_identify(DnsStream *s) { ssize_t dns_stream_writev(DnsStream *s, const struct iovec *iov, size_t iovcnt, int flags) { ssize_t m; + int r; assert(s); assert(iov); @@ -224,12 +225,14 @@ ssize_t dns_stream_writev(DnsStream *s, const struct iovec *iov, size_t iovcnt, m = sendmsg(s->fd, &hdr, MSG_FASTOPEN); if (m < 0) { - if (errno == EOPNOTSUPP) { - s->tfo_salen = 0; - if (connect(s->fd, &s->tfo_address.sa, s->tfo_salen) < 0) - return -errno; + if (ERRNO_IS_NOT_SUPPORTED(errno)) { + /* MSG_FASTOPEN not supported? Then try to connect() traditionally */ + r = RET_NERRNO(connect(s->fd, &s->tfo_address.sa, s->tfo_salen)); + s->tfo_salen = 0; /* connection is made */ + if (r < 0 && r != -EINPROGRESS) + return r; - return -EAGAIN; + return -EAGAIN; /* In case of EINPROGRESS, EAGAIN or success: return EAGAIN, so that caller calls us again */ } if (errno == EINPROGRESS) return -EAGAIN;