From nobody Fri May 3 08:31:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=tremily.us Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1541524103106467.10458225626553; Tue, 6 Nov 2018 09:08:23 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 2D640394D30; Tue, 6 Nov 2018 17:08:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E37F600C0; Tue, 6 Nov 2018 17:08:19 +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 7D7D23FA56; Tue, 6 Nov 2018 17:08:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA6H71PZ028150 for ; Tue, 6 Nov 2018 12:07:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1038760F87; Tue, 6 Nov 2018 17:07:01 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A39560C46 for ; Tue, 6 Nov 2018 17:06:59 +0000 (UTC) Received: from resqmta-po-10v.sys.comcast.net (resqmta-po-10v.sys.comcast.net [96.114.154.169]) (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 8EFE73002C84 for ; Tue, 6 Nov 2018 17:06:57 +0000 (UTC) Received: from resomta-po-02v.sys.comcast.net ([96.114.154.226]) by resqmta-po-10v.sys.comcast.net with ESMTP id K2Rpg7cKt3raLK4obg1uKS; Tue, 06 Nov 2018 17:06:57 +0000 Received: from mail.tremily.us ([67.168.83.168]) by resomta-po-02v.sys.comcast.net with ESMTPSA id K4megPfVFohhGK4mfg2xwf; Tue, 06 Nov 2018 17:04:57 +0000 Received: by mail.tremily.us (Postfix, from userid 1000) id 7E1F21A20810; Tue, 6 Nov 2018 09:10:42 -0800 (PST) From: "W. Trevor King" To: libvir-list@redhat.com Date: Tue, 6 Nov 2018 09:10:39 -0800 Message-Id: X-CMAE-Envelope: MS4wfOJf9GR1puLCVZxbHDeeIdHW5uidrvtc7U4tm0+b/V3jH7olm0sYvMWn71ymVukh4spmfMJDXZBYCZTMPlaE/4chC5DnQBAUvYhcK8D4ZZJT6O0zfBuF xgK2a+1K70uU80FWzRY13EA0q7IwMbsSo2doRrI3AvfPgcfKH6Jg9jtN X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 06 Nov 2018 17:06:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 06 Nov 2018 17:06:58 +0000 (UTC) for IP:'96.114.154.169' DOMAIN:'resqmta-po-10v.sys.comcast.net' HELO:'resqmta-po-10v.sys.comcast.net' FROM:'wking@tremily.us' RCPT:'' X-RedHat-Spam-Score: -0.702 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_PASS) 96.114.154.169 resqmta-po-10v.sys.comcast.net 96.114.154.169 resqmta-po-10v.sys.comcast.net X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: "W. Trevor King" Subject: [libvirt] [PATCH] virNetworkDefUpdateDNSHost: Require both IP and a hostname to match 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 06 Nov 2018 17:08:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Since fc19a0059 (network: backend functions for updating network dns host/srv/txt, 2012-11-12), the matching logic for various network components has been: 1) for HOST records, it's considered a match if the IP address or any of the hostnames of an existing record matches. 2) for SRV records, it's a match if all of domain+service+protocol+target *which have been specified* are matched. 3) for TXT records, there is only a single field to match - name (value can be the same for multiple records, and isn't considered a search term), so by definition there can be no ambiguous matches. But HOST records can have the same hostname for multiple records (similar to TXT records with the same value). The value that needs to be distinct for HOST records is the IP address. This commit updates the matching logic to only consider the IP address. Compared to the previous HOST logic: 1. You can now delete entries from an existing network like: example example with input like: or: example Previously, only the former would work (the latter used to raise "multiple matching DNS HOST records were found in network"). 2. You can no longer remove entries by hostname alone. Previously, you may have been able to remove an entry from an existing network like: example-1 example-2 with input like: example-1 using the 'name' property to get through the partialOkay check in virNetworkDHCPHostDefParseXML. Now that input will raise "Missing IP address in network '%s' DNS HOST record". 3. You can now add multiple entries with a common hostname (as long as they have distinct IP addresses). Previously, adding: example to an existing: example would have raised "there is already at least one DNS HOST record with a matching field in network". --- I'm actually not clear on whether the 'ip' attribute is required to be unique or not. If not, maybe the logic should be: * Deletes with just an IP remove all entries that match that IP. * Deletes with just a hostname remove all entries that match that hostname. * Deletes with an IP and a hostname remove matching entries from entries which match the IP. * If removal completely empties a , the is also removed. Thoughts? src/conf/network_conf.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 39a13b4..8ed62ac 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -587,14 +587,14 @@ virNetworkDNSHostDefParseXML(const char *networkName, xmlNodePtr cur; char *ip; =20 - if (!(ip =3D virXMLPropString(node, "ip")) && !partialOkay) { + if (!(ip =3D virXMLPropString(node, "ip"))) { virReportError(VIR_ERR_XML_DETAIL, _("Missing IP address in network '%s' DNS HOST reco= rd"), networkName); goto error; } =20 - if (ip && (virSocketAddrParse(&def->ip, ip, AF_UNSPEC) < 0)) { + if (virSocketAddrParse(&def->ip, ip, AF_UNSPEC) < 0) { virReportError(VIR_ERR_XML_DETAIL, _("Invalid IP address in network '%s' DNS HOST reco= rd"), networkName); @@ -603,6 +603,13 @@ virNetworkDNSHostDefParseXML(const char *networkName, } VIR_FREE(ip); =20 + if (!VIR_SOCKET_ADDR_VALID(&def->ip)) { + virReportError(VIR_ERR_XML_DETAIL, + _("Invalid IP address in network '%s' DNS HOST reco= rd"), + networkName); + goto error; + } + cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE && @@ -631,13 +638,6 @@ virNetworkDNSHostDefParseXML(const char *networkName, goto error; } =20 - if (!VIR_SOCKET_ADDR_VALID(&def->ip) && def->nnames =3D=3D 0) { - virReportError(VIR_ERR_XML_DETAIL, - _("Missing ip and hostname in network '%s' DNS HOST= record"), - networkName); - goto error; - } - return 0; =20 error: @@ -3334,18 +3334,7 @@ virNetworkDefUpdateDNSHost(virNetworkDefPtr def, goto cleanup; =20 for (i =3D 0; i < dns->nhosts; i++) { - bool foundThisTime =3D false; - - 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; - } - } - if (foundThisTime) { + if virSocketAddrEqual(&host.ip, &dns->hosts[i].ip) { foundCt++; foundIdx =3D i; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list