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-dp-h"
to create OvsDpInterface.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 <ankursha...@vmware.com>
Co-authored-by: Saurabh Shah <ssaur...@vmware.com>
Tested-by: Ankur Sharma <ankursha...@vmware.com>
Reported-by: Alin Serdean <aserd...@cloudbasesolutions.com>
Reported-by: Nithin Raju <nit...@vmware.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/21

---
 .gitignore                                 |  2 ++
 Makefile.am                                |  1 +
 build-aux/extract-odp-netlink-windows-dp-h | 24 ++++++++++++++++++++++++
 datapath-windows/include/automake.mk       | 13 +++++++++++++
 datapath-windows/ovsext/precomp.h          |  2 +-
 lib/netlink-protocol.h                     |  2 ++
 6 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100755 build-aux/extract-odp-netlink-windows-dp-h
 create mode 100644 datapath-windows/include/automake.mk

diff --git a/.gitignore b/.gitignore
index 22ea3ec..800352c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,3 +60,5 @@ TAGS
 cscope.*
 tags
 _debian
+odp-netlink.h
+OvsDpInterface.h
diff --git a/Makefile.am b/Makefile.am
index eddacaf..eb58101 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -316,3 +316,4 @@ include python/compat/automake.mk
 include tutorial/automake.mk
 include vtep/automake.mk
 include datapath-windows/automake.mk
+include datapath-windows/include/automake.mk
diff --git a/build-aux/extract-odp-netlink-windows-dp-h 
b/build-aux/extract-odp-netlink-windows-dp-h
new file mode 100755
index 0000000..041d103
--- /dev/null
+++ b/build-aux/extract-odp-netlink-windows-dp-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/__OVS_DP_INTERFACE_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/include/automake.mk 
b/datapath-windows/include/automake.mk
new file mode 100644
index 0000000..bcd9d23
--- /dev/null
+++ b/datapath-windows/include/automake.mk
@@ -0,0 +1,13 @@
+if WIN32
+BUILT_SOURCES += $(srcdir)/datapath-windows/include/OvsDpInterface.h
+
+$(srcdir)/datapath-windows/include/OvsDpInterface.h: \
+         $(srcdir)/datapath/linux/compat/include/linux/openvswitch.h \
+         $(srcdir)/build-aux/extract-odp-netlink-windows-dp-h
+
+       sed -f $(srcdir)/build-aux/extract-odp-netlink-windows-dp-h < $< > $@
+
+EXTRA_DIST += $(srcdir)/build-aux/extract-odp-netlink-windows-dp-h
+
+CLEANFILES += $(srcdir)/datapath-windows/include/OvsDpInterface.h
+endif
diff --git a/datapath-windows/ovsext/precomp.h 
b/datapath-windows/ovsext/precomp.h
index 45e72de..ec4a621 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\OvsDpInterface.h"
diff --git a/lib/netlink-protocol.h b/lib/netlink-protocol.h
index 8938055..d4fb9bf 100644
--- a/lib/netlink-protocol.h
+++ b/lib/netlink-protocol.h
@@ -29,9 +29,11 @@
  * 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

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to