From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 9 09:17:38 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6F5E1EF2 for ; Mon, 9 Jun 2014 09:17:38 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 512D52F8E for ; Mon, 9 Jun 2014 09:17:38 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.8/8.14.8) with ESMTP id s599HcbZ056335 for ; Mon, 9 Jun 2014 10:17:38 +0100 (BST) (envelope-from bz-noreply@freebsd.org) From: bz-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 190824] New: [patch] [libc] getaddrinfo: addrconfig doesn't ignore loopback addresses Date: Mon, 09 Jun 2014 09:17:38 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: justin.mcomie@gmail.com X-Bugzilla-Status: Needs Triage X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2014 09:17:38 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190824 Bug ID: 190824 Summary: [patch] [libc] getaddrinfo: addrconfig doesn't ignore loopback addresses Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: Needs Triage Severity: Affects Many People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: justin.mcomie@gmail.com The AI_ADDRCONFIG option of getaddrinfo is intended to reduce latency by excluding queries for address families not configured on the system. However loopback addresses are currently treated as "configured" addresses, effectively breaking this functionality. This patch addresses this by retooling addrconfig() to exclude addresses on loopback interfaces when looking for configured addresses. The code is based on getifaddrs.c. - This patch does not address link-local addresses with respect to AI_ADDRCONFIG. - This patch does not affect the ability to resolve numeric hosts such as '127.0.0.1', '::1', and 'ffff::%eth0', since getaddrinfo bypasses the call to addrconfig when such an address is requested. Testing: - Host info: $ ifconfig em0: flags=8843 metric 0 mtu 1500 options=9b ether 00:0c:29:0d:a3:78 inet 172.16.69.133 netmask 0xffffff00 broadcast 172.16.69.255 nd6 options=29 media: Ethernet autoselect (1000baseT ) status: active lo0: flags=8049 metric 0 mtu 16384 options=600003 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 inet 127.0.0.1 netmask 0xff000000 nd6 options=21 - Using a test program like http://www.logix.cz/michal/devel/various/getaddrinfo.c.xp and filtering to just show the address families: - With AI_ADDRCONFIG NOT set: $ ./gai google.com | egrep -o IPv. | uniq IPv4 IPv6 $ ./gai 127.0.0.1 | egrep -o IPv. | uniq IPv4 $ ./gai fe80::1%lo0 | egrep -o IPv. | uniq IPv6 - With AI_ADDRCONFIG set: $ ./gai google.com | egrep -o IPv. | uniq IPv4 $ ./gai 127.0.0.1 | egrep -o IPv. | uniq IPv4 $ ./gai fe80::1%lo0 | egrep -o IPv. | uniq IPv6 -- You are receiving this mail because: You are the assignee for the bug.