From patchwork Wed Sep 13 10:26:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9950913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9BB1F60360 for ; Wed, 13 Sep 2017 10:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C8A922299 for ; Wed, 13 Sep 2017 10:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 808FB223A5; Wed, 13 Sep 2017 10:27:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECD80223A0 for ; Wed, 13 Sep 2017 10:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751875AbdIMK1J (ORCPT ); Wed, 13 Sep 2017 06:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751661AbdIMK1I (ORCPT ); Wed, 13 Sep 2017 06:27:08 -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 mx1.redhat.com (Postfix) with ESMTPS id 86D2481DFF; Wed, 13 Sep 2017 10:27:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 86D2481DFF Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com Received: from localhost (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B0D860BEC; Wed, 13 Sep 2017 10:27:05 +0000 (UTC) From: Stefan Hajnoczi To: linux-nfs@vger.kernel.org Cc: NeilBrown , Matt Benjamin , Jeff Layton , "J . Bruce Fields" , Chuck Lever , Steve Dickson , Stefan Hajnoczi , Jorgen Hansen Subject: [PATCH nfs-utils v3 02/14] nfs-utils: add vsock.h Date: Wed, 13 Sep 2017 11:26:38 +0100 Message-Id: <20170913102650.10377-3-stefanha@redhat.com> In-Reply-To: <20170913102650.10377-1-stefanha@redhat.com> References: <20170913102650.10377-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 13 Sep 2017 10:27:08 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP AF_VSOCK has been in Linux since 2013 but nfs-utils should compile cleanly on systems that lack this feature or have incomplete header files (see vsock.h file in this patch for details). This patch allows code to #include "vsock.h" to use AF_VSOCK and struct sockaddr_vm without #ifdefs. Cc: Jorgen Hansen Signed-off-by: Stefan Hajnoczi --- Jorgen: The header file in linux.git is GPLv2-only licensed. nfs-utils is GPLv2-or-later. The only authors of the Linux header file are @vmware.com. Could you please post a GPLv2-or-later version of this file? Thanks! --- support/include/vsock.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 3 +++ 2 files changed, 62 insertions(+) create mode 100644 support/include/vsock.h diff --git a/support/include/vsock.h b/support/include/vsock.h new file mode 100644 index 0000000..8d1bb79 --- /dev/null +++ b/support/include/vsock.h @@ -0,0 +1,59 @@ +/* + * AF_VSOCK constants and struct definitions + * + * Copyright (C) 2007-2013 VMware, Inc. All rights reserved. + * Copyright (C) 2017 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef _VSOCK_H +#define _VSOCK_H + +/* + * This header includes the vsock system headers. Distros have been known to + * ship with: + * 1. vsock-capable kernels but no AF_VSOCK constant + * 2. AF_VSOCK but no + * + * Define constants and structs ourselves, if necessary. This avoids #ifdefs + * in many places throughout the code. If the kernel really does not support + * AF_VSOCK then socket(2) returns an EAFNOSUPPORT errno. + */ + +#include + +#ifndef AF_VSOCK +#define AF_VSOCK 40 +#endif + +#ifdef HAVE_LINUX_VM_SOCKETS_H +#include +#else /* !HAVE_LINUX_VM_SOCKETS_H */ + +#define VMADDR_CID_ANY (-1U) + +struct sockaddr_vm +{ + sa_family_t svm_family; + unsigned short svm_reserved1; + unsigned int svm_port; + unsigned int svm_cid; + unsigned char svm_zero[sizeof(struct sockaddr) - + sizeof(sa_family_t) - + sizeof(unsigned short) - + sizeof(unsigned int) - sizeof(unsigned int)]; +}; + +#define IOCTL_VM_SOCKETS_GET_LOCAL_CID _IO(7, 0xb9) + +#endif /* !HAVE_LINUX_VM_SOCKETS_H */ + +#endif /* !_VSOCK_H */ diff --git a/configure.ac b/configure.ac index 1ca1603..7d82d37 100644 --- a/configure.ac +++ b/configure.ac @@ -410,6 +410,9 @@ fi dnl Check for IPv6 support AC_IPV6 +dnl Check for AF_VSOCK support +AC_CHECK_HEADERS([linux/vm_sockets.h], , , [#include ]) + dnl ************************************************************* dnl Check for headers dnl *************************************************************