From patchwork Wed Jun 8 13:29:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9164671 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 3495960467 for ; Wed, 8 Jun 2016 13:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2832A20410 for ; Wed, 8 Jun 2016 13:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CDFA2824F; Wed, 8 Jun 2016 13:40:08 +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=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 5DBE928303 for ; Wed, 8 Jun 2016 13:40:05 +0000 (UTC) Received: from localhost ([::1]:57053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdiG-0004EF-C4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 09:40:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZA-00045N-Ps for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZ5-0005cx-Ed for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:39 -0400 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]:33571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZ4-0005cL-S8 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:35 -0400 Received: by mail-lf0-x230.google.com with SMTP id s64so5897036lfe.0 for ; Wed, 08 Jun 2016 06:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gWoEiRfBIYWT775YgKfc50Y5X+9L0E0t93/Fq1fjHxo=; b=LYmw/IMEQjLlM+FofLrZjpP9eOi28wGf/LhK1LG7bkkS5sxeO8NHh1rlifFEjRxOuR ppoTZP2Q3RT7j2WznaTl7z+MFBdlqPWmltVI+z1IF0MUB8u/oQgKQXc1JpFJ9ZWeO/0Q 82XvuClaG1Y3byH0PW7GVnEbDtKAPRea/PYVY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gWoEiRfBIYWT775YgKfc50Y5X+9L0E0t93/Fq1fjHxo=; b=WaXnRsfa22GYzjtRYTSOnkUNj9uWgioys/dbystr7DKE+kIOQDJh/E0lTMT3wBKJIS 2RE4mUCirLlPLwMc55eSHq7iz6zVGZ6LWx0efMsQGdxqv3BXdaZZUre/n1AeqFYahAO8 kjuCLVVzWv2vtdvgYJ+KMUrV/b/Ei0BaH6XrKD+9q+SGoEhHdtr4CgruOzPlS4c/fky+ cxlCGcsNYTytB8yZEM434eplp4rCigM2Xb8kcKpqIVkBK5P5G1tNbC1FvdIXjRsN12aO A+BGt8Bt9AZFXPJaJpcZAJAXcqnVdU/R6nsI6RQXLY7glWUqeW2FqLMeAa9VG0n35GSF QVeA== X-Gm-Message-State: ALyK8tJ6os7IIG27SahNVQNXdKNw6bqnQjkMnTis7IoFsCCVRaMcKTLSLlAUQcLJqJeMd2Vv X-Received: by 10.25.167.201 with SMTP id q192mr4877272lfe.59.1465392634056; Wed, 08 Jun 2016 06:30:34 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.30.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:30:33 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:29:46 +0300 Message-Id: <575b22b1b7a843f34f52ebc9c00fb1c967258912.1465392530.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::230 Subject: [Qemu-devel] [PULL 05/44] 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: Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Vivier 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 Signed-off-by: Riku Voipio --- configure | 15 +++++++++++++++ linux-user/syscall.c | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 6d01d96..d1dbc4b 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 933c2cd..9cc9a35 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -102,7 +102,9 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include #include +#ifdef CONFIG_RTNETLINK #include +#endif #include #include "linux_loop.h" #include "uname.h" @@ -1627,6 +1629,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) @@ -2041,6 +2044,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) { @@ -2730,6 +2734,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); @@ -2744,6 +2749,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) { @@ -2771,10 +2777,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; } @@ -2793,9 +2801,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;