From nobody Sat Apr 27 06:45:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626261119; cv=none; d=zohomail.com; s=zohoarc; b=HVZ7ozS+EvIYudFYO5MEphdRsZC304n2Waolh3ps0WmSzBPtk2L3AoOx37mnbEBJx2RroK2EPc23FzOjMBkcFiC70ujXCZIDmheaSOJuBGqAM+i62ZJaptR0cQYPd8qyEz/bJ73JJufUoc8asViD61iJ6mg3X75i/muYqytobQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626261119; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dipjl4Wz0XCOawt9IUfR+FwmijXXw2hi618rFMxu+R4=; b=cV3dfc3+9fpd9Wa8IuLYaL9I831DSV72vZLinglwOmmCwnsKQW0/Ym0e5cmnl0bw4Wzim7N44y7TX7ajQCSHNAo1ffOAfKkJsuuo3Vm9sQX8pvccNcW7XQ5nhWtAOrE71VOhtvF5MaHyeWyVnF9xQNxiyRe3/aVTEE8bGH/2Pf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1626261119882966.6132449123559; Wed, 14 Jul 2021 04:11:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500-Urf916q7PWy4TL8En_OMLg-1; Wed, 14 Jul 2021 07:11:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCE059F92B; Wed, 14 Jul 2021 11:11:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C7E518A50; Wed, 14 Jul 2021 11:11:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 01B9A1809C97; Wed, 14 Jul 2021 11:11:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16EBBjCb009597 for ; Wed, 14 Jul 2021 07:11:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F30D100F49F; Wed, 14 Jul 2021 11:11:45 +0000 (UTC) Received: from andariel.lan (unknown [10.40.192.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6B11100EB3D for ; Wed, 14 Jul 2021 11:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626261118; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dipjl4Wz0XCOawt9IUfR+FwmijXXw2hi618rFMxu+R4=; b=iZoy5S+0OsxY57uLLtinnCZQtGkmFqSayNtU3f9OopGPJoqH+7Bvw4iBZukIknfzHS3MAx oMvj7JAIbn0sfsmBsxpEhU8ZUxu+AhaYSR/yXnqldFfKzfWrDl+lXepCI7GMb/1/SEvIv/ 6vVMvsEg/MwsNS4AKSr+l/+1V1Re+Tg= X-MC-Unique: Urf916q7PWy4TL8En_OMLg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] networkxml2xmltest: Add example of multiple addresses having the same hostname Date: Wed, 14 Jul 2021 13:11:38 +0200 Message-Id: <4c009a3eb08a6f784f29641b6349517e576775ad.1626261065.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626261122097100003 Content-Type: text/plain; charset="utf-8" Having multiple addresses for the same hostname is a legitimate configuration in DNS. Add test data to cover this case. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/networkxml2xmlin/nat-network-dns-hosts.xml | 8 ++++++++ tests/networkxml2xmlout/nat-network-dns-hosts.xml | 8 ++++++++ .../nat-network-dns-more-hosts.xml | 8 ++++++++ .../networkxml2xmlupdateout/nat-network-no-hosts.xml | 11 ++++++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/networkxml2xmlin/nat-network-dns-hosts.xml b/tests/netwo= rkxml2xmlin/nat-network-dns-hosts.xml index da65267ec5..58608f6959 100644 --- a/tests/networkxml2xmlin/nat-network-dns-hosts.xml +++ b/tests/networkxml2xmlin/nat-network-dns-hosts.xml @@ -8,6 +8,14 @@ host gateway + + shared + names + + + shared + names + diff --git a/tests/networkxml2xmlout/nat-network-dns-hosts.xml b/tests/netw= orkxml2xmlout/nat-network-dns-hosts.xml index 17e269710b..7c561aad2a 100644 --- a/tests/networkxml2xmlout/nat-network-dns-hosts.xml +++ b/tests/networkxml2xmlout/nat-network-dns-hosts.xml @@ -10,6 +10,14 @@ host gateway + + shared + names + + + shared + names + diff --git a/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml b= /tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml index 5464d90ab9..dfc12eb2f9 100644 --- a/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml +++ b/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml @@ -13,6 +13,14 @@ host gateway + + shared + names + + + shared + names + diff --git a/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml b/tests= /networkxml2xmlupdateout/nat-network-no-hosts.xml index ee2d773729..7cff9edc09 100644 --- a/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml +++ b/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml @@ -5,7 +5,16 @@ - + + + shared + names + + + shared + names + + --=20 2.31.1 From nobody Sat Apr 27 06:45:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626261131; cv=none; d=zohomail.com; s=zohoarc; b=c/PsYvZf5/jYUKQcSjg/PQk4I0K6X1+fVJqWtUrEohKIAIcYUvUns/asLAXw3RuHdcD5mTV+oaJYk7HezgG9NLVsn9Et9mwkq/S+g1uG1PPIZHg6PZql1eDCuWEmQEQV0b0rnCYCjX6eLRBSaegIoHc4c4KGiq2rnlvtsOuY3cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626261131; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h8xw+0fO0PT22OCnFo+rnMI+1pFE/0+9WuGj3V21SW8=; b=jdTDXO3ipe2XjoI367IA8BIZF/DDUKJNxy7pnuEukcv3D1KXmGC+bCXxpNfqWE0sztbPu/vYMMzMy1OMfbkoutkz5kysjQByyFH6pB8C96kUl8CW2l0BT3KvTmY6JXLKHUzqqLXqM2c6g9ET/ny0qlGvCOwyfNh4hn6WzdYwoHk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1626261131142233.17774135471643; Wed, 14 Jul 2021 04:12:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-BB1LsZE-M9m7Dky6oSufUQ-1; Wed, 14 Jul 2021 07:12:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31456801B0A; Wed, 14 Jul 2021 11:12:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1167E60938; Wed, 14 Jul 2021 11:12:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 997D31809CB2; Wed, 14 Jul 2021 11:12:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16EBBklB009602 for ; Wed, 14 Jul 2021 07:11:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3801A100F49F; Wed, 14 Jul 2021 11:11:46 +0000 (UTC) Received: from andariel.lan (unknown [10.40.192.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id B05F6100EB3D for ; Wed, 14 Jul 2021 11:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626261130; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=h8xw+0fO0PT22OCnFo+rnMI+1pFE/0+9WuGj3V21SW8=; b=CCqltQZrO4otKMw0K95edcXt/R6jceUxLP7XQnU8z7lDAYQor2U3+nF3N3wujBhn3umeZl t29jIgP/6SBb8XEnKN7ugxQCK8e5icqugLmjFyQstjKzr8lhEwPcUX09xy6F+c8B57YUnU 3zItAI35M7FKGI5BvZhVIrjRhhH3Oy4= X-MC-Unique: BB1LsZE-M9m7Dky6oSufUQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] network: Allow adding DNS entries sharing hostname for multiple addreses Date: Wed, 14 Jul 2021 13:11:39 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626261133164100001 Content-Type: text/plain; charset="utf-8" Having multiple addresses having same hostname is a common config either to have IPv4 and IPv6 address for the same hostname or even for DNS round robin. The validation in the network update code didn't allow adding such entries despite the fact that it is possible to define a network with them. Don't check hostname duplicity when adding a DNS entry. The update of the test case adds another entry for the 'pudding' hostname which is added in one of the networkxml2xmlupdate test cases. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/network_conf.c | 13 +++++++++---- tests/networkxml2xmlin/nat-network-dns-hosts.xml | 3 +++ tests/networkxml2xmlout/nat-network-dns-hosts.xml | 3 +++ .../nat-network-dns-more-hosts.xml | 3 +++ .../nat-network-no-hosts.xml | 3 +++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index b10ff5c7a8..fe9919d4ce 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -3404,12 +3404,17 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def, if (virSocketAddrEqual(&host.ip, &dns->hosts[i].ip)) foundThisTime =3D true; - for (j =3D 0; j < host.nnames && !foundThisTime; j++) { - for (k =3D 0; k < dns->hosts[i].nnames && !foundThisTime; k++)= { - if (STREQ(host.names[j], dns->hosts[i].names[k])) - foundThisTime =3D true; + /* when adding we want to only check duplicates of address since h= aving + * multiple addresses with the same hostname is a legitimate confi= guration */ + if (!isAdd) { + for (j =3D 0; j < host.nnames && !foundThisTime; j++) { + for (k =3D 0; k < dns->hosts[i].nnames && !foundThisTime; = k++) { + if (STREQ(host.names[j], dns->hosts[i].names[k])) + foundThisTime =3D true; + } } } + if (foundThisTime) { foundCt++; foundIdx =3D i; diff --git a/tests/networkxml2xmlin/nat-network-dns-hosts.xml b/tests/netwo= rkxml2xmlin/nat-network-dns-hosts.xml index 58608f6959..c28ebd8c4b 100644 --- a/tests/networkxml2xmlin/nat-network-dns-hosts.xml +++ b/tests/networkxml2xmlin/nat-network-dns-hosts.xml @@ -4,6 +4,9 @@ + + pudding + host gateway diff --git a/tests/networkxml2xmlout/nat-network-dns-hosts.xml b/tests/netw= orkxml2xmlout/nat-network-dns-hosts.xml index 7c561aad2a..86832af518 100644 --- a/tests/networkxml2xmlout/nat-network-dns-hosts.xml +++ b/tests/networkxml2xmlout/nat-network-dns-hosts.xml @@ -6,6 +6,9 @@ + + pudding + host gateway diff --git a/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml b= /tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml index dfc12eb2f9..7b8a451b67 100644 --- a/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml +++ b/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml @@ -9,6 +9,9 @@ pudding + + pudding + host gateway diff --git a/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml b/tests= /networkxml2xmlupdateout/nat-network-no-hosts.xml index 7cff9edc09..679575973c 100644 --- a/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml +++ b/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml @@ -6,6 +6,9 @@ + + pudding + shared names --=20 2.31.1