From patchwork Tue Oct 1 15:40:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 11169145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B685614DB for ; Tue, 1 Oct 2019 15:52:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93F072168B for ; Tue, 1 Oct 2019 15:52:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93F072168B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:43772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFKSN-00072s-NP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Oct 2019 11:52:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48113) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFKGt-0002nk-Ku for qemu-devel@nongnu.org; Tue, 01 Oct 2019 11:41:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFKGs-0006xy-4G for qemu-devel@nongnu.org; Tue, 01 Oct 2019 11:41:03 -0400 Received: from hera.aquilenet.fr ([185.233.100.1]:48092) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iFKGr-0006xD-UJ for qemu-devel@nongnu.org; Tue, 01 Oct 2019 11:41:02 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id D2F67C0EEF; Tue, 1 Oct 2019 17:41:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XQ75-pMmCk9r; Tue, 1 Oct 2019 17:41:00 +0200 (CEST) Received: from function (unknown [109.190.253.14]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 02496C0EEE; Tue, 1 Oct 2019 17:41:00 +0200 (CEST) Received: from samy by function with local (Exim 4.92.2) (envelope-from ) id 1iFKGo-00076F-T7; Tue, 01 Oct 2019 17:40:58 +0200 From: Samuel Thibault To: qemu-devel@nongnu.org, jasowang@redhat.com, marcandre.lureau@gmail.com, philmd@redhat.com Subject: [PATCHv2] slirp: Allow non-local DNS address when restrict is off Date: Tue, 1 Oct 2019 17:40:57 +0200 Message-Id: <20191001154057.27250-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 185.233.100.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This can be used to set a DNS server to be used by the guest which is different from the one configured on the host. Buglink: https://bugs.launchpad.net/qemu/+bug/1010484 Signed-off-by: Samuel Thibault Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- Difference from first version: - handle DNS IPv6 as well - reference bug with Buglink net/slirp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index f42f496641..c4334ee876 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -456,7 +456,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, error_setg(errp, "Failed to parse DNS"); return -1; } - if ((dns.s_addr & mask.s_addr) != net.s_addr) { + if (restricted && (dns.s_addr & mask.s_addr) != net.s_addr) { error_setg(errp, "DNS doesn't belong to network"); return -1; } @@ -522,7 +522,7 @@ static int net_slirp_init(NetClientState *peer, const char *model, error_setg(errp, "Failed to parse IPv6 DNS"); return -1; } - if (!in6_equal_net(&ip6_prefix, &ip6_dns, vprefix6_len)) { + if (restricted && !in6_equal_net(&ip6_prefix, &ip6_dns, vprefix6_len)) { error_setg(errp, "IPv6 DNS doesn't belong to network"); return -1; }