From nobody Mon Feb 9 16:35:16 2026 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 --- 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