From patchwork Tue Apr 23 23:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1089833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44pg3y1LBsz9sBp for ; Wed, 24 Apr 2019 09:42:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 97902D13; Tue, 23 Apr 2019 23:42:49 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E6995CB0 for ; Tue, 23 Apr 2019 23:42:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0B96E829 for ; Tue, 23 Apr 2019 23:42:46 +0000 (UTC) X-Originating-IP: 66.170.99.95 Received: from sigill.benpfaff.org (unknown [66.170.99.95]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 5A718E0003; Tue, 23 Apr 2019 23:42:44 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 23 Apr 2019 16:42:32 -0700 Message-Id: <20190423234232.21799-1-blp@ovn.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] sparse: Configure target operating system and fix fallout. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org cgcc, the "sparse" wrapper that OVS uses, can be told the host architecture or the host OS or both. Until now, OVS has told it the host architecture because it is fairly common that it doesn't guess it automatically. Until now, OS has not told it the host OS, assuming that it would get it right. However, it doesn't--if you tell it the host OS or the host architecture, it doesn't really have a default for the other. This means that on Linux (presumably the only OS where sparse works properly for OVS), it was not defining __linux__, which caused some weird behavior. This commit adds a flag to the cgcc invocation to make it define __linux__ on Linux, and it fixes some errors that this would otherwise cause. Signed-off-by: Ben Pfaff Acked-by: Ilya Maximets --- acinclude.m4 | 6 +++--- include/sparse/automake.mk | 1 + include/sparse/linux/if_packet.h | 30 ++++++++++++++++++++++++++++++ lib/perf-counter.c | 4 ++-- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 include/sparse/linux/if_packet.h diff --git a/acinclude.m4 b/acinclude.m4 index 1607d5f4b1d9..301aeb70d82a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,6 +1,6 @@ # -*- autoconf -*- -# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc. +# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019 Nicira, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1107,8 +1107,8 @@ AC_DEFUN([OVS_CHECK_SPARSE_TARGET], [x86_64-*], [ac_cv_sparse_target=x86_64], [ac_cv_sparse_target=other])]) AS_CASE([$ac_cv_sparse_target], - [x86], [SPARSEFLAGS= CGCCFLAGS=-target=i86], - [x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS=-target=x86_64], + [x86], [SPARSEFLAGS= CGCCFLAGS="-target=i86 -target=host_os_specs"], + [x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS="-target=x86_64 -target=host_os_specs"], [SPARSEFLAGS= CGCCFLAGS=]) AC_SUBST([SPARSEFLAGS]) AC_SUBST([CGCCFLAGS])]) diff --git a/include/sparse/automake.mk b/include/sparse/automake.mk index 4c7b17783fd5..8d96d0346f48 100644 --- a/include/sparse/automake.mk +++ b/include/sparse/automake.mk @@ -27,4 +27,5 @@ noinst_HEADERS += \ include/sparse/sys/types.h \ include/sparse/sys/wait.h \ include/sparse/threads.h \ + include/sparse/linux/if_packet.h \ include/sparse/linux/tc_act/tc_pedit.h diff --git a/include/sparse/linux/if_packet.h b/include/sparse/linux/if_packet.h new file mode 100644 index 000000000000..eab1be9d247d --- /dev/null +++ b/include/sparse/linux/if_packet.h @@ -0,0 +1,30 @@ +#ifndef FIX_LINUX_IF_PACKET_H +#define FIX_LINUX_IF_PACKET_H + +#ifndef __CHECKER__ +#error "Use this header only with sparse. It is not a correct implementation." +#endif + +#include_next + +/* Fix endianness of 'spkt_protocol' and 'sll_protocol' members. */ + +#define sockaddr_pkt rpl_sockaddr_pkt +struct sockaddr_pkt { + unsigned short spkt_family; + unsigned char spkt_device[14]; + ovs_be16 spkt_protocol; +}; + +#define sockaddr_ll rpl_sockaddr_ll +struct sockaddr_ll { + unsigned short sll_family; + ovs_be16 sll_protocol; + int sll_ifindex; + unsigned short sll_hatype; + unsigned char sll_pkttype; + unsigned char sll_halen; + unsigned char sll_addr[8]; +}; + +#endif diff --git a/lib/perf-counter.c b/lib/perf-counter.c index c4458d2f5fa9..402fabe1775b 100644 --- a/lib/perf-counter.c +++ b/lib/perf-counter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Nicira, Inc. + * Copyright (c) 2015, 2016, 2019 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ /* This implementation only applies to the Linux platform. */ #include -#if defined(__linux__) && defined(HAVE_LINUX_PERF_EVENT_H) +#if defined(__linux__) && defined(HAVE_LINUX_PERF_EVENT_H) && !__CHECKER__ #include #include