From nobody Fri Apr 26 16:38:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544111928144591.871188087232; Thu, 6 Dec 2018 07:58:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E131C81DEC; Thu, 6 Dec 2018 15:58:45 +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 A648D105705C; Thu, 6 Dec 2018 15:58:45 +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 547BB3F605; Thu, 6 Dec 2018 15:58:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wB6FwWPC022496 for ; Thu, 6 Dec 2018 10:58:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5DD605D77E; Thu, 6 Dec 2018 15:58:32 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-189.phx2.redhat.com [10.3.117.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id E312A5D6A6; Thu, 6 Dec 2018 15:58:31 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Thu, 6 Dec 2018 10:58:22 -0500 Message-Id: <20181206155823.3246-2-laine@laine.org> In-Reply-To: <20181206155823.3246-1-laine@laine.org> References: <20181206155823.3246-1-laine@laine.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: kolomaxes@gmail.com Subject: [libvirt] [PATCH v2 1/2] lxc: check actual type of interface not config type 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 06 Dec 2018 15:58:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virLXCControllerGetNICIndexes() was deciding whether or not to add the ifindex for an interface's ifname to the list of ifindexes sent to CreateMachineWithNetwork based on the interface type stored in the config. This would be incorrect in the case of where the network was giving out macvlan interfaces tied to a physical device (i.e. when the actual interface type was "direct"). Instead of checking the setting of "net->type", we should be checking the setting of virDomainNetGetActualType(net). I don't think this caused any actual misbehavior, it was just technically wrong. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_controller.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index e853d02d65..07342cbc77 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -367,7 +367,10 @@ static int virLXCControllerGetNICIndexes(virLXCControl= lerPtr ctrl) VIR_DEBUG("Getting nic indexes"); for (i =3D 0; i < ctrl->def->nnets; i++) { int nicindex =3D -1; - switch (ctrl->def->nets[i]->type) { + virDomainNetType actualType + =3D virDomainNetGetActualType(ctrl->def->nets[i]); + + switch (actualType) { case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_ETHERNET: @@ -396,11 +399,11 @@ static int virLXCControllerGetNICIndexes(virLXCContro= llerPtr ctrl) case VIR_DOMAIN_NET_TYPE_HOSTDEV: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type %s"), - virDomainNetTypeToString(ctrl->def->nets[i]->ty= pe)); + virDomainNetTypeToString(actualType)); goto cleanup; case VIR_DOMAIN_NET_TYPE_LAST: default: - virReportEnumRangeError(virDomainNetType, ctrl->def->nets[i]->= type); + virReportEnumRangeError(virDomainNetType, actualType); goto cleanup; } } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 16:38:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544111920871643.020243492707; Thu, 6 Dec 2018 07:58:40 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 798E3C067829; Thu, 6 Dec 2018 15:58:38 +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 26D596E3E7; Thu, 6 Dec 2018 15:58:37 +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 401393F604; Thu, 6 Dec 2018 15:58:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wB6FwXMP022501 for ; Thu, 6 Dec 2018 10:58:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 01FD45D77E; Thu, 6 Dec 2018 15:58:33 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-189.phx2.redhat.com [10.3.117.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85A7B5D6A6; Thu, 6 Dec 2018 15:58:32 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Thu, 6 Dec 2018 10:58:23 -0500 Message-Id: <20181206155823.3246-3-laine@laine.org> In-Reply-To: <20181206155823.3246-1-laine@laine.org> References: <20181206155823.3246-1-laine@laine.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: kolomaxes@gmail.com Subject: [libvirt] [PATCH v2 2/2] lxc: don't forbid 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 06 Dec 2018 15:58:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Commit 017dfa27d changed a few switch statements in the LXC code to have all possible enum values, and in the process changed the switch statement in virLXCControllerGetNICIndexes() to return an error status for unsupported interface types, but it erroneously put type=3D'direct' on the list of unsupported types. type=3D'direct' (implemented with a macvlan interface) is supported on LXC, but it's interface shouldn't be placed on the list of interfaces given to CreateMachineWithNetwork() because the interface is put inside the container, while CreateMachineWithNetwork() only wants to know about the parent veths of veth pairs (the parent veth remains on the host side, while the child veth is put into the container). Resolves: https://bugzilla.redhat.com/1656463 Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_controller.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 07342cbc77..cff004a034 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -364,6 +364,16 @@ static int virLXCControllerGetNICIndexes(virLXCControl= lerPtr ctrl) size_t i; int ret =3D -1; =20 + /* Gather the ifindexes of the "parent" veths for all interfaces + * implemented with a veth pair. These will be used when calling + * virCgroupNewMachine (and eventually the dbus method + * CreateMachineWithNetwork). ifindexes for the child veths, and + * for macvlan interfaces, *should not* be in this list, as they + * will be moved into the container. Only the interfaces that will + * remain outside the container, but are used for communication + * with the container, should be added to the list. + */ + VIR_DEBUG("Getting nic indexes"); for (i =3D 0; i < ctrl->def->nnets; i++) { int nicindex =3D -1; @@ -388,6 +398,9 @@ static int virLXCControllerGetNICIndexes(virLXCControll= erPtr ctrl) ctrl->nicindexes[ctrl->nnicindexes-1] =3D nicindex; break; =20 + case VIR_DOMAIN_NET_TYPE_DIRECT: + break; + case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_VHOSTUSER: case VIR_DOMAIN_NET_TYPE_SERVER: @@ -395,7 +408,6 @@ static int virLXCControllerGetNICIndexes(virLXCControll= erPtr ctrl) case VIR_DOMAIN_NET_TYPE_MCAST: case VIR_DOMAIN_NET_TYPE_UDP: case VIR_DOMAIN_NET_TYPE_INTERNAL: - case VIR_DOMAIN_NET_TYPE_DIRECT: case VIR_DOMAIN_NET_TYPE_HOSTDEV: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type %s"), --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list