From patchwork Tue Sep 12 16:34:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 812964 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xs9PG31ZNz9s7g for ; Wed, 13 Sep 2017 02:34:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751480AbdILQek (ORCPT ); Tue, 12 Sep 2017 12:34:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44474 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054AbdILQei (ORCPT ); Tue, 12 Sep 2017 12:34:38 -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 mx1.redhat.com (Postfix) with ESMTPS id C7D4912B1; Tue, 12 Sep 2017 16:34:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C7D4912B1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com Received: from localhost (ovpn-117-246.ams2.redhat.com [10.36.117.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83A825F910; Tue, 12 Sep 2017 16:34:36 +0000 (UTC) From: Stefan Hajnoczi To: netdev@vger.kernel.org Cc: "David S . Miller" , Jorgen Hansen , Stefan Hajnoczi Subject: [PATCH] VSOCK: fix uapi/linux/vm_sockets.h incomplete types Date: Tue, 12 Sep 2017 17:34:35 +0100 Message-Id: <20170912163435.4049-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 12 Sep 2017 16:34:38 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fixes the following compiler errors when userspace applications use the vm_sockets.h header: include/uapi/linux/vm_sockets.h:148:32: error: invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’ unsigned char svm_zero[sizeof(struct sockaddr) - ^~~~~~ include/uapi/linux/vm_sockets.h:149:18: error: ‘sa_family_t’ undeclared here (not in a function) sizeof(sa_family_t) - ^~~~~~~~~~~ Two issues: 1. In the kernel struct sockaddr comes in via but in userspace is required. 2. struct sockaddr_vm has a __kernel_sa_family_t field so let's be consistent and use the same type for the sizeof(sa_family_t) calculation. Currently userspace applications work around this broken header by first including . In the kernel there is no compiler error because provides everything. It's worth fixing the header file though. Cc: Jorgen Hansen Signed-off-by: Stefan Hajnoczi Reviewed-by: Jorgen Hansen --- include/uapi/linux/vm_sockets.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/vm_sockets.h b/include/uapi/linux/vm_sockets.h index b4ed5d895699..4ae5c625ac56 100644 --- a/include/uapi/linux/vm_sockets.h +++ b/include/uapi/linux/vm_sockets.h @@ -18,6 +18,10 @@ #include +#ifndef __KERNEL__ +#include /* struct sockaddr */ +#endif + /* Option name for STREAM socket buffer size. Use as the option name in * setsockopt(3) or getsockopt(3) to set or get an unsigned long long that * specifies the size of the buffer underlying a vSockets STREAM socket. @@ -146,7 +150,7 @@ struct sockaddr_vm { unsigned int svm_port; unsigned int svm_cid; unsigned char svm_zero[sizeof(struct sockaddr) - - sizeof(sa_family_t) - + sizeof(__kernel_sa_family_t) - sizeof(unsigned short) - sizeof(unsigned int) - sizeof(unsigned int)]; };