From patchwork Thu Jun 2 20:14:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9151179 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 04A8F60221 for ; Thu, 2 Jun 2016 20:35:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E991E28309 for ; Thu, 2 Jun 2016 20:35:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE43128326; Thu, 2 Jun 2016 20:35:50 +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 lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BF9228309 for ; Thu, 2 Jun 2016 20:35:50 +0000 (UTC) Received: from localhost ([::1]:50276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8ZLJ-0006Ql-Eg for patchwork-qemu-devel@patchwork.kernel.org; Thu, 02 Jun 2016 16:35:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Z13-0004yJ-3r for qemu-devel@nongnu.org; Thu, 02 Jun 2016 16:14:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8Z0x-0005bq-4J for qemu-devel@nongnu.org; Thu, 02 Jun 2016 16:14:51 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:62341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Z0w-0005bT-Pi for qemu-devel@nongnu.org; Thu, 02 Jun 2016 16:14:47 -0400 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MQ6Al-1b4y7D3flb-005Kbo; Thu, 02 Jun 2016 22:14:37 +0200 From: Laurent Vivier To: Riku Voipio Date: Thu, 2 Jun 2016 22:14:15 +0200 Message-Id: <1464898455-10082-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.5 X-Provags-ID: V03:K0:Qyk6tMrgYcx0bukOgCcM+48Q98i96W6bMqTtPLlaNwRELyFsckY avgUvT4eqO0Ovxp+RruQ9bJ0DCdRXm7m3JTG7UW6CjGmJLYfBQXsPGuIYLuU2pDFEf//LXU WOMbxhitIcJiASYnb1SUyMatysPLh4hdJ+xZnjLiDmYzuT7nhSY+s/9aHOeSonJtEKIQrwR x9089NgBi8zBWAWmaG6UA== X-UI-Out-Filterresults: notjunk:1; V01:K0:DfuuVYyGo8A=:SVGzGc3UKflwqVJiCG0ish VHuOlX2sy9AvgBPdOeiZ7ed4l02x18FzhDBss558rbmtwcIFpNOPSA6xwVpVt745Z+7oon7Nq y36/4uWeyzOaHLuL+dYX1tn4i3IZOZYdu/ro/L+eTa3ZqRcbJ3qVFtrWH+8ZfcMscOaVHwlv+ PzHKc7HKrm2dYbTec503eyXiC13y4aMelv4v6Qx3B5nzbb+yZ5kJmLKpxr8yi6GyqMxluE4MA i1/vhvBHXrTFD8alrjXYrXZfundHN4CHtdPj7Y0WL0MhE2g0aaDdcYYlFKTWigq7iTS0XFk7R 38Jmzwk+rQdJ0CiDv7mfs4s/lK33vNAZHYYhzKqkMZE4ITun3ljG7qExeal/nHKrgMUxpHIe+ yQ1Tdk7dcLKXc2RHY4wc4bVc3UUuoUuXEEdBix5Ki7szLXxaZYZTuv3LOjtxjTSCPNGNVWVP1 UBakw3XrnTj7Rinr7aJpq8SfCCPOC4xodKvVF0qJT8cL1qs/MOGMEeYvrEDNnXJ5jgdGmqHNg jm/pKHJ1RTLjr8DLjv/3GNRJTuLDqYFCI7thrnmYGlITX1VNLWKuzOJpxWQv39PB8qMZm0puU oxhiTWYNsCGPprSOp0ePm/2SrQn1Me2CY3XtxdfIUlgCZWN9MzW9fZ8mbzTefdUa9H0p0ewMW tW+2Eh4I0xRNd9eapDwwvr0ZcITRIPeXKxx12s3CsEWwG0MBS78WVU7IVLLpxWd0j+9w= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PATCH] linux-user: check if NETLINK_ROUTE is available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some IFLA_* symbols can be missing in the host linux/if_link.h, but as they are enums and not "#defines", check in "configure" if last known (IFLA_PROTO_DOWN) is available and if not, disable management of NETLINK_ROUTE protocol. Signed-off-by: Laurent Vivier --- Note: This patch must be applied on top of the series: [PATCH v2 0/3] linux-user: netlink support configure | 15 +++++++++++++++ linux-user/syscall.c | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/configure b/configure index b5aab72..294d791 100755 --- a/configure +++ b/configure @@ -4526,6 +4526,17 @@ if compile_prog "" "" ; then have_fsxattr=yes fi +have_rtnetlink=no +cat > $TMPC << EOF +#include +int main(void) { + return IFLA_PROTO_DOWN; +} +EOF +if compile_prog "" "" ; then + have_rtnetlink=yes +fi + ########################################## # End of CC checks # After here, no more $cc or $ld runs @@ -5461,6 +5472,10 @@ if test "$rdma" = "yes" ; then echo "CONFIG_RDMA=y" >> $config_host_mak fi +if test "$have_rtnetlink" = "yes" ; then + echo "CONFIG_RTNETLINK=y" >> $config_host_mak +fi + # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on # a thread we have a handle to diff --git a/linux-user/syscall.c b/linux-user/syscall.c index da48ba4..7c88d63 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -104,7 +104,9 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include "linux_loop.h" #include #include +#ifdef CONFIG_RTNETLINK #include +#endif #include #include "uname.h" @@ -1629,6 +1631,7 @@ static abi_long target_to_host_for_each_nlmsg(struct nlmsghdr *nlh, return 0; } +#ifdef CONFIG_RTNETLINK static abi_long host_to_target_for_each_rtattr(struct rtattr *rtattr, size_t len, abi_long (*host_to_target_rtattr) @@ -2043,6 +2046,7 @@ static abi_long target_to_host_nlmsg_route(struct nlmsghdr *nlh, size_t len) { return target_to_host_for_each_nlmsg(nlh, len, target_to_host_data_route); } +#endif /* CONFIG_RTNETLINK */ static abi_long host_to_target_data_audit(struct nlmsghdr *nlh) { @@ -2794,6 +2798,7 @@ static TargetFdTrans target_packet_trans = { .target_to_host_addr = packet_target_to_host_sockaddr, }; +#ifdef CONFIG_RTNETLINK static abi_long netlink_route_target_to_host(void *buf, size_t len) { return target_to_host_nlmsg_route(buf, len); @@ -2808,6 +2813,7 @@ static TargetFdTrans target_netlink_route_trans = { .target_to_host_data = netlink_route_target_to_host, .host_to_target_data = netlink_route_host_to_target, }; +#endif /* CONFIG_RTNETLINK */ static abi_long netlink_audit_target_to_host(void *buf, size_t len) { @@ -2835,10 +2841,12 @@ static abi_long do_socket(int domain, int type, int protocol) return ret; } - if (domain == PF_NETLINK && - !(protocol == NETLINK_ROUTE || - protocol == NETLINK_KOBJECT_UEVENT || - protocol == NETLINK_AUDIT)) { + if (domain == PF_NETLINK && !( +#ifdef CONFIG_RTNETLINK + protocol == NETLINK_ROUTE || +#endif + protocol == NETLINK_KOBJECT_UEVENT || + protocol == NETLINK_AUDIT)) { return -EPFNOSUPPORT; } @@ -2857,9 +2865,11 @@ static abi_long do_socket(int domain, int type, int protocol) fd_trans_register(ret, &target_packet_trans); } else if (domain == PF_NETLINK) { switch (protocol) { +#ifdef CONFIG_RTNETLINK case NETLINK_ROUTE: fd_trans_register(ret, &target_netlink_route_trans); break; +#endif case NETLINK_KOBJECT_UEVENT: /* nothing to do: messages are strings */ break;