From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979057; cv=none; d=zohomail.com; s=zohoarc; b=ensKSdiXIaWqvSFKdn4kJPP3We0OtDZPzIWwcUfp6xJmSkyCylRw8Tx3Ho2msZvA5bfminVeBaagnTFymudTy6PXJBddC6ESAGFdpegrpWNS+C7UIZln83Y5FIwDt9gR/mzQpmiYOvgikF8TNJJvH3fcUleN9do9vAH9PM7n4x4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979057; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uR0u9OZYhJ2tBSmJCAPvb4M9OBU8yMsbTxmrFBMd5hs=; b=cIB05q/yG2I2GxujnQMU2rtlgzttO8IFpBWBtFpldEbSEXRG5ynHJesDLCtPToapl1PUNTxjSnw/XX3WMtmrAEUI+Py9dgbatGVjEd5dTbllm68NME3i4sDs5WRwRGcJbuUuD7tqD6khGQAFmyW+fDFSJbFV7jCtwphPI+ITcvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603979057466542.8165677829971; Thu, 29 Oct 2020 06:44:17 -0700 (PDT) Received: from localhost ([::1]:52048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8Dw-0003uO-GR for importer@patchew.org; Thu, 29 Oct 2020 09:44:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88h-0005ti-EN for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88f-0008Jp-48 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-581-wOhaBtmyOHqbb-cLrVaQcA-1; Thu, 29 Oct 2020 09:38:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B201C805EF4; Thu, 29 Oct 2020 13:38:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 288D35D9EF; Thu, 29 Oct 2020 13:38:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 99864113861E; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uR0u9OZYhJ2tBSmJCAPvb4M9OBU8yMsbTxmrFBMd5hs=; b=jWEbYNNk5tNxrjo2PV0BX1DLUBZ8aV9/Ksr/Z81BjpA5uFEkfUdQFIABuCzIg7AwEzI2/B TKA/+Qz6Xkpjk/0OQgM3R1aEdZx9TWCvl3BaiidQG+P6db2kQxkDV/5uQNUI3xlsCX3e6e K+0fzUC1o8VMP6y+cejHezSk/4rPizw= X-MC-Unique: wOhaBtmyOHqbb-cLrVaQcA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 01/11] test-util-sockets: Plug file descriptor leak Date: Thu, 29 Oct 2020 14:38:23 +0100 Message-Id: <20201029133833.3450220-2-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Fixes: 4d3a329af59ef8acd076f99f05e82531d8129b34 Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- tests/test-util-sockets.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index f6336e0f91..15da867b8f 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -252,6 +252,7 @@ static gpointer unix_server_thread_func(gpointer user_d= ata) =20 connfd =3D accept(fd, (struct sockaddr *)&un, &len); g_assert_cmpint(connfd, !=3D, -1); + close(connfd); =20 close(fd); =20 --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603978873; cv=none; d=zohomail.com; s=zohoarc; b=EiPS78YhQ0Ev10zLnf0BTnXnW4T/Uri4U5VmbyGQIZIxfpLyj9EIp2C43yF3QGVw4jfDFphG4VgLdmPr5ofM9CIEylIXGMtEvyTZh9mgaiNHatH8lM4WdEWhGU73clKbSFCszibMiFA3TMgmkfEj12VCt/PIItm22l3XuDO0Uac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603978873; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ipDAHN34HYPTwpBfDDlZgURqYSPDncPgCbiQcKj+//M=; b=c2xMOcSDFnT2koYpddy98g0yRZlDOnhLAF/3pVJda0HrpX3zLfFZq2DL5gWFqWXUFTThIH2biWbMELqy0skK2j2CqfZAi5nHu9Zyy4ujOAoF1B26kXErCfZH6XdKyvdD0t0vI4prd8eJDxHdkLlb1kI98LFlZ3C76AVCkxKqFmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603978873930520.5472457051487; Thu, 29 Oct 2020 06:41:13 -0700 (PDT) Received: from localhost ([::1]:40764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8Ay-0007jm-SW for importer@patchew.org; Thu, 29 Oct 2020 09:41:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88i-0005uu-48 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44312) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88c-0008JH-Uz for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-bwbY1UlqO6-_Tfk9bFN91Q-1; Thu, 29 Oct 2020 09:38:44 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F0D11018F7C; Thu, 29 Oct 2020 13:38:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2861160E1C; Thu, 29 Oct 2020 13:38:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9CA401138461; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ipDAHN34HYPTwpBfDDlZgURqYSPDncPgCbiQcKj+//M=; b=aE4xlScG/UryHPsY9w5kzfpTTVYDwCaPeUcC3YeK/PXrrUZEuivtoM8g/Nqp0bsHzOzsFe NIBCmhCEUIJTvIF345kUCz3o0hrBhV1EOZMHO8wUHw5M6q8R/CMAKHzj6DV1mGcVLQQc6r 2lD4m8LXpu7/BSKS6Mj2QtKAqiPMnRA= X-MC-Unique: bwbY1UlqO6-_Tfk9bFN91Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 02/11] test-util-sockets: Correct to set has_abstract, has_tight Date: Thu, 29 Oct 2020 14:38:24 +0100 Message-Id: <20201029133833.3450220-3-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The code tested doesn't care, which is a bug I will fix shortly. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- tests/test-util-sockets.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 15da867b8f..9d317e73a6 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -243,7 +243,9 @@ static gpointer unix_server_thread_func(gpointer user_d= ata) =20 addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; addr.u.q_unix.path =3D abstract_sock_name; + addr.u.q_unix.has_tight =3D true; addr.u.q_unix.tight =3D user_data !=3D NULL; + addr.u.q_unix.has_abstract =3D true; addr.u.q_unix.abstract =3D true; =20 fd =3D socket_listen(&addr, 1, &err); @@ -267,7 +269,9 @@ static gpointer unix_client_thread_func(gpointer user_d= ata) =20 addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; addr.u.q_unix.path =3D abstract_sock_name; + addr.u.q_unix.has_tight =3D true; addr.u.q_unix.tight =3D user_data !=3D NULL; + addr.u.q_unix.has_abstract =3D true; addr.u.q_unix.abstract =3D true; =20 fd =3D socket_connect(&addr, &err); --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603978896; cv=none; d=zohomail.com; s=zohoarc; b=QeDUIFTo2HAKZ2+8EV/rDs6nfF5O9lmtibvNIx/i++BDYgo2rAb9LljPXM99bPTJHzJNnjGpI3R5QjLw8GnLmqCXPfffxXpmC1KzVPOgPbRbNb4T5J5XqcSXWaYPMu785cvBHcHA1zxVJQK88Sv30aZeoZz+iWYEF1RbDMMsp9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603978896; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aAvrY18gsWhtfCs+PRf6YPZnkLAFlXIFr47Ukhgadd8=; b=etzZ6h0Z0wH+SZ0P1m+YQGCIoUwfdblcVL7B62EtLTiufKmJXXcRLwasI3lU37ZO3p7xWXS49pmsRRa/zvMExgujoooJs/LeSxSY2Irrt9wxyf/2d7j36ShfU0HSGnKP55lT+YxfJvRrz7GG09TrDgmMbxdqziaO5ejk7EmPtZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603978896743297.03888756391314; Thu, 29 Oct 2020 06:41:36 -0700 (PDT) Received: from localhost ([::1]:42256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8BL-0008Kv-Kl for importer@patchew.org; Thu, 29 Oct 2020 09:41:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88e-0005ot-FE for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88c-0008JB-CO for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-lB-KYrK1M62iTnnQAF4m4A-1; Thu, 29 Oct 2020 09:38:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09BCE1018F79; Thu, 29 Oct 2020 13:38:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D19E19930; Thu, 29 Oct 2020 13:38:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9FD241138468; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aAvrY18gsWhtfCs+PRf6YPZnkLAFlXIFr47Ukhgadd8=; b=Y5jLrmiFooNN5DKB5Avatf4dkwILNPm9obqYFNz5+s/7ygf3zz5fwydQ3UCibYsOK1BI7n kmhFmjEdC9OlH3qknosvQuOUFkLvZeFtV3DqJ40AkGEOljPM9sY5A/XZ9H2xkYu7Q/KnG9 I7axUUU1fT7Gdm4w9F40pTRq4d+d7BY= X-MC-Unique: lB-KYrK1M62iTnnQAF4m4A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 03/11] test-util-sockets: Clean up SocketAddress construction Date: Thu, 29 Oct 2020 14:38:25 +0100 Message-Id: <20201029133833.3450220-4-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The thread functions build the SocketAddress from global variable @abstract_sock_name and the tight flag passed as pointer argument (either NULL or (gpointer)1). There is no need for such hackery; simply pass the SocketAddress instead. While there, dumb down g_rand_int_range() to g_random_int(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- tests/test-util-sockets.c | 62 +++++++++++++++------------------------ 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 9d317e73a6..b1b5628bd5 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -230,25 +230,14 @@ static void test_socket_fd_pass_num_nocli(void) #endif =20 #ifdef __linux__ -static gchar *abstract_sock_name; - static gpointer unix_server_thread_func(gpointer user_data) { - SocketAddress addr; - Error *err =3D NULL; - int fd =3D -1; - int connfd =3D -1; + int fd; + int connfd; struct sockaddr_un un; socklen_t len =3D sizeof(un); =20 - addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; - addr.u.q_unix.path =3D abstract_sock_name; - addr.u.q_unix.has_tight =3D true; - addr.u.q_unix.tight =3D user_data !=3D NULL; - addr.u.q_unix.has_abstract =3D true; - addr.u.q_unix.abstract =3D true; - - fd =3D socket_listen(&addr, 1, &err); + fd =3D socket_listen(user_data, 1, &error_abort); g_assert_cmpint(fd, >=3D, 0); g_assert(fd_is_socket(fd)); =20 @@ -257,69 +246,66 @@ static gpointer unix_server_thread_func(gpointer user= _data) close(connfd); =20 close(fd); - return NULL; } =20 static gpointer unix_client_thread_func(gpointer user_data) { - SocketAddress addr; - Error *err =3D NULL; - int fd =3D -1; - - addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; - addr.u.q_unix.path =3D abstract_sock_name; - addr.u.q_unix.has_tight =3D true; - addr.u.q_unix.tight =3D user_data !=3D NULL; - addr.u.q_unix.has_abstract =3D true; - addr.u.q_unix.abstract =3D true; - - fd =3D socket_connect(&addr, &err); + int fd; =20 + fd =3D socket_connect(user_data, &error_abort); g_assert_cmpint(fd, >=3D, 0); - close(fd); - return NULL; } =20 static void test_socket_unix_abstract_good(void) { - GRand *r =3D g_rand_new(); + SocketAddress addr; =20 - abstract_sock_name =3D g_strdup_printf("unix-%d-%d", getpid(), - g_rand_int_range(r, 100, 1000)); + addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; + addr.u.q_unix.path =3D g_strdup_printf("unix-%d-%u", + getpid(), g_random_int()); + addr.u.q_unix.has_abstract =3D true; + addr.u.q_unix.abstract =3D true; =20 /* non tight socklen serv and cli */ + + addr.u.q_unix.has_tight =3D false; + addr.u.q_unix.tight =3D false; + GThread *serv =3D g_thread_new("abstract_unix_server", unix_server_thread_func, - NULL); + &addr); =20 sleep(1); =20 GThread *cli =3D g_thread_new("abstract_unix_client", unix_client_thread_func, - NULL); + &addr); =20 g_thread_join(cli); g_thread_join(serv); =20 /* tight socklen serv and cli */ + + addr.u.q_unix.has_tight =3D true; + addr.u.q_unix.tight =3D true; + serv =3D g_thread_new("abstract_unix_server", unix_server_thread_func, - (gpointer)1); + &addr); =20 sleep(1); =20 cli =3D g_thread_new("abstract_unix_client", unix_client_thread_func, - (gpointer)1); + &addr); =20 g_thread_join(cli); g_thread_join(serv); =20 - g_free(abstract_sock_name); - g_rand_free(r); + g_free(addr.u.q_unix.path); } #endif =20 --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979002; cv=none; d=zohomail.com; s=zohoarc; b=SSwklr4TfFJt4yw0uXBgvUj71hCDVbBGuggpMdzvvP/8ahDAiMa5XOUmWRVOmZHs9nWA6lBaeQVSFxl+8U3Et29c0pcjwUXI6tEDPFWmk6Bj6nuX2cVJPm02s8hDWZ2R1R/eoO7YEOXcQqsM63n8OymlQq4K/3Fw40pryWtAMaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979002; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EG8yK+UEMiZms/cfjid9unXye8eEYZE1eZxm7VRgSDE=; b=j+HV42uzKFHe+k9mxbPkavhysnHGhhiD18tO43DCb55uFhhzSvbsqbMCiXJVZOAXLGS6uL3WecbYEgkaTTD5o7IG8al4IMHPdN/ItgzNCrW5qKJmF2SRYUHPUYq7Em1yzSibmHfTHOczNY33JblJzmUspV/hVGBZwxrvIkWc2xA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160397900263744.24251881897044; Thu, 29 Oct 2020 06:43:22 -0700 (PDT) Received: from localhost ([::1]:48448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8D3-0002Qe-Ka for importer@patchew.org; Thu, 29 Oct 2020 09:43:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88h-0005uC-MV for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88d-0008JJ-2U for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-360-T83t0AX2P4KXIytgrGtABQ-1; Thu, 29 Oct 2020 09:38:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B22AE10E2186; Thu, 29 Oct 2020 13:38:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 305F15D98F; Thu, 29 Oct 2020 13:38:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A45071132FD3; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EG8yK+UEMiZms/cfjid9unXye8eEYZE1eZxm7VRgSDE=; b=eH7d10oahBqBcqnHe19kuww+o0wXWdb5sgzdFzvCVy5vNSAmrFrOO14G6XrHzV5/tLOqb8 fMtMmBi/Z3uSTbt17INpE+wcc2Ot7Q6bGuKNw40iCqgZgXY/Dt0J+PYHMHFPxPiu3zqAFW YWn8fYvMpVnVZjWHkESRCSneOOaIi5s= X-MC-Unique: T83t0AX2P4KXIytgrGtABQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 04/11] test-util-sockets: Factor out test_socket_unix_abstract_one() Date: Thu, 29 Oct 2020 14:38:26 +0100 Message-Id: <20201029133833.3450220-5-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- tests/test-util-sockets.c | 48 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index b1b5628bd5..77fc51d6f5 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -259,6 +259,24 @@ static gpointer unix_client_thread_func(gpointer user_= data) return NULL; } =20 +static void test_socket_unix_abstract_one(SocketAddress *addr) +{ + GThread *serv, *cli; + + serv =3D g_thread_new("abstract_unix_server", + unix_server_thread_func, + addr); + + sleep(1); + + cli =3D g_thread_new("abstract_unix_client", + unix_client_thread_func, + addr); + + g_thread_join(cli); + g_thread_join(serv); +} + static void test_socket_unix_abstract_good(void) { SocketAddress addr; @@ -270,40 +288,14 @@ static void test_socket_unix_abstract_good(void) addr.u.q_unix.abstract =3D true; =20 /* non tight socklen serv and cli */ - addr.u.q_unix.has_tight =3D false; addr.u.q_unix.tight =3D false; - - GThread *serv =3D g_thread_new("abstract_unix_server", - unix_server_thread_func, - &addr); - - sleep(1); - - GThread *cli =3D g_thread_new("abstract_unix_client", - unix_client_thread_func, - &addr); - - g_thread_join(cli); - g_thread_join(serv); + test_socket_unix_abstract_one(&addr); =20 /* tight socklen serv and cli */ - addr.u.q_unix.has_tight =3D true; addr.u.q_unix.tight =3D true; - - serv =3D g_thread_new("abstract_unix_server", - unix_server_thread_func, - &addr); - - sleep(1); - - cli =3D g_thread_new("abstract_unix_client", - unix_client_thread_func, - &addr); - - g_thread_join(cli); - g_thread_join(serv); + test_socket_unix_abstract_one(&addr); =20 g_free(addr.u.q_unix.path); } --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979162; cv=none; d=zohomail.com; s=zohoarc; b=mt/S0J4tm9UtR3SRI0CVAtRk8PXpKzC8jHlc8KO0uImf8h0nnJkdJ63t/1RxwQd0pNh/yFYYrthsxF5YzdKKR8Sfpof/Nv/7TwmiTkyqcH+Pd4yGYAIHOYwTk+fXsrSE1IohXLlH+07qFUteAI6qcxIbymbO26lx1mK/2Vbx1Oc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=acTP4k7dJxWpJ5Fq0SQZT9+fmMb05Cb2TQXTfT3JKyc=; b=VJZxgLpeKSvsuK7H2El0co0hDjzYm7s8uw5AkV9CjeSchzbsF7Ofvg3pJ34s/0/iLfAMiHdTd5DrEvMw11yoGbiPnyAyGQBbn84UBBFrQp+9MPmi+XPH4vqUzcR0N7OMQDbFiWuL/58+PgCrmxNMUUvC0+ZUggYj3Eli3aqWcbc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603979162273824.393982308894; Thu, 29 Oct 2020 06:46:02 -0700 (PDT) Received: from localhost ([::1]:56574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8Fd-0005s4-5r for importer@patchew.org; Thu, 29 Oct 2020 09:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88o-0005wo-4l for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88i-0008LY-E4 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-ryl5pZOvNRCVrgfKl3AXXg-1; Thu, 29 Oct 2020 09:38:49 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E26D71018F8C; Thu, 29 Oct 2020 13:38:48 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78B4B5C1C4; Thu, 29 Oct 2020 13:38:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A61EC1132D67; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=acTP4k7dJxWpJ5Fq0SQZT9+fmMb05Cb2TQXTfT3JKyc=; b=GJ/3aJ9jd1h8zCI5cU3FO/ekeTlFVvgObTFx5q0Kdm2n3arSs7fZ2PH/p59D7ZhMsekriv JWV+X4iy7inHITuFWBx4MUtqcUvoiTGK+mkmPmMrVtwcRYCisz2f7eGVKezxhMkW1TiXxH xr2sFflFCdZXCiIj45C+6e6PhY//fEE= X-MC-Unique: ryl5pZOvNRCVrgfKl3AXXg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 05/11] test-util-sockets: Synchronize properly, don't sleep(1) Date: Thu, 29 Oct 2020 14:38:27 +0100 Message-Id: <20201029133833.3450220-6-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The abstract sockets test spawns a thread to listen and a accept, and a second one to connect, with a sleep(1) in between to "ensure" the former is listening when the latter tries to connect. Review fail. Risks spurious test failure, say when a heavily loaded machine doesn't schedule the first thread quickly enough. It's also slow. Listen and accept in the main thread, and start the connect thread in between. Look ma, no sleep! Run time drops from 2s wall clock to a few milliseconds. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- tests/test-util-sockets.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 77fc51d6f5..c2802f69ee 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -230,25 +230,6 @@ static void test_socket_fd_pass_num_nocli(void) #endif =20 #ifdef __linux__ -static gpointer unix_server_thread_func(gpointer user_data) -{ - int fd; - int connfd; - struct sockaddr_un un; - socklen_t len =3D sizeof(un); - - fd =3D socket_listen(user_data, 1, &error_abort); - g_assert_cmpint(fd, >=3D, 0); - g_assert(fd_is_socket(fd)); - - connfd =3D accept(fd, (struct sockaddr *)&un, &len); - g_assert_cmpint(connfd, !=3D, -1); - close(connfd); - - close(fd); - return NULL; -} - static gpointer unix_client_thread_func(gpointer user_data) { int fd; @@ -261,20 +242,26 @@ static gpointer unix_client_thread_func(gpointer user= _data) =20 static void test_socket_unix_abstract_one(SocketAddress *addr) { - GThread *serv, *cli; + int fd, connfd; + GThread *cli; + struct sockaddr_un un; + socklen_t len =3D sizeof(un); =20 - serv =3D g_thread_new("abstract_unix_server", - unix_server_thread_func, - addr); - - sleep(1); + fd =3D socket_listen(addr, 1, &error_abort); + g_assert_cmpint(fd, >=3D, 0); + g_assert(fd_is_socket(fd)); =20 cli =3D g_thread_new("abstract_unix_client", unix_client_thread_func, addr); =20 + connfd =3D accept(fd, (struct sockaddr *)&un, &len); + g_assert_cmpint(connfd, !=3D, -1); + close(connfd); + + close(fd); + g_thread_join(cli); - g_thread_join(serv); } =20 static void test_socket_unix_abstract_good(void) --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979109; cv=none; d=zohomail.com; s=zohoarc; b=cG64wCzCGTDcq7vlfxdexMR7ZJJuZSC99K2wC6hW8MazOBm0+u3pKnDFrHUHyBGj9ggE9B2drLJHOe8zQsnbJqB0bpE/jul5Lb0y3AMnOJxoYMwe3Iz+CdUMiC+GH0aHrl0mTFPHpR0UzJFV+2klz7bgOkkrCrfXtr2YVn8PR0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979109; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I5TAkXO8hRW4draEOOtSdWG01FRAYCqFtnl4WPLDFXo=; b=oIiwRiF7us1FGFycklNnHcjubl5P0+/7qmDpvfEykGYp3+QvcIfD4LE6IeyVySIl96z4JdFQVPkXWw4OEFL5qBjBpBOq45PzcPweQHp45zpI7dbKkckMfgp9idNEFIBZ94SvG8jHerJWPnnAbD3lFPiF2SrHORlLxLwVG+JOcqk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160397910896789.14360135958123; Thu, 29 Oct 2020 06:45:08 -0700 (PDT) Received: from localhost ([::1]:54412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8Ei-0004t0-Qi for importer@patchew.org; Thu, 29 Oct 2020 09:45:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88i-0005ve-Fn for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88f-0008Jk-5c for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-9P-9i2lcOLmBlBagLy4uGg-1; Thu, 29 Oct 2020 09:38:44 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A6DF8015FB; Thu, 29 Oct 2020 13:38:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 797D460CCC; Thu, 29 Oct 2020 13:38:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A938D11329AC; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I5TAkXO8hRW4draEOOtSdWG01FRAYCqFtnl4WPLDFXo=; b=Be2c9tXoUl57gRZklTwv6UBUZsnSXTWVFlLcXOJRk+58+cpCEXiPVgWg42dIYTREgzaQey SpqIuOkhgyezFgEM1pHCmTLIXFboT5H6KX8TftkjhopZII2X48B89Q8jhfSVKtHX93zQ6Y q4TVKq+hKc6aix7WO1/djAJPMg6meKw= X-MC-Unique: 9P-9i2lcOLmBlBagLy4uGg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 06/11] test-util-sockets: Test the complete abstract socket matrix Date: Thu, 29 Oct 2020 14:38:28 +0100 Message-Id: <20201029133833.3450220-7-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The test covers only two out of nine combinations. Test all nine. Four turn out to be broken. Marked /* BUG */. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- tests/test-util-sockets.c | 86 ++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 23 deletions(-) diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index c2802f69ee..f8b6586e70 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -230,59 +230,99 @@ static void test_socket_fd_pass_num_nocli(void) #endif =20 #ifdef __linux__ + +#define ABSTRACT_SOCKET_VARIANTS 3 + +typedef struct { + SocketAddress *server, *client[ABSTRACT_SOCKET_VARIANTS]; + bool expect_connect[ABSTRACT_SOCKET_VARIANTS]; +} abstract_socket_matrix_row; + static gpointer unix_client_thread_func(gpointer user_data) { - int fd; + abstract_socket_matrix_row *row =3D user_data; + Error *err =3D NULL; + int i, fd; =20 - fd =3D socket_connect(user_data, &error_abort); - g_assert_cmpint(fd, >=3D, 0); - close(fd); + for (i =3D 0; i < ABSTRACT_SOCKET_VARIANTS; i++) { + if (row->expect_connect[i]) { + fd =3D socket_connect(row->client[i], &error_abort); + g_assert_cmpint(fd, >=3D, 0); + } else { + fd =3D socket_connect(row->client[i], &err); + g_assert_cmpint(fd, =3D=3D, -1); + error_free_or_abort(&err); + } + close(fd); + } return NULL; } =20 -static void test_socket_unix_abstract_one(SocketAddress *addr) +static void test_socket_unix_abstract_row(abstract_socket_matrix_row *test) { - int fd, connfd; + int fd, connfd, i; GThread *cli; struct sockaddr_un un; socklen_t len =3D sizeof(un); =20 - fd =3D socket_listen(addr, 1, &error_abort); + /* Last one must connect, or else accept() below hangs */ + assert(test->expect_connect[ABSTRACT_SOCKET_VARIANTS - 1]); + + fd =3D socket_listen(test->server, 1, &error_abort); g_assert_cmpint(fd, >=3D, 0); g_assert(fd_is_socket(fd)); =20 cli =3D g_thread_new("abstract_unix_client", unix_client_thread_func, - addr); + test); =20 - connfd =3D accept(fd, (struct sockaddr *)&un, &len); - g_assert_cmpint(connfd, !=3D, -1); - close(connfd); + for (i =3D 0; i < ABSTRACT_SOCKET_VARIANTS; i++) { + if (test->expect_connect[i]) { + connfd =3D accept(fd, (struct sockaddr *)&un, &len); + g_assert_cmpint(connfd, !=3D, -1); + close(connfd); + } + } =20 close(fd); - g_thread_join(cli); } =20 -static void test_socket_unix_abstract_good(void) +static void test_socket_unix_abstract(void) { - SocketAddress addr; + SocketAddress addr, addr_tight, addr_padded; + abstract_socket_matrix_row matrix[ABSTRACT_SOCKET_VARIANTS] =3D { + { &addr, + { &addr_tight, &addr_padded, &addr }, + { false /* BUG */, true /* BUG */, true } }, + { &addr_tight, + { &addr_padded, &addr, &addr_tight }, + { false, false /* BUG */, true } }, + { &addr_padded, + { &addr, &addr_tight, &addr_padded }, + { true /* BUG */, false, true } } + }; + int i; =20 addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; addr.u.q_unix.path =3D g_strdup_printf("unix-%d-%u", getpid(), g_random_int()); addr.u.q_unix.has_abstract =3D true; addr.u.q_unix.abstract =3D true; - - /* non tight socklen serv and cli */ addr.u.q_unix.has_tight =3D false; addr.u.q_unix.tight =3D false; - test_socket_unix_abstract_one(&addr); =20 - /* tight socklen serv and cli */ - addr.u.q_unix.has_tight =3D true; - addr.u.q_unix.tight =3D true; - test_socket_unix_abstract_one(&addr); + addr_tight =3D addr; + addr_tight.u.q_unix.has_tight =3D true; + addr_tight.u.q_unix.tight =3D true; + + addr_padded =3D addr; + addr_padded.u.q_unix.has_tight =3D true; + addr_padded.u.q_unix.tight =3D false; + + for (i =3D 0; i < ABSTRACT_SOCKET_VARIANTS; i++) { + test_socket_unix_abstract_row(&matrix[i]); + } =20 g_free(addr.u.q_unix.path); } @@ -329,8 +369,8 @@ int main(int argc, char **argv) } =20 #ifdef __linux__ - g_test_add_func("/util/socket/unix-abstract/good", - test_socket_unix_abstract_good); + g_test_add_func("/util/socket/unix-abstract", + test_socket_unix_abstract); #endif =20 end: --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979204; cv=none; d=zohomail.com; s=zohoarc; b=VmPvwdC0PvKlMSSGk6SFAICvn5pi1EJZYSiVrp072Ntic5GC2A4zoMdJaBZ+HE20f26lWLCS05SJBe+lxmkz2Ox93i5mt4W8keIsYN1bWAZsofrbKHGq4ZsU2+8eRJM8v3wnuYowTeIseZn7Mt8DVAZbPUxkzE+HlsSCOhGf/C0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979204; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=apIX88BZzBufVjJ+xtCiEP6x1ttOWXyYdBbCiC51M3E=; b=bji6rKdqOwZ4FGjy66WG2CCS1wWCUxHasLYU2DItpHGzup2Sq1nhYzp69TAY6mlvYyj7g5utJ3VKPzMl3baEIo2A7T7lpTqf91BSOAS/MVTsZseX96YmsrBS5DnvMwpr5goUWH6Njrt2GJp6k1hbnjMG+fxv6PzLGHzNCuerzuU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603979204213185.3296118302544; Thu, 29 Oct 2020 06:46:44 -0700 (PDT) Received: from localhost ([::1]:58666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8GJ-0006iU-42 for importer@patchew.org; Thu, 29 Oct 2020 09:46:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88q-0005yt-4f for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:39:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88k-0008Ll-Cw for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-Siio049xMDu2CP8UhBKaiA-1; Thu, 29 Oct 2020 09:38:49 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E220D10E219E; Thu, 29 Oct 2020 13:38:48 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 794F35C1D0; Thu, 29 Oct 2020 13:38:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AC74E11329B3; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=apIX88BZzBufVjJ+xtCiEP6x1ttOWXyYdBbCiC51M3E=; b=SOffvLPDryE/V0X0C5Bx4m13fRrmDCgmobc5anIDmtDv5hGTIJxCHuYabL0w8EvZZWcUj0 u1bNai51km1Zw6AtfWckoNVjzzoZNz1mjnf2pJvxNqJPNPoFkEqIEzLSzqblBZ0mWhMdwC zbjSTDXO2GO5wieWKYxkyn1UshR81v8= X-MC-Unique: Siio049xMDu2CP8UhBKaiA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 07/11] sockets: Fix default of UnixSocketAddress member @tight Date: Thu, 29 Oct 2020 14:38:29 +0100 Message-Id: <20201029133833.3450220-8-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" QMP chardev-add defaults absent member @tight to false instead of true. HMP chardev-add and CLI -chardev correctly default to true. The previous commit demonstrated that socket_listen() and socket_connect() are broken for absent @tight. That explains why QMP is broken, but not why HMP and CLI work. We need to dig deeper. An optional bool member of a QAPI struct can be false, true, or absent. In C, we have: has_MEMBER MEMBER false true false true true false absent false false/ignore When has_MEMBER is false, MEMBER should be set to false on write, and ignored on read. unix_listen_saddr() and unix_connect_saddr() use member @tight without checking @has_tight. This is wrong. When @tight was set to false as it should be, absent @tight defaults to false. Wrong, it should default to true. This is what breaks QMP. There is one exception: qemu_chr_parse_socket() leaves @has_tight false when it sets @tight. Wrong, but the wrongs cancel out. This is why HMP and CLI work. Same for @has_abstract. Fix unix_listen_saddr() and unix_connect_saddr() to default absent @tight to true. Fix qemu_chr_parse_socket() to set @has_tight and @has_abstract. Fixes: 776b97d3605ed0fc94443048fdf988c7725e38a9 Reported-by: Kevin Wolf Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- chardev/char-socket.c | 2 ++ tests/test-util-sockets.c | 6 +++--- util/qemu-sockets.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 95e45812d5..1ee5a8c295 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -1439,7 +1439,9 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX; q_unix =3D addr->u.q_unix.data =3D g_new0(UnixSocketAddress, 1); q_unix->path =3D g_strdup(path); + q_unix->has_tight =3D true; q_unix->tight =3D tight; + q_unix->has_abstract =3D true; q_unix->abstract =3D abstract; } else if (host) { addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index f8b6586e70..7ecf95579b 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -294,13 +294,13 @@ static void test_socket_unix_abstract(void) abstract_socket_matrix_row matrix[ABSTRACT_SOCKET_VARIANTS] =3D { { &addr, { &addr_tight, &addr_padded, &addr }, - { false /* BUG */, true /* BUG */, true } }, + { true, false, true } }, { &addr_tight, { &addr_padded, &addr, &addr_tight }, - { false, false /* BUG */, true } }, + { false, true, true } }, { &addr_padded, { &addr, &addr_tight, &addr_padded }, - { true /* BUG */, false, true } } + { false, false, true } } }; int i; =20 diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 05e5c73f9d..c802d5aa0a 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -919,7 +919,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, if (saddr->abstract) { un.sun_path[0] =3D '\0'; memcpy(&un.sun_path[1], path, pathlen); - if (saddr->tight) { + if (!saddr->has_tight || saddr->tight) { addrlen =3D offsetof(struct sockaddr_un, sun_path) + 1 + pathl= en; } } else { @@ -979,7 +979,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr,= Error **errp) if (saddr->abstract) { un.sun_path[0] =3D '\0'; memcpy(&un.sun_path[1], saddr->path, pathlen); - if (saddr->tight) { + if (!saddr->has_tight || saddr->tight) { addrlen =3D offsetof(struct sockaddr_un, sun_path) + 1 + pathl= en; } } else { --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603978873; cv=none; d=zohomail.com; s=zohoarc; b=JzVjxCPCkC21BfvBk4ev0bX8Yw9g09gsdKoLR4VKjSfV4m22eqAU16IUIrMQDsPauk1HTapbi2QK0heO8zIjp7kGpYB5loYN/6oLTGWThVwjElzTsxXBIOrrIaEMsgNJYEE//ZE8hPN1Op6MT3tLS5lRQJ8VUDyjbS1Gno50rVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603978873; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2CcTRrLuVHym08uC7ic0BIJQGlah2N3jZECNEJQTcJg=; b=SCUXWT264X/zQvN64S5ralZPwTvADjzplEYD77H4xZncgxujteNC6AblALAaFhNcZ1UeIwj+2C3gDpGWEF15Y4wNhiYSD5oSA3Qcxjj6BHVmh506G/SKHj+XqfzJ4RHT3ZAdFFWIgau4mpCYQZTueo8lsnZHaGP7iwjCqEfl6TI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603978873541828.3808804697147; Thu, 29 Oct 2020 06:41:13 -0700 (PDT) Received: from localhost ([::1]:40702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8Ay-0007iR-G1 for importer@patchew.org; Thu, 29 Oct 2020 09:41:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88g-0005ss-Ui for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88e-0008JY-Gw for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-xJIP-wbdObaVZBS5_0qoJg-1; Thu, 29 Oct 2020 09:38:43 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B06641018F7A; Thu, 29 Oct 2020 13:38:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 740CB19930; Thu, 29 Oct 2020 13:38:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AF99511329BE; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2CcTRrLuVHym08uC7ic0BIJQGlah2N3jZECNEJQTcJg=; b=RDkpvHvvOcaUtKR9NvJUCru6G6f+MBjEvn3oFyGsKXJbolve7Bsp/AZ7CxNRszarTXb4z4 lb1lDGN/MkZrsxDTsgZCNQemuSHhvlVY2Q566LRFzTE6jNJIqTcDPE+3HwZ12QlkC4981p Cf9g7uhskn04d6ljSRhyHuJ50DBncD4= X-MC-Unique: xJIP-wbdObaVZBS5_0qoJg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 08/11] sockets: Fix socket_sockaddr_to_address_unix() for abstract sockets Date: Thu, 29 Oct 2020 14:38:30 +0100 Message-Id: <20201029133833.3450220-9-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Commit 776b97d360 "qemu-sockets: add abstract UNIX domain socket support" neglected to update socket_sockaddr_to_address_unix(). The function returns a non-abstract socket address for abstract sockets (wrong) with a null @path (also wrong; a non-optional QAPI str member must never be null). The null @path is due to confused code going back all the way to commit 17c55decec "sockets: add helpers for creating SocketAddress from a socket". Add the required special case, and simplify the confused code. Fixes: 776b97d3605ed0fc94443048fdf988c7725e38a9 Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini --- util/qemu-sockets.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index c802d5aa0a..801c5e3957 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1264,10 +1264,20 @@ socket_sockaddr_to_address_unix(struct sockaddr_sto= rage *sa, =20 addr =3D g_new0(SocketAddress, 1); addr->type =3D SOCKET_ADDRESS_TYPE_UNIX; - if (su->sun_path[0]) { - addr->u.q_unix.path =3D g_strndup(su->sun_path, sizeof(su->sun_pat= h)); +#ifdef CONFIG_LINUX + if (!su->sun_path[0]) { + /* Linux abstract socket */ + addr->u.q_unix.path =3D g_strndup(su->sun_path + 1, + sizeof(su->sun_path) - 1); + addr->u.q_unix.has_abstract =3D true; + addr->u.q_unix.abstract =3D true; + addr->u.q_unix.has_tight =3D true; + addr->u.q_unix.tight =3D !su->sun_path[sizeof(su->sun_path) - 1]; + return addr; } +#endif =20 + addr->u.q_unix.path =3D g_strdup(su->sun_path); return addr; } #endif /* WIN32 */ --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603978937; cv=none; d=zohomail.com; s=zohoarc; b=QWiHWyLCPWdE0OryhiG20rRQY2UCnivQ5Ln4MpM6KYaypotmKo/K536HOqme8wOtfup6/qL9yu9e+33YtZe/UnurAxTJh+zHR7hvdkPta6DxrEsJso9jeJb9Uau4tGMdHA2zah4rXpJVg1Ng34HBiItwTleNG7EGxUV3lsq/Dkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603978937; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0aaI62MqpCVlWiqfeRGUdxe9LfKHQujWNQ0NbrrtWK8=; b=Tgo2VVNeCFG3iENg6fzYVrBX7lSsyyaqFsBrtkt61Pd6tcwlpJRvCzufWG7WSvnFuGs/zgHWwTggtMTXYcNOcXpo1vzjyds386KyVMrVty3pT8HMBPDM2SCodtEqVd83aRrY8NZCl3hplYLHmKkmvtwL9vkxIa8O0sxb8qsHNtU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603978937432180.48203207596544; Thu, 29 Oct 2020 06:42:17 -0700 (PDT) Received: from localhost ([::1]:45248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8C0-000185-By for importer@patchew.org; Thu, 29 Oct 2020 09:42:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88f-0005qM-GP for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88c-0008JF-Om for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:38:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-_6pBecWGO52W8yGO31eumg-1; Thu, 29 Oct 2020 09:38:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 418826D584; Thu, 29 Oct 2020 13:38:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D8795D9EF; Thu, 29 Oct 2020 13:38:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B2CC21132922; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0aaI62MqpCVlWiqfeRGUdxe9LfKHQujWNQ0NbrrtWK8=; b=F9tPcrXx4hhnLs6FUv7kOnbkaJNObqv2DySXXI7BIty4C+RfwAWf+hdmk4/7PU0/VGjXL6 7pkXiWCVtw27OgEF9PwrCUDpB2zuNDyycThGwC35SRWmXQqNPbAOCW5D3sUHr68mHK2Pco h/654ozV06ZxXiymCMLXqCv+K+cJXxU= X-MC-Unique: _6pBecWGO52W8yGO31eumg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 09/11] char-socket: Fix qemu_chr_socket_address() for abstract sockets Date: Thu, 29 Oct 2020 14:38:31 +0100 Message-Id: <20201029133833.3450220-10-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Commit 776b97d360 "qemu-sockets: add abstract UNIX domain socket support" neglected to update qemu_chr_socket_address(). It shows shows neither @abstract nor @tight. Fix that. Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini --- chardev/char-socket.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 1ee5a8c295..dc1cf86ecf 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -443,10 +443,18 @@ static char *qemu_chr_socket_address(SocketChardev *s= , const char *prefix) s->is_listen ? ",server" : ""); break; case SOCKET_ADDRESS_TYPE_UNIX: - return g_strdup_printf("%sunix:%s%s", prefix, + { + UnixSocketAddress *sa =3D &s->addr->u.q_unix; + + return g_strdup_printf("%sunix:%s%s%s%s", prefix, s->addr->u.q_unix.path, + sa->has_abstract && sa->abstract + ? ",abstract" : "", + sa->has_tight && sa->tight + ? ",tight" : "", s->is_listen ? ",server" : ""); break; + } case SOCKET_ADDRESS_TYPE_FD: return g_strdup_printf("%sfd:%s%s", prefix, s->addr->u.fd.str, s->is_listen ? ",server" : ""); --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979254; cv=none; d=zohomail.com; s=zohoarc; b=Cmq34aRe9EyX25WD3bWBT4U/sLuY1x4D1JAhinW2Bpdp32HP7qEy+TYr0uNrZWSvqbrqw1aB/QxsFf2xzZFn4nK3q/aD6DTkBUn3Rixq+hxXJBV/VB29a92AZt3XY8nv+WCnTQOEG1r7UnyRB05V6FhawWkYGG8q4ofJsYq26vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979254; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/OY7QJGK3vdY037YYRIecs8AA+sXSLcI4y2LIdA4Gn8=; b=WKwec9F72W2GJLJxvP8unNlhEHYDpmwmzfsBDVtVm9r4m079TXleATFngWiPqyEPNc+LGlgTTFmkD/AK9UNe9FmBV6D3k40+dnTMjM5r7VWiILcca2ofilSm3csOmmq/xhXynbsSF7jYsYSJD5js9u+TlFIXRzuOwxI2Vn/lNjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603979254280722.1423229676514; Thu, 29 Oct 2020 06:47:34 -0700 (PDT) Received: from localhost ([::1]:60804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8H7-0007c6-7A for importer@patchew.org; Thu, 29 Oct 2020 09:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88r-00060B-Im for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:39:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88k-0008Ln-D0 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:39:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-BwRyBJJOP0GIp-vl4uyl9Q-1; Thu, 29 Oct 2020 09:38:49 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6623807321; Thu, 29 Oct 2020 13:38:48 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D9735B4A9; Thu, 29 Oct 2020 13:38:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B60A1113275D; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/OY7QJGK3vdY037YYRIecs8AA+sXSLcI4y2LIdA4Gn8=; b=AljFCpQvP5eWaCwctH9UYuiBWqjI2ail1CHS4aF/hNHibYDEcZNDTKmXuGOtlq74mWeIiL JzMNzTQGoq0ZLUPAzAUA34My3GeKO5t+icpYpc6cwCexc/laqNit+KCeFisJml4GRr+9Da ewXN2j7CXtX/lGfooGnbaiwv8Gsn44o= X-MC-Unique: BwRyBJJOP0GIp-vl4uyl9Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 10/11] sockets: Bypass "replace empty @path" for abstract unix sockets Date: Thu, 29 Oct 2020 14:38:32 +0100 Message-Id: <20201029133833.3450220-11-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" unix_listen_saddr() replaces empty @path by unique value. It obtains the value by creating and deleting a unique temporary file with mkstemp(). This is racy, as the comment explains. It's also entirely undocumented as far as I can tell. Goes back to commit d247d25f18 "sockets: helper functions for qemu (Gerd Hoffman)", v0.10.0. Since abstract socket addresses have no connection with filesystem pathnames, making them up with mkstemp() seems inappropriate. Bypass the replacement of empty @path. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- util/qemu-sockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 801c5e3957..18c8de8cdb 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -871,7 +871,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, return -1; } =20 - if (saddr->path && saddr->path[0]) { + if (saddr->path[0] || saddr->abstract) { path =3D saddr->path; } else { const char *tmpdir =3D getenv("TMPDIR"); --=20 2.26.2 From nobody Sat May 18 15:38:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603979317; cv=none; d=zohomail.com; s=zohoarc; b=Or9GElSfvYAxJf3vQqVhPgjwo9m1C1tX9r4/XR4DSy4bdd0cgm35CLE0zxck9SNxgx4da5ygphPPVKRlsRtjBd3y8RxVVAIw+oJB3qYAdvhU4UX9ttHAYzsCJBbnA5ZTm1zrGMNB4FeA82sryr+g1pHjm56Raba+aFjycaYp73o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603979317; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G21g2Urc6so8DNLpRRUN8vW/Mk8zrUm7vuyny65EQoY=; b=dP/jBDx9+x8C/+CqN3NPoFkR/bkXTrjnZ85QdyO6W4K/qHJehz+ymXJ3HGE9ZPVzqSr5ZP5ej6SOI+vELPkd6PncZ62NANycZvUEfbZMcxyOtghm4MXcSXieV3yKPjAD1qi1ytQTBLVWDBIzHxE3sqPEzCGa6yPJyycjpmWaLYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603979317742547.5877033490771; Thu, 29 Oct 2020 06:48:37 -0700 (PDT) Received: from localhost ([::1]:34752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY8I8-0008Ve-Ku for importer@patchew.org; Thu, 29 Oct 2020 09:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY88s-00062E-VF for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:39:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY88k-0008Lp-DP for qemu-devel@nongnu.org; Thu, 29 Oct 2020 09:39:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-gxi6Cz-FP_-3UbdPufrowg-1; Thu, 29 Oct 2020 09:38:50 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11738188C12E; Thu, 29 Oct 2020 13:38:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CFC455778; Thu, 29 Oct 2020 13:38:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BF00911326AE; Thu, 29 Oct 2020 14:38:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603978732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G21g2Urc6so8DNLpRRUN8vW/Mk8zrUm7vuyny65EQoY=; b=ejWjcSwmuGbnmJO/zfXYUM0+vmPkpCuUv1XcDAaR7yd/ub/vfw5d3scbWzLcpOtQ/4X+hR VqYWDxzE4hbbg/Wmlk9qKWr7daB3WkmudAzPJa6iJoAeM9FP5K3tQc+VeCo1jB5io77NpU AkE8sODyjLPDU2NsOmDRZKOXkzY/Zl4= X-MC-Unique: gxi6Cz-FP_-3UbdPufrowg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 11/11] sockets: Make abstract UnixSocketAddress depend on CONFIG_LINUX Date: Thu, 29 Oct 2020 14:38:33 +0100 Message-Id: <20201029133833.3450220-12-armbru@redhat.com> In-Reply-To: <20201029133833.3450220-1-armbru@redhat.com> References: <20201029133833.3450220-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 01:47:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berrange@redhat.com, zxq_yx_007@163.com, kraxel@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The abstract socket namespace is a non-portable Linux extension. An attempt to use it elsewhere should fail with ENOENT (the abstract address looks like a "" pathname, which does not resolve). We report this failure like Failed to connect socket abc: No such file or directory Tolerable, although ENOTSUP would be better. However, introspection lies: it has @abstract regardless of host support. Easy enough to fix: since Linux provides them since 2.2, 'if': 'defined(CONFIG_LINUX)' should do. The above failure becomes Parameter 'backend.data.addr.data.abstract' is unexpected I consider this an improvement. Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini --- qapi/sockets.json | 14 ++++++++------ chardev/char-socket.c | 10 ++++++++++ chardev/char.c | 2 ++ tests/test-util-sockets.c | 7 ++++--- util/qemu-sockets.c | 40 +++++++++++++++++++++++++++++---------- 5 files changed, 54 insertions(+), 19 deletions(-) diff --git a/qapi/sockets.json b/qapi/sockets.json index c0c640a5b0..db4019306a 100644 --- a/qapi/sockets.json +++ b/qapi/sockets.json @@ -74,18 +74,20 @@ # Captures a socket address in the local ("Unix socket") namespace. # # @path: filesystem path to use -# @tight: pass a socket address length confined to the minimum length of t= he -# abstract string, rather than the full sockaddr_un record length -# (only matters for abstract sockets, default true). (Since 5.1) -# @abstract: whether this is an abstract address, default false. (Since 5.= 1) +# @abstract: if true, this is a Linux abstract socket address. @path +# will be prefixed by a null byte, and optionally padded +# with null bytes. Defaults to false. (Since 5.1) +# @tight: if false, pad an abstract socket address with enough null +# bytes to make it fill struct sockaddr_un member sun_path. +# Defaults to true. (Since 5.1) # # Since: 1.3 ## { 'struct': 'UnixSocketAddress', 'data': { 'path': 'str', - '*tight': 'bool', - '*abstract': 'bool' } } + '*tight': { 'type': 'bool', 'if': 'defined(CONFIG_LINUX)' }, + '*abstract': { 'type': 'bool', 'if': 'defined(CONFIG_LINUX)' } } } =20 ## # @VsockSocketAddress: diff --git a/chardev/char-socket.c b/chardev/char-socket.c index dc1cf86ecf..1d2b2efb13 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -444,14 +444,20 @@ static char *qemu_chr_socket_address(SocketChardev *s= , const char *prefix) break; case SOCKET_ADDRESS_TYPE_UNIX: { +#ifdef CONFIG_LINUX UnixSocketAddress *sa =3D &s->addr->u.q_unix; +#endif =20 return g_strdup_printf("%sunix:%s%s%s%s", prefix, s->addr->u.q_unix.path, +#ifdef CONFIG_LINUX sa->has_abstract && sa->abstract ? ",abstract" : "", sa->has_tight && sa->tight ? ",tight" : "", +#else + "", "", +#endif s->is_listen ? ",server" : ""); break; } @@ -1394,8 +1400,10 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Ch= ardevBackend *backend, const char *host =3D qemu_opt_get(opts, "host"); const char *port =3D qemu_opt_get(opts, "port"); const char *fd =3D qemu_opt_get(opts, "fd"); +#ifdef CONFIG_LINUX bool tight =3D qemu_opt_get_bool(opts, "tight", true); bool abstract =3D qemu_opt_get_bool(opts, "abstract", false); +#endif SocketAddressLegacy *addr; ChardevSocket *sock; =20 @@ -1447,10 +1455,12 @@ static void qemu_chr_parse_socket(QemuOpts *opts, C= hardevBackend *backend, addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_UNIX; q_unix =3D addr->u.q_unix.data =3D g_new0(UnixSocketAddress, 1); q_unix->path =3D g_strdup(path); +#ifdef CONFIG_LINUX q_unix->has_tight =3D true; q_unix->tight =3D tight; q_unix->has_abstract =3D true; q_unix->abstract =3D abstract; +#endif } else if (host) { addr->type =3D SOCKET_ADDRESS_LEGACY_KIND_INET; addr->u.inet.data =3D g_new(InetSocketAddress, 1); diff --git a/chardev/char.c b/chardev/char.c index 78553125d3..aa4282164a 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -928,6 +928,7 @@ QemuOptsList qemu_chardev_opts =3D { },{ .name =3D "logappend", .type =3D QEMU_OPT_BOOL, +#ifdef CONFIG_LINUX },{ .name =3D "tight", .type =3D QEMU_OPT_BOOL, @@ -935,6 +936,7 @@ QemuOptsList qemu_chardev_opts =3D { },{ .name =3D "abstract", .type =3D QEMU_OPT_BOOL, +#endif }, { /* end of list */ } }, diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 7ecf95579b..67486055ed 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -229,7 +229,7 @@ static void test_socket_fd_pass_num_nocli(void) } #endif =20 -#ifdef __linux__ +#ifdef CONFIG_LINUX =20 #define ABSTRACT_SOCKET_VARIANTS 3 =20 @@ -326,7 +326,8 @@ static void test_socket_unix_abstract(void) =20 g_free(addr.u.q_unix.path); } -#endif + +#endif /* CONFIG_LINUX */ =20 int main(int argc, char **argv) { @@ -368,7 +369,7 @@ int main(int argc, char **argv) #endif } =20 -#ifdef __linux__ +#ifdef CONFIG_LINUX g_test_add_func("/util/socket/unix-abstract", test_socket_unix_abstract); #endif diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 18c8de8cdb..f8553976e6 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -854,10 +854,29 @@ static int vsock_parse(VsockSocketAddress *addr, cons= t char *str, =20 #ifndef _WIN32 =20 +static bool saddr_is_abstract(UnixSocketAddress *saddr) +{ +#ifdef CONFIG_LINUX + return saddr->abstract; +#else + return false; +#endif +} + +static bool saddr_is_tight(UnixSocketAddress *saddr) +{ +#ifdef CONFIG_LINUX + return !saddr->has_tight || saddr->tight; +#else + return false; +#endif +} + static int unix_listen_saddr(UnixSocketAddress *saddr, int num, Error **errp) { + bool abstract =3D saddr_is_abstract(saddr); struct sockaddr_un un; int sock, fd; char *pathbuf =3D NULL; @@ -871,7 +890,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, return -1; } =20 - if (saddr->path[0] || saddr->abstract) { + if (saddr->path[0] || abstract) { path =3D saddr->path; } else { const char *tmpdir =3D getenv("TMPDIR"); @@ -881,10 +900,10 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, =20 pathlen =3D strlen(path); if (pathlen > sizeof(un.sun_path) || - (saddr->abstract && pathlen > (sizeof(un.sun_path) - 1))) { + (abstract && pathlen > (sizeof(un.sun_path) - 1))) { error_setg(errp, "UNIX socket path '%s' is too long", path); error_append_hint(errp, "Path must be less than %zu bytes\n", - saddr->abstract ? sizeof(un.sun_path) - 1 : + abstract ? sizeof(un.sun_path) - 1 : sizeof(un.sun_path)); goto err; } @@ -906,7 +925,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, close(fd); } =20 - if (!saddr->abstract && unlink(path) < 0 && errno !=3D ENOENT) { + if (!abstract && unlink(path) < 0 && errno !=3D ENOENT) { error_setg_errno(errp, errno, "Failed to unlink socket %s", path); goto err; @@ -916,10 +935,10 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, un.sun_family =3D AF_UNIX; addrlen =3D sizeof(un); =20 - if (saddr->abstract) { + if (abstract) { un.sun_path[0] =3D '\0'; memcpy(&un.sun_path[1], path, pathlen); - if (!saddr->has_tight || saddr->tight) { + if (!saddr_is_tight(saddr)) { addrlen =3D offsetof(struct sockaddr_un, sun_path) + 1 + pathl= en; } } else { @@ -946,6 +965,7 @@ err: =20 static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) { + bool abstract =3D saddr_is_abstract(saddr); struct sockaddr_un un; int sock, rc; size_t pathlen; @@ -964,10 +984,10 @@ static int unix_connect_saddr(UnixSocketAddress *sadd= r, Error **errp) =20 pathlen =3D strlen(saddr->path); if (pathlen > sizeof(un.sun_path) || - (saddr->abstract && pathlen > (sizeof(un.sun_path) - 1))) { + (abstract && pathlen > (sizeof(un.sun_path) - 1))) { error_setg(errp, "UNIX socket path '%s' is too long", saddr->path); error_append_hint(errp, "Path must be less than %zu bytes\n", - saddr->abstract ? sizeof(un.sun_path) - 1 : + abstract ? sizeof(un.sun_path) - 1 : sizeof(un.sun_path)); goto err; } @@ -976,10 +996,10 @@ static int unix_connect_saddr(UnixSocketAddress *sadd= r, Error **errp) un.sun_family =3D AF_UNIX; addrlen =3D sizeof(un); =20 - if (saddr->abstract) { + if (abstract) { un.sun_path[0] =3D '\0'; memcpy(&un.sun_path[1], saddr->path, pathlen); - if (!saddr->has_tight || saddr->tight) { + if (!saddr_is_tight(saddr)) { addrlen =3D offsetof(struct sockaddr_un, sun_path) + 1 + pathl= en; } } else { --=20 2.26.2