From patchwork Tue Jun 3 23:36:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 355679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CAF551400AF for ; Wed, 4 Jun 2014 09:59:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=TQCUj53MX/s/ZkYhYK3Bsl8V1G1ae6i AUCV0HUtjr4JfUEZBZkbVT3rE1mJe1krGU4dfsJxTf5edArS1mi23u+5PPfJUNpz 7oyUyoEPnpQ4AxCXvxgBP2xQHrPxPUWWJ+0tlD1jMNCuYijFeS6LQbltsLbhIOV4 S/nXgYA/gCNw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=E0ofA3JKt+bpbEJX8lORC778HMg=; b=GvA8B JXUQ8bfMvmZegG8v+vzpV8hW8fhw7Rwt94OGOfA0zR8oqi2z0CXMcuH2ex3VUCCK +eAG6dvkyGeW+sguEKXiTHVDMXLq4OeRroXK9crU1lznTf4QFtFeT9ebPKUP/sgC eXV6s0Iv3IvBQgkYxaD8XV9wgPAbf6AM3xOJSY= Received: (qmail 23824 invoked by alias); 3 Jun 2014 23:59:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 23813 invoked by uid 89); 3 Jun 2014 23:59:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [RFC PATCH 3/4] resolv: fix issues when using IPv6 nameservers only Date: Wed, 4 Jun 2014 01:36:42 +0200 Message-Id: <1401838603-22101-4-git-send-email-aurelien@aurel32.net> In-Reply-To: <1401838603-22101-1-git-send-email-aurelien@aurel32.net> References: <1401838603-22101-1-git-send-email-aurelien@aurel32.net> statp->nscount contains the number of servers in the statp->nsaddr_list array, which only contains IPv4 nameservers. When resolv.conf only contains IPv6 nameservers, statp->nscount equals to 0, which causes the existing code to add a 127.0.0.1 entry. Change that by checking nservall, contains the number of IPv4 + IPv6 servers instead. The same way __libc_res_nsend exits almost immediately when statp->nscount considering that no nameservers are available, while IPv6 nameservers are actually available. Change that by checking (statp->nscount + EXT(statp).nscount6) instead. --- resolv/res_init.c | 2 +- resolv/res_send.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resolv/res_init.c b/resolv/res_init.c index 37004ab..95564af 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -427,7 +427,7 @@ __res_vinit(res_state statp, int preinit) { #endif (void) fclose(fp); } - if (__builtin_expect(statp->nscount == 0, 0)) { + if (__builtin_expect(nservall == 0, 0)) { statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); statp->nsaddr.sin_family = AF_INET; statp->nsaddr.sin_port = htons(NAMESERVER_PORT); diff --git a/resolv/res_send.c b/resolv/res_send.c index af42b8a..08fc037 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -347,7 +347,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, { int gotsomewhere, terrno, try, v_circuit, resplen, ns, n; - if (statp->nscount == 0) { + if ((statp->nscount + EXT(statp).nscount6) == 0) { __set_errno (ESRCH); return (-1); }