From nobody Fri May 3 11:51:02 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.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 149010981468461.12352907297338; Tue, 21 Mar 2017 08:23:34 -0700 (PDT) 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 EC1883B721; Tue, 21 Mar 2017 15:23:33 +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 B757917A6B; Tue, 21 Mar 2017 15:23:33 +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 3581A18521C8; Tue, 21 Mar 2017 15:23:33 +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 v2LFNVMM013710 for ; Tue, 21 Mar 2017 11:23:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE9E817A64; Tue, 21 Mar 2017 15:23:31 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-242.phx2.redhat.com [10.3.116.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EC2D7E61C; Tue, 21 Mar 2017 15:23:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC1883B721 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EC1883B721 From: Laine Stump To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 11:23:23 -0400 Message-Id: <20170321152325.20524-2-laine@laine.org> In-Reply-To: <20170321152325.20524-1-laine@laine.org> References: <20170321152325.20524-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: stefanb@us.ibm.com Subject: [libvirt] [PATCH 1/3] util: use AF_UNIX family (not AF_PACKET) for ioctl sockets 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 21 Mar 2017 15:23:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The exact family of the socket created for the fd used by ioctl(7) doesn't matter, it just needs to be a socket and not a file. But for some reason when macvtap support was added, it used AF_PACKET/SOCK_DGRAM sockets for its ioctls; we later used the same AF_PACKET/SOCK_DGRAM socket for new ioctls we added, and eventually modified the other pre-existing ioctl sockets (for creating/deleting bridges) to also use AF_PACKET/SOCK_DGRAM (that code originally used AF_UNIX/SOCK_STREAM). The problem with using AF_PACKET (intended for sending/receiving "raw" packets, i.e. packets that can be some protocol other than TCP or UDP) is that it requires root privileges. This meant that none of the ioctls in virnetdev.c or virnetdevip.c would work when running libvirtd unprivileged. This patch solves that problem by changing the family to AF_UNIX when creating the socket used for any ioctl(). --- (Cc'ing Stefan Berger, since he originally added the code using AF_PACKET, and I want to make sure this was just a random choice, and not for some important reason I'm overlooking) src/util/virnetdev.c | 2 +- src/util/virnetdevip.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index d9f716b..b0159b2 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -41,7 +41,7 @@ #ifdef __linux__ # include # include -# define VIR_NETDEV_FAMILY AF_PACKET +# define VIR_NETDEV_FAMILY AF_UNIX #elif defined(HAVE_STRUCT_IFREQ) && defined(AF_LOCAL) # define VIR_NETDEV_FAMILY AF_LOCAL #else diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index 42fbba1..c82b8a5 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -44,7 +44,7 @@ #ifdef __linux__ # include # include -# define VIR_NETDEV_FAMILY AF_PACKET +# define VIR_NETDEV_FAMILY AF_UNIX #elif defined(HAVE_STRUCT_IFREQ) && defined(AF_LOCAL) # define VIR_NETDEV_FAMILY AF_LOCAL #else --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 11:51:02 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.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 1490109817280366.8222448915344; Tue, 21 Mar 2017 08:23:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D831C04D2AB; Tue, 21 Mar 2017 15:23:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BE661713A; Tue, 21 Mar 2017 15:23:36 +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 C48865EC62; Tue, 21 Mar 2017 15:23:35 +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 v2LFNWro013717 for ; Tue, 21 Mar 2017 11:23:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33DA717A64; Tue, 21 Mar 2017 15:23:32 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-242.phx2.redhat.com [10.3.116.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7C7817A67 for ; Tue, 21 Mar 2017 15:23:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4D831C04D2AB Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4D831C04D2AB From: Laine Stump To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 11:23:24 -0400 Message-Id: <20170321152325.20524-3-laine@laine.org> In-Reply-To: <20170321152325.20524-1-laine@laine.org> References: <20170321152325.20524-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] util: allow retrieving ethtool features when unprivileged 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 21 Mar 2017 15:23:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The only reason that the ethtool features weren't being retrieved in an unprivileged libvirtd was because they required ioctl(), and the ioctl was using an AF_PACKET socket, which requires root. Now that we are using AF_UNIX for ioctl(), this restriction can be removed. --- src/util/virnetdev.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b0159b2..0d19432 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -2980,12 +2980,6 @@ virNetDevGetFeatures(const char *ifname, if (!(*out =3D virBitmapNew(VIR_NET_DEV_FEAT_LAST))) return -1; =20 - /* Only fetch features if we're privileged, but no need to fail */ - if (geteuid() !=3D 0) { - VIR_DEBUG("ETHTOOL feature bits not available in session mode"); - return 0; - } - /* Ultimately uses AF_PACKET for socket which requires privileged * daemon support. */ --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 11:51:02 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.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 1490109877405907.782849336946; Tue, 21 Mar 2017 08:24:37 -0700 (PDT) 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 C7A602E6047; Tue, 21 Mar 2017 15:24:36 +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 9C15317A6A; Tue, 21 Mar 2017 15:24:36 +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 38B9218521C9; Tue, 21 Mar 2017 15:24:35 +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 v2LFNWGp013725 for ; Tue, 21 Mar 2017 11:23:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F4A317A68; Tue, 21 Mar 2017 15:23:32 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-242.phx2.redhat.com [10.3.116.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DCD317A64 for ; Tue, 21 Mar 2017 15:23:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C7A602E6047 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C7A602E6047 From: Laine Stump To: libvir-list@redhat.com Date: Tue, 21 Mar 2017 11:23:25 -0400 Message-Id: <20170321152325.20524-4-laine@laine.org> In-Reply-To: <20170321152325.20524-1-laine@laine.org> References: <20170321152325.20524-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] network: remove unused typedef for networkDnsmasqLeaseFileNameFunc 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 21 Mar 2017 15:24:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/network/bridge_driver.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index ff7f921..c696f03 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -102,6 +102,4 @@ networkBandwidthUpdate(virDomainNetDefPtr iface ATTRIBU= TE_UNUSED, =20 # endif =20 -typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname); - #endif /* __VIR_NETWORK__DRIVER_H */ --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list