From nobody Mon Apr 29 15:50:38 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 ARC-Seal: i=1; a=rsa-sha256; t=1556202558; cv=none; d=zoho.com; s=zohoarc; b=LSKpNBpdJGHhj1ezkZqBQ9gT+6IWzXoDSqmObgcasJujExvgNUX7vNRir4MeqQAteYqWxsq3G/u40ezWFQ1mXAVY62LelX7KHFdK1dvQQuz2GQX5LblQWIVcOQ7cMHhR39ckvVMNKZ8LBX+kULGW3XE+EWt5W7p9aBtqqoXGoI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556202558; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=7WZ1IAKrjd6Aca/S7Ilzd8WQtmTC5V9J4On+rfgnN0E=; b=FcbD8BP96lMGKm++WDXNiOfiowS04pB1J3kFAKB8hwqCQRboqOHEeZSez11ZmXo4IR0K8sBAyQFUyh9PvHUpawMNYC+2qmrI4LLja8DWnkaxZctKQxGK+hG+qbe7xGiVPB+483YAMvZ49MKnMQXUx3g+56nPqM/YkG3D1zaIVlw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556202558755733.6776939402059; Thu, 25 Apr 2019 07:29:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4367B356F5; Thu, 25 Apr 2019 14:29:17 +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 D3D4F60C9A; Thu, 25 Apr 2019 14:29:16 +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 6505A181B9E0; Thu, 25 Apr 2019 14:29:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3P6K0Fb023210 for ; Thu, 25 Apr 2019 02:20:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id B84BE58B2; Thu, 25 Apr 2019 06:20:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2B4419491 for ; Thu, 25 Apr 2019 06:19:58 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.195]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27DEE46202 for ; Thu, 25 Apr 2019 06:19:55 +0000 (UTC) Received: from yili?winhong.com (unknown [192.168.167.177]) by regular1.263xmail.com (Postfix) with ESMTP id CC4819DB for ; Thu, 25 Apr 2019 14:19:52 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.70]) by smtp.263.net (postfix) whith ESMTP id P26601T139790137669376S1556173188844234_; Thu, 25 Apr 2019 14:19:52 +0800 (CST) X-263anti-spam: KSV:0;BIG:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ADDR-CHECKED4: 1 X-ABS-CHECKED: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: libvir-list@redhat.com X-SENDER-IP: 14.18.236.70 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Yi Li To: libvir-list@redhat.com Date: Thu, 25 Apr 2019 14:19:37 +0800 Message-Id: <1556173177-18540-1-git-send-email-yili@winhong.com> X-Greylist: Sender passed SPF test, ACL 242 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Apr 2019 06:19:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Apr 2019 06:19:57 +0000 (UTC) for IP:'211.150.70.195' DOMAIN:'regular1.263xmail.com' HELO:'regular1.263xmail.com' FROM:'yili@winhong.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 211.150.70.195 regular1.263xmail.com 211.150.70.195 regular1.263xmail.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Thu, 25 Apr 2019 10:29:15 -0400 Cc: Yi Li Subject: [libvirt] [PATCH] storage: escape ipv6 for ceph mon hosts to librados 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 25 Apr 2019 14:29:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Hosts for rbd are ceph monitor daemons. These have fixed IP addresses, so they are often referenced by IP rather than hostname for convenience, or to avoid relying on DNS. Using IPv4 addresses as the host name works already, but IPv6 addresses require rbd-specific escaping because the colon is used as an option separator in the string passed to librados. Escape these colons, and enclose the IPv6 address in square brackets so it is distinguished from the port, which is currently mandatory. Signed-off-by: Yi Li --- docs/schemas/storagepool.rng | 5 ++++- src/storage/storage_backend_rbd.c | 13 ++++++++++--- tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml | 13 +++++++++++++ tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml | 16 ++++++++++++++++ tests/storagepoolxml2xmltest.c | 1 + 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml create mode 100644 tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 3ca8e79..976a02b 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -305,7 +305,10 @@ - + + + + diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index f8c968e..3056563 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -268,9 +268,16 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBD= StatePtr ptr, source->hosts[i].name); } else if (source->hosts[i].name !=3D NULL && source->hosts[i].port) { - virBufferAsprintf(&mon_host, "%s:%d,", - source->hosts[i].name, - source->hosts[i].port); + /* assume host containing : is ipv6 */ + if (strchr(source->hosts[i].name, ':')) { + virBufferAsprintf(&mon_host, "[%s]:%d,", + source->hosts[i].name, + source->hosts[i].port); + } else { + virBufferAsprintf(&mon_host, "%s:%d,", + source->hosts[i].name, + source->hosts[i].port); + } } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("received malformed monitor, check the XML de= finition")); diff --git a/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml b/tests/storagepo= olxml2xmlin/pool-rbd-ipv6.xml new file mode 100644 index 0000000..0744b33 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml @@ -0,0 +1,13 @@ + + ceph + 47c1faee-0207-e741-f5ae-d9b019b98fe2 + + rbd + + + + + + + + diff --git a/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml b/tests/storagep= oolxml2xmlout/pool-rbd-ipv6.xml new file mode 100644 index 0000000..cc2a379 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml @@ -0,0 +1,16 @@ + + ceph + 47c1faee-0207-e741-f5ae-d9b019b98fe2 + 0 + 0 + 0 + + + + + rbd + + + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 2ae514f..b6f4cb4 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -95,6 +95,7 @@ mymain(void) DO_TEST("pool-zfs-sourcedev"); DO_TEST("pool-rbd"); #ifdef WITH_STORAGE_RBD + DO_TEST("pool-rbd-ipv6"); DO_TEST("pool-rbd-refresh-volume-allocation"); DO_TEST("pool-rbd-ns-configopts"); #endif --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list