From nobody Wed Feb 11 10:17:40 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.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