From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3901 invoked from network); 24 Feb 2023 22:08:02 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 24 Feb 2023 22:08:02 -0000 Received: (qmail 7801 invoked by uid 550); 24 Feb 2023 22:07:58 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7765 invoked from network); 24 Feb 2023 22:07:57 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru ACA4444C1024 From: Alexey Izbyshev To: musl@lists.openwall.com Date: Sat, 25 Feb 2023 01:07:33 +0300 Message-Id: <20230224220733.235207-1-izbyshev@ispras.ru> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Mail-Followup-To: musl@lists.openwall.com Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH] dns: fix workaround for systems defaulting to ipv6-only sockets When IPv6 nameservers are present, __res_msend_rc attempts to disable IPV6_V6ONLY socket option to ensure that it can communicate with IPv4 nameservers (if they are present too) via IPv4-mapped IPv6 addresses. However, this option can't be disabled on bound sockets, so setsockopt always fails. --- Given that this workaround never worked and nobody complained, another alternative is to remove it altogether. Alexey --- src/network/res_msend.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/network/res_msend.c b/src/network/res_msend.c index 2643be22..86c2fcf4 100644 --- a/src/network/res_msend.c +++ b/src/network/res_msend.c @@ -133,6 +133,22 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, family = AF_INET; sl = sizeof sa.sin; } + + /* Convert any IPv4 addresses in a mixed environment to v4-mapped */ + if (fd >= 0 && family == AF_INET6) { + setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0); + for (i=0; i= 0) close(fd); @@ -152,21 +168,6 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, pthread_cleanup_push(cleanup, pfd); pthread_setcancelstate(cs, 0); - /* Convert any IPv4 addresses in a mixed environment to v4-mapped */ - if (family == AF_INET6) { - setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0); - for (i=0; i