[ovs-dev] [PATCH] odp-netlink.h: Autogenerate a version of odp-netlink for windows kernel.

Ankur Sharma ankursharma at vmware.com
Wed Aug 6 23:30:34 UTC 2014


odp-netlink.h: Autogenerate a version of odp-netlink for windows kernel.

Autogenerated odp-netlink.h will not compile with windows kernel, as
it refers to some userspace files like openvswitch/types.h and
packets.h which hyperv extension does not access. Due to this the
windows datapath compilation is broken on tip of tree. This patch
intends to fix that.

In this patch we add a new sed script "extract-odp-netlink-windows-h" 
to create odp-netlink-windows-dp.h. It works on similar lines as
extract-odp-netlink-h, but avoids including the header files
which are not available for driver.

Also, added saurabh's fix to not to include some header files
in lib/netlink-protocol.h not needed by windows driver.

After this fix, a userspace build will be needed before windows
kernel datapath can be built.

Tested that hyperv extension could be built after building
the userspace. Verified vxlan tunnel based ping across
hypervisors. Verified that odp-netlink-windows-dp.h is not
built for linux platform. Ran 'make distcheck' to verify that
nothing is broken on linux.

Signed-off-by: Ankur Sharma <ankursharma at vmware.com>
Co-authored-by: Saurabh Shah <ssaurabh at vmware.com>
Tested-by: Ankur Sharma <ankursharma at vmware.com>
Reported-by: Alin Serdean <aserdean at cloudbasesolutions.com>
Reported-by: Nithin Raju <nithin at vmware.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/21
---
 build-aux/extract-odp-netlink-windows-h | 24 ++++++++++++++++++++++++
 datapath-windows/ovsext/precomp.h       |  2 +-
 include/automake.mk                     | 16 ++++++++++++++++
 lib/netlink-protocol.h                  |  3 ++-
 4 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100755 build-aux/extract-odp-netlink-windows-h

diff --git a/build-aux/extract-odp-netlink-windows-h b/build-aux/extract-odp-netlink-windows-h
new file mode 100755
index 0000000..dbb2c98
--- /dev/null
+++ b/build-aux/extract-odp-netlink-windows-h
@@ -0,0 +1,24 @@
+# This is a "sed" script that transforms <linux/openvswitch.h> into a
+# form that is suitable for inclusion within the Open vSwitch tree on
+# windows system. The transformed header file can be included by windows
+# driver modules.
+
+# Add a header warning that this is a generated file.
+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_WINDOWS_DP_H/
+
+# and use the appropriate userspace header.
+s,<linux/types\.h>,"OvsTypes.h",
+
+# Add ETH_ADDR_LEN macro to avoid including userspace packet.h
+s,#include <linux/if_ether\.h>,\n#ifndef ETH_ADDR_LEN \
+#define ETH_ADDR_LEN  6 \n#endif,
+
+# Use OVS's own ETH_ADDR_LEN instead of Linux-specific ETH_ALEN.
+s/ETH_ALEN/ETH_ADDR_LEN/
diff --git a/datapath-windows/ovsext/precomp.h b/datapath-windows/ovsext/precomp.h
index 45e72de..4c81323 100644
--- a/datapath-windows/ovsext/precomp.h
+++ b/datapath-windows/ovsext/precomp.h
@@ -28,4 +28,4 @@
  * Include openvswitch.h from userspace. Changing the location the file from
  * include/linux is pending discussion.
  */
-#include "include\linux\openvswitch.h"
+#include "include\odp-netlink-windows-dp.h"
diff --git a/include/automake.mk b/include/automake.mk
index 55cb353..233eb52 100644
--- a/include/automake.mk
+++ b/include/automake.mk
@@ -1,9 +1,25 @@
 BUILT_SOURCES += include/odp-netlink.h
 
+if WIN32
+BUILT_SOURCES += include/odp-netlink-windows-dp.h
+endif
+
 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 < $< > $@
+
+if WIN32
+include/odp-netlink-windows-dp.h: datapath/linux/compat/include/linux/openvswitch.h \
+                                  build-aux/extract-odp-netlink-windows-h
+	sed -f $(srcdir)/build-aux/extract-odp-netlink-windows-h < $< > $@
+endif
+
 EXTRA_DIST += build-aux/extract-odp-netlink-h
+
+if WIN32
+EXTRA_DIST += build-aux/extract-odp-netlink-windows-h
+endif
+
 CLEANFILES += include/odp-netlink.h
 
 include include/openflow/automake.mk
diff --git a/lib/netlink-protocol.h b/lib/netlink-protocol.h
index 8938055..3ce18f0 100644
--- a/lib/netlink-protocol.h
+++ b/lib/netlink-protocol.h
@@ -28,10 +28,11 @@
  * regardless of platform.  On Linux, it includes the proper headers directly;
  * on other platforms it directly defines the structures and macros itself.
  */
-
+#ifndef OVS_WIN_DP
 #include <stdint.h>
 #include <sys/socket.h>
 #include "util.h"
+#endif
 
 #ifdef HAVE_NETLINK
 #include <linux/netlink.h>
-- 
1.9.1




More information about the dev mailing list