From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 47C0C17DCC8F for ; Sun, 30 Nov 2014 15:59:28 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 7BD8AB5D863 for ; Sun, 30 Nov 2014 15:50:34 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 537BE97A83A for ; Sun, 30 Nov 2014 15:50:36 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1ltPord8dj-u for ; Sun, 30 Nov 2014 15:50:36 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E10EE97A827 for ; Sun, 30 Nov 2014 15:50:35 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 6C852952408 for ; Sun, 30 Nov 2014 15:50:33 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A6DEA120420; Sun, 30 Nov 2014 15:50:28 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 7E42112040F for ; Sun, 30 Nov 2014 15:50:24 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=LB1x1nKxtc8YpKatO5e2Pofx3YM=; b=BkoqPYEr9UJPqbLdPL keEWk3r9lFnEsSVbgAcWYqzwXpmPMfA8R8bbdDZHBI34FQO/pP9CSnwyfdXJlgLZ 9D2jmgxHXwB7IBU6R1tOvDZlELzfcH/uywlcSjOhLJMLZCpZRnFkbT6biXIK2HAi cJNUHqHJMrRmThOpHF+aJE3OM= Received: by filter0080p1mdw1.sendgrid.net with SMTP id filter0080p1mdw1.7673.547ABE2021 2014-11-30 06:50:09.213749862 +0000 UTC Received: from herokuapp.com (ec2-54-161-4-130.compute-1.amazonaws.com [54.161.4.130]) by ismtpd-025 (SG) with ESMTP id 149ff76b176.75c5.14f8de for ; Sun, 30 Nov 2014 06:50:09 +0000 (UTC) Date: Sun, 30 Nov 2014 06:50:08 +0000 From: aaron@serendipity.cx To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 40983 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 9925 X-Redmine-Issue-Author: aaron@serendipity.cx X-Redmine-Sender: aaron@serendipity.cx X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: OOF Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7W6PNVmbx2QkB0k0f97vQNfLgh2PN7IlnrsJ fXFXhiKUWctDKTru7rmy4A4QAcJLvwUfROF15kR2fI4/Lk9qkFzZbm4Ufwp0vXOzY+ZAqwicCO1Xz/ hyfUERU7RPjJo8uhv1qzGX92hNJmbsW0fwGY X-SendGrid-Contentd-ID: {"test_id":"1417330211"} X-ML-Name: ruby-core X-Mail-Count: 66584 Subject: [ruby-core:66584] [ruby-trunk - Feature #9925] rsock_addrinfo uses DNS family AF_UNSPEC for lookup causing high IPv6 AAAA volume X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #9925 has been updated by Aaron Stone. Ping. I was hoping someone from the Ruby core would provide feedback and direction regarding my suggestions: > There is also a compile-time Ruby flag for LOOKUP_ORDER_HACK_INET and LOOKUP_ORDER_HACK_INET6. Perhaps those could become an environment variable instead of compile-time flags? and > Another approach could be a module variable in Socket that I could toggle globally or per-instance. Something like this: > > Socket::DEFAULT_DNS_LOOKUP = :UNSPEC > > I could either globally set Socket::DEFAULT_DNS_LOOKUP = :INET or on a per-instance basis, e.g. > > my_socket = TCPSocket.new() > my_socket.dns_lookup = :INET ---------------------------------------- Feature #9925: rsock_addrinfo uses DNS family AF_UNSPEC for lookup causing high IPv6 AAAA volume https://bugs.ruby-lang.org/issues/9925#change-50199 * Author: Aaron Stone * Status: Open * Priority: Normal * Assignee: * Category: * Target version: ---------------------------------------- In ext/socket/raddrinfo.c, the function `rsock_addrinfo()` always uses `AF_UNSPEC` for DNS queries. This is causing me a very high volume of IPv6 DNS lookups. `rsock_addrinfo()` is used by TCPSocket (and all other Socket base classes, e.g. Socket and UDPSocket), and TCPSocket is used by Net::HTTP. Remember that DNS does not do negative caching - if a hostname does not have a AAAA record, then DNS will _always_ try to look up that record again! I propose that the following code should have some way to force IPv4 or IPv6 lookups: http://rxr.whitequark.org/mri/source/ext/socket/raddrinfo.c ~~~c 378 struct addrinfo* 379 rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags) 380 { 381 struct addrinfo hints; 382 383 MEMZERO(&hints, struct addrinfo, 1); 384 hints.ai_family = AF_UNSPEC; 385 hints.ai_socktype = socktype; 386 hints.ai_flags = flags; 387 return rsock_getaddrinfo(host, port, &hints, 1); 388 } ~~~ For example, an environment variable named something like `RUBY_GAI` could be set to "INET" or "INET6" to switch the `hints.ai_family` away from `AF_UNSPEC`. -- https://bugs.ruby-lang.org/