[ovs-dev] [PATCH 2/5] Add NETLINK defines and remove padding for MSVC

Alin Serdean aserdean at cloudbasesolutions.com
Thu Jul 17 19:33:43 UTC 2014


For our kernel extension we do not take into consideration the padding
thus remove it.

Add MAX_LINKS define needed for nl_pool.

Add NETLINK_ROUTE needed to compile rtnetlink-link.

Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
 lib/netlink-protocol.h | 14 ++++++++++++++
 lib/netlink.c          |  4 ++++
 2 files changed, 18 insertions(+)

diff --git a/lib/netlink-protocol.h b/lib/netlink-protocol.h
index 88b7abf..56949bb 100644
--- a/lib/netlink-protocol.h
+++ b/lib/netlink-protocol.h
@@ -39,6 +39,7 @@
 
 #else
 #define NETLINK_GENERIC         16
+#define NETLINK_ROUTE           0
 
 /* nlmsg_flags bits. */
 #define NLM_F_REQUEST           0x001
@@ -48,7 +49,9 @@
 
 #define NLM_F_ROOT              0x100
 #define NLM_F_MATCH             0x200
+#define NLM_F_EXCL              0x200
 #define NLM_F_ATOMIC            0x400
+#define NLM_F_CREATE            0x400
 #define NLM_F_DUMP              (NLM_F_ROOT | NLM_F_MATCH)
 
 /* nlmsg_type values. */
@@ -59,6 +62,7 @@
 
 #define NLMSG_MIN_TYPE          0x10
 
+#define MAX_LINKS               32
 struct nlmsghdr {
     uint32_t nlmsg_len;
     uint16_t nlmsg_type;
@@ -68,8 +72,13 @@ struct nlmsghdr {
 };
 BUILD_ASSERT_DECL(sizeof(struct nlmsghdr) == 16);
 
+#ifdef _WIN32
+#define NLMSG_ALIGNTO 0
+#define NLMSG_ALIGN(SIZE) SIZE
+#else
 #define NLMSG_ALIGNTO 4
 #define NLMSG_ALIGN(SIZE) ROUND_UP(SIZE, NLMSG_ALIGNTO)
+#endif
 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
 
 struct nlmsgerr
@@ -94,8 +103,13 @@ struct nlattr {
 };
 BUILD_ASSERT_DECL(sizeof(struct nlattr) == 4);
 
+#ifdef _WIN32
+#define NLA_ALIGNTO 0
+#define NLA_ALIGN(SIZE) SIZE
+#else
 #define NLA_ALIGNTO 4
 #define NLA_ALIGN(SIZE) ROUND_UP(SIZE, NLA_ALIGNTO)
+#endif
 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
 
 #define GENL_MIN_ID     NLMSG_MIN_TYPE
diff --git a/lib/netlink.c b/lib/netlink.c
index 24b2168..c3d7ee2 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -174,7 +174,11 @@ nl_msg_put(struct ofpbuf *msg, const void *data, size_t size)
 void *
 nl_msg_put_uninit(struct ofpbuf *msg, size_t size)
 {
+#ifdef _WIN32
+    size_t pad = 0;
+#else
     size_t pad = PAD_SIZE(size, NLMSG_ALIGNTO);
+#endif
     char *p = ofpbuf_put_uninit(msg, size + pad);
     if (pad) {
         memset(p + size, 0, pad);
-- 
1.9.0.msysgit.0
 


More information about the dev mailing list