From patchwork Thu Jan 5 16:03:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 9499275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 30BFF606B4 for ; Thu, 5 Jan 2017 16:13:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25A6B28413 for ; Thu, 5 Jan 2017 16:13:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A92B28421; Thu, 5 Jan 2017 16:13:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C2F4E28415 for ; Thu, 5 Jan 2017 16:13:02 +0000 (UTC) Received: from localhost ([::1]:47216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPAez-00057m-Oi for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Jan 2017 11:13:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPAVr-00065Q-B1 for qemu-devel@nongnu.org; Thu, 05 Jan 2017 11:03:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPAVn-0000Ig-Ro for qemu-devel@nongnu.org; Thu, 05 Jan 2017 11:03:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33672) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cPAVn-0000IL-N6 for qemu-devel@nongnu.org; Thu, 05 Jan 2017 11:03:31 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4C7B81250 for ; Thu, 5 Jan 2017 16:03:31 +0000 (UTC) Received: from t460.redhat.com (ovpn-117-42.ams2.redhat.com [10.36.117.42]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v05G3SmN009982; Thu, 5 Jan 2017 11:03:30 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 5 Jan 2017 16:03:14 +0000 Message-Id: <20170105160321.21786-2-berrange@redhat.com> In-Reply-To: <20170105160321.21786-1-berrange@redhat.com> References: <20170105160321.21786-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Jan 2017 16:03:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/8] sockets: add ability to disable DNS resolution for InetSocketAddress X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a 'numeric' flag to the InetSocketAddress struct to allow the caller to indicate that DNS should be skipped for the host/port fields. This is useful if the caller knows the address is already numeric and wants to guarantee no (potentially blocking) DNS lookups are attempted. Signed-off-by: Daniel P. Berrange --- qapi-schema.json | 5 +++++ util/qemu-sockets.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/qapi-schema.json b/qapi-schema.json index a0d3b5d..d605c1e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3070,6 +3070,10 @@ # # @port: port part of the address, or lowest port if @to is present # +# @numeric: #optional true if the host/port are guaranteed to be numeric, +# false if name resolution should be attempted. Defaults to false. +# Since 2.8 +# # @to: highest port to try # # @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6 @@ -3084,6 +3088,7 @@ 'data': { 'host': 'str', 'port': 'str', + 'numeric': 'bool', '*to': 'uint16', '*ipv4': 'bool', '*ipv6': 'bool' } } diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index fe1d07a..6f1c10a 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -141,6 +141,9 @@ static int inet_listen_saddr(InetSocketAddress *saddr, memset(&ai,0, sizeof(ai)); ai.ai_flags = AI_PASSIVE; + if (saddr->numeric) { + ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV; + } ai.ai_family = inet_ai_family_from_address(saddr, &err); ai.ai_socktype = SOCK_STREAM;