summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2014-08-04 11:11:40 -0700
committerBen Pfaff <blp@nicira.com>2014-08-04 11:11:40 -0700
commit837eefc76b3c79bb790a4c4c2d0a314d81b71a28 (patch)
treea1f69472e0cf641513506ac54eae1815e0ff0aa5
parentfa6395df71913c749f104978a736f238fb20bc08 (diff)
downloadopenvswitch-837eefc76b3c79bb790a4c4c2d0a314d81b71a28.tar.gz
Do not seemingly #include Linux-specific headers on other platforms.
Until now, the OVS source tree has had a whole maze of header files that make "#include <linux/openvswitch.h>" work OK regardless of platform, but this confuses everyone new to the tree, at first glance, and is difficult to understand at second glance too. This commit renames include/linux/openvswitch.h to datapath/linux/compat/include/linux/openvswitch.h without other change, then modifies the userspace build to generate a header that makes sense in portable Open vSwitch userspace from that header. It then removes all the remaining include/linux/* files since they are now unused. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
-rw-r--r--Makefile.am1
-rwxr-xr-xbuild-aux/extract-odp-netlink-h31
-rw-r--r--datapath/linux/Modules.mk1
-rw-r--r--datapath/linux/compat/include/linux/openvswitch.h (renamed from include/linux/openvswitch.h)0
-rw-r--r--debian/copyright.in2
-rw-r--r--include/automake.mk9
-rw-r--r--include/linux/automake.mk4
-rw-r--r--include/linux/if_ether.h31
-rw-r--r--include/linux/types.h58
-rw-r--r--include/openvswitch/types.h15
-rw-r--r--lib/dpif-linux.h4
-rw-r--r--lib/dpif.h7
-rw-r--r--lib/odp-execute.c2
-rw-r--r--lib/odp-util.h2
14 files changed, 54 insertions, 113 deletions
diff --git a/Makefile.am b/Makefile.am
index f62198bca..eddacafd4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,7 @@ AM_LDFLAGS += $(PTHREAD_LDFLAGS)
endif
AM_CPPFLAGS += -I $(top_srcdir)/include
+AM_CPPFLAGS += -I $(top_builddir)/include
AM_CPPFLAGS += -I $(top_srcdir)/lib
AM_CPPFLAGS += -I $(top_builddir)/lib
diff --git a/build-aux/extract-odp-netlink-h b/build-aux/extract-odp-netlink-h
new file mode 100755
index 000000000..c61a1b73a
--- /dev/null
+++ b/build-aux/extract-odp-netlink-h
@@ -0,0 +1,31 @@
+# This is a "sed" script that transforms <linux/openvswitch.h> into a
+# form that is suitable for inclusion within the Open vSwitch tree on
+# both Linux and non-Linux systems.
+
+# Add a header warning that this is a generated file. It might save somebody
+# some frustration (maybe even me!).
+1i\
+/* -*- mode: c; buffer-read-only: t -*- */\
+/* Generated automatically from <linux/openvswitch.h> -- do not modify! */\
+\
+\
+
+
+# Avoid using reserved names in header guards.
+s/_LINUX_OPENVSWITCH_H/ODP_NETLINK_H/
+
+# Transform Linux-specific __u<N> types into C99 uint<N>_t types,
+# and Linux-specific __be<N> into Open vSwitch ovs_be<N>,
+# and use the appropriate userspace header.
+s,<linux/types\.h>,"openvswitch/types.h",
+s/__u64/uint64_t/g
+s/__u32/uint32_t/g
+s/__u16/uint16_t/g
+s/__u8/uint8_t/g
+s/__be64/ovs_be64/g
+s/__be32/ovs_be32/g
+s/__be16/ovs_be16/g
+
+# Use OVS's own ETH_ADDR_LEN instead of Linux-specific ETH_ALEN.
+s,<linux/if_ether\.h>,"packets.h",
+s/ETH_ALEN/ETH_ADDR_LEN/
diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
index 46aa1f675..0b9fffa6f 100644
--- a/datapath/linux/Modules.mk
+++ b/datapath/linux/Modules.mk
@@ -46,6 +46,7 @@ openvswitch_headers += \
linux/compat/include/linux/netdevice.h \
linux/compat/include/linux/netdev_features.h \
linux/compat/include/linux/netlink.h \
+ linux/compat/include/linux/openvswitch.h \
linux/compat/include/linux/poison.h \
linux/compat/include/linux/rculist.h \
linux/compat/include/linux/rcupdate.h \
diff --git a/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h
index 271a14ebf..271a14ebf 100644
--- a/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
diff --git a/debian/copyright.in b/debian/copyright.in
index 89cd2d216..811a378f3 100644
--- a/debian/copyright.in
+++ b/debian/copyright.in
@@ -95,7 +95,7 @@ License:
* The following components are dual-licensed under the
GNU General Public License version 2 and the Apache License Version 2.0.
- include/linux/openvswitch.h
+ datapath/linux/compat/include/linux/openvswitch.h
On Debian systems, the complete text of the GNU General Public License
version 2 can be found in `/usr/share/common-licenses/GPL-2'.
diff --git a/include/automake.mk b/include/automake.mk
index 37a6f77af..55cb353ac 100644
--- a/include/automake.mk
+++ b/include/automake.mk
@@ -1,4 +1,11 @@
-include include/linux/automake.mk
+BUILT_SOURCES += include/odp-netlink.h
+
+include/odp-netlink.h: datapath/linux/compat/include/linux/openvswitch.h \
+ build-aux/extract-odp-netlink-h
+ sed -f $(srcdir)/build-aux/extract-odp-netlink-h < $< > $@
+EXTRA_DIST += build-aux/extract-odp-netlink-h
+CLEANFILES += include/odp-netlink.h
+
include include/openflow/automake.mk
include include/openvswitch/automake.mk
include include/sparse/automake.mk
diff --git a/include/linux/automake.mk b/include/linux/automake.mk
deleted file mode 100644
index 6ca0e4017..000000000
--- a/include/linux/automake.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-noinst_HEADERS += \
- include/linux/if_ether.h \
- include/linux/openvswitch.h \
- include/linux/types.h
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
deleted file mode 100644
index a3cc9bc44..000000000
--- a/include/linux/if_ether.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2013 Nicira, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LINUX_IF_ETHER_H
-#define LINUX_IF_ETHER_H 1
-
-/* On Linux, this header file just includes <linux/if_ether.h>.
- *
- * On other platforms, this header file implements just enough of
- * <linux/if_ether.h> to allow <linux/openvswitch.h> to work. */
-
-#if defined(HAVE_LINUX_IF_ETHER_H) || defined(__KERNEL__)
-#include_next <linux/if_ether.h>
-#else /* no <linux/if_ether.h> */
-#define ETH_ALEN 6 /* Octets in one ethernet addr */
-#endif
-
-#endif /* <linux/if_ether.h> */
diff --git a/include/linux/types.h b/include/linux/types.h
deleted file mode 100644
index 5438a430d..000000000
--- a/include/linux/types.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2011, 2014 Nicira, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LINUX_TYPES_H
-#define LINUX_TYPES_H 1
-
-/* On Linux, this header file just includes <linux/types.h>.
- *
- * On other platforms, this header file implements just enough of
- * <linux/types.h> to allow <linux/openvswitch.h> to work, that is, it defines
- * the __u<N> and __be<N> types. */
-
-#ifdef __KERNEL__
-#include_next <linux/types.h>
-#elif defined(HAVE_LINUX_TYPES_H)
-/* With some combinations of kernel and userspace headers, including both
- * <sys/types.h> and <linux/types.h> only works if you do so in that order, so
- * force it. */
-
-#ifdef __CHECKER__
-#define __CHECK_ENDIAN__
-#endif
-
-#include <sys/types.h>
-#include_next <linux/types.h>
-#else /* no <linux/types.h> */
-#include <stdint.h>
-
-#ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
-#else
-#define __bitwise__
-#endif
-
-typedef uint8_t __u8;
-typedef uint16_t __u16;
-typedef uint32_t __u32;
-typedef uint64_t __u64;
-
-typedef uint16_t __bitwise__ __be16;
-typedef uint32_t __bitwise__ __be32;
-typedef uint64_t __bitwise__ __be64;
-#endif /* no <linux/types.h> */
-
-#endif /* <linux/types.h> */
diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
index d9a5dc883..54541a42b 100644
--- a/include/openvswitch/types.h
+++ b/include/openvswitch/types.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, 2013 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2013, 2014 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,6 @@
#ifndef OPENVSWITCH_TYPES_H
#define OPENVSWITCH_TYPES_H 1
-#include <linux/types.h>
#include <sys/types.h>
#include <stdint.h>
@@ -30,14 +29,10 @@
#endif
/* The ovs_be<N> types indicate that an object is in big-endian, not
- * native-endian, byte order. They are otherwise equivalent to uint<N>_t.
- *
- * We bootstrap these from the Linux __be<N> types. If we instead define our
- * own independently then __be<N> and ovs_be<N> become mutually
- * incompatible. */
-typedef __be16 ovs_be16;
-typedef __be32 ovs_be32;
-typedef __be64 ovs_be64;
+ * native-endian, byte order. They are otherwise equivalent to uint<N>_t. */
+typedef uint16_t OVS_BITWISE ovs_be16;
+typedef uint32_t OVS_BITWISE ovs_be32;
+typedef uint64_t OVS_BITWISE ovs_be64;
#define OVS_BE16_MAX ((OVS_FORCE ovs_be16) 0xffff)
#define OVS_BE32_MAX ((OVS_FORCE ovs_be32) 0xffffffff)
diff --git a/lib/dpif-linux.h b/lib/dpif-linux.h
index 21d00484f..a35826c8e 100644
--- a/lib/dpif-linux.h
+++ b/lib/dpif-linux.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <linux/openvswitch.h>
+#include "odp-netlink.h"
#include "flow.h"
diff --git a/lib/dpif.h b/lib/dpif.h
index 8d8e43a26..f4a2a9e87 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -115,7 +115,7 @@
* a flow, but the datapath interface uses a different data format to
* allow ABI forward- and backward-compatibility. datapath/README
* describes the rationale and design. Refer to OVS_KEY_ATTR_* and
- * "struct ovs_key_*" in include/linux/openvswitch.h for details.
+ * "struct ovs_key_*" in include/odp-netlink.h for details.
* lib/odp-util.h defines several functions for working with these flows.
*
* - A "mask" that, for each bit in the flow, specifies whether the datapath
@@ -154,9 +154,8 @@
* within a flow. Some examples of actions are OVS_ACTION_ATTR_OUTPUT,
* which transmits the packet out a port, and OVS_ACTION_ATTR_SET, which
* modifies packet headers. Refer to OVS_ACTION_ATTR_* and "struct
- * ovs_action_*" in include/linux/openvswitch.h for details.
- * lib/odp-util.h defines several functions for working with datapath
- * actions.
+ * ovs_action_*" in include/odp-netlink.h for details. lib/odp-util.h
+ * defines several functions for working with datapath actions.
*
* The actions list may be empty. This indicates that nothing should be
* done to matching packets, that is, they should be dropped.
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index cb89e72fa..e1e9b5718 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -17,13 +17,13 @@
#include <config.h>
#include "odp-execute.h"
-#include <linux/openvswitch.h>
#include <stdlib.h>
#include <string.h>
#include "dpif.h"
#include "netlink.h"
#include "ofpbuf.h"
+#include "odp-netlink.h"
#include "odp-util.h"
#include "packet-dpif.h"
#include "packets.h"
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 4ce693c7e..82ab06d22 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -21,10 +21,10 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
-#include <linux/openvswitch.h>
#include "flow.h"
#include "hash.h"
#include "hmap.h"
+#include "odp-netlink.h"
#include "openflow/openflow.h"
#include "util.h"