From nobody Mon Feb 9 01:21:06 2026 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; dkim=fail; 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=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1550516974257429.76546691037436; Mon, 18 Feb 2019 11:09:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F26036EBA2; Mon, 18 Feb 2019 19:09:31 +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 B3FF65D71C; Mon, 18 Feb 2019 19:09:31 +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 64BCC181A00B; Mon, 18 Feb 2019 19:09:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1IJ9TX5019055 for ; Mon, 18 Feb 2019 14:09:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id DF267579BB; Mon, 18 Feb 2019 19:09:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D71ED60C1D for ; Mon, 18 Feb 2019 19:09:20 +0000 (UTC) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53C64C05784A for ; Mon, 18 Feb 2019 19:09:19 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id p15so10604766qkl.5 for ; Mon, 18 Feb 2019 11:09:19 -0800 (PST) Received: from localhost.localdomain ([177.95.254.156]) by smtp.gmail.com with ESMTPSA id s21sm9106768qki.94.2019.02.18.11.09.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 11:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=G7+7KTrLqvvcDrvOkm4AdXLj9JFhcYU1rmb3A5kbtqU=; b=uYD11ut3iKOXDMZan5yr/ecwQmx8YCP0pteV0Jljsm/E9amC+zHpvZto8OFASlvby9 EHmvKfgODMhKaK7XqdR6Jb8raOQ8XL97btQFxeBtqtSPvqyKbsGfX5HAcSQXKyIx2CTq M0p1/LGB+4hB87jp66QH1OU6v6KmIdg291LE3hS09eOzsmSkvE2FAGuLoiglv9Mm8gcl wnksiyfwWawY8GWkn6UflB/XD+XvkWPcvXXwJJj6SZKuXBCidEEGvg8Heb7Gb2HX8obG LMeaDbSNIuFbsipFf5ZXD8n9P1PGSkVxzXFzTkTXHxQzhSaWu1EuwfUO82gG5LGaHJ1L IF6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G7+7KTrLqvvcDrvOkm4AdXLj9JFhcYU1rmb3A5kbtqU=; b=n8OFlHXR3LMMJ7mi8j75jWfy3ao3SWXvl9xvMAuQnRyGOodVru/NqU4hUMVo9SKGZQ vScnYt7rsP2IYOFUxUYZgqCuDMKeqt2haKof9dgHeoRPliX8gUu53tAnL/jXQEO0R85U 57vu7jiaaL5hbm3ubw8QiSg3U8aZEK2GcMi0OujSEH+2AyxfXefFkcZ0124jHdOPPD7C BT3RgMiPTEwnZLHkkDCk79NZ+ChakyCJMZg7/sWNriVDhc/y2SrbPHPcR+a+uD/Ov260 gCISMzTZyoZ8N+y2Of8gJ0H8EAlU/sqERRtLSnQTySRpjTpl60xwe/Uc3NmhjiWZBz6R Oowg== X-Gm-Message-State: AHQUAub0IXTuBuLaoFOFcFS7Bz5EkjQTotYczGc8go09+OLcVhbe1dnQ OCF/pVYRLFvzHHfZmBHZJXeqyzcX X-Google-Smtp-Source: AHgI3IaUobKzE9d5XpkH/yvVMVs+h6IXarDbBOMQenebyG9nPq3SNlsu/UxUbAv3LI2BF9O+b4P75Q== X-Received: by 2002:a37:cfdd:: with SMTP id v90mr14411726qkl.193.1550516958307; Mon, 18 Feb 2019 11:09:18 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 18 Feb 2019 16:09:05 -0300 Message-Id: <20190218190910.22477-2-jcfaracco@gmail.com> In-Reply-To: <20190218190910.22477-1-jcfaracco@gmail.com> References: <20190218190910.22477-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 19:09:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 19:09:19 +0000 (UTC) for IP:'209.85.222.177' DOMAIN:'mail-qk1-f177.google.com' HELO:'mail-qk1-f177.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.222.177 mail-qk1-f177.google.com 209.85.222.177 mail-qk1-f177.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] lxc: Create a separate method to handle IPv{4, 6} outside parser. 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Feb 2019 19:09:32 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The new method called lxcNetworkParseDataIPs() is responsible to handle IPv{4,6} settings now. The idea is let lxcNetworkWalkCallback() method handle all entries related to network definition only. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 65 +++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 1eee3fc2bb..5bbbbf132c 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -552,6 +552,42 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data) return -1; } =20 +static int +lxcNetworkParseDataIPs(const char *name, virConfValuePtr value, lxcNetwork= ParseData *parseData) +{ + int family =3D AF_INET; + char **ipparts =3D NULL; + virNetDevIPAddrPtr ip =3D NULL; + + if (VIR_ALLOC(ip) < 0) + return -1; + + if (STREQ(name, "lxc.network.ipv6")) + family =3D AF_INET6; + + ipparts =3D virStringSplit(value->str, "/", 2); + if (virStringListLength((const char * const *)ipparts) !=3D 2 || + virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || + virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { + + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid CIDR address: '%s'"), value->str); + + virStringListFree(ipparts); + VIR_FREE(ip); + return -1; + } + + virStringListFree(ipparts); + + if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0) { + VIR_FREE(ip); + return -1; + } + + return 0; +} + static int lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data) { @@ -597,35 +633,8 @@ lxcNetworkWalkCallback(const char *name, virConfValueP= tr value, void *data) parseData->name =3D value->str; else if (STREQ(name, "lxc.network.ipv4") || STREQ(name, "lxc.network.ipv6")) { - int family =3D AF_INET; - char **ipparts =3D NULL; - virNetDevIPAddrPtr ip =3D NULL; - - if (VIR_ALLOC(ip) < 0) + if (lxcNetworkParseDataIPs(name, value, parseData) < 0) return -1; - - if (STREQ(name, "lxc.network.ipv6")) - family =3D AF_INET6; - - ipparts =3D virStringSplit(value->str, "/", 2); - if (virStringListLength((const char * const *)ipparts) !=3D 2 || - virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || - virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { - - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid CIDR address: '%s'"), value->str); - - virStringListFree(ipparts); - VIR_FREE(ip); - return -1; - } - - virStringListFree(ipparts); - - if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0) { - VIR_FREE(ip); - return -1; - } } else if (STREQ(name, "lxc.network.ipv4.gateway")) { parseData->gateway_ipv4 =3D value->str; } else if (STREQ(name, "lxc.network.ipv6.gateway")) { --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list