datapath: Add compat support for nla_type().
authorBen Pfaff <blp@nicira.com>
Fri, 10 Dec 2010 22:42:17 +0000 (14:42 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 13 Dec 2010 18:20:29 +0000 (10:20 -0800)
The datapath code uses nla_type() but it was only introduced in 2.6.24.

The NLA_TYPE_MASK definition has to go above the #include <net/netlink.h>
because <net/netlink.h> recursively #include <linux/netlink.h>.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath/linux-2.6/compat-2.6/include/linux/netlink.h
datapath/linux-2.6/compat-2.6/include/net/netlink.h

index fba899e..1666097 100644 (file)
@@ -3,8 +3,14 @@
 
 #include <linux/skbuff.h>
 #include_next <linux/netlink.h>
-#include <net/netlink.h>
 
+#ifndef NLA_TYPE_MASK
+#define NLA_F_NESTED           (1 << 15)
+#define NLA_F_NET_BYTEORDER    (1 << 14)
+#define NLA_TYPE_MASK          ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
+#endif
+
+#include <net/netlink.h>
 #include <linux/version.h>
 
 #ifndef NLMSG_DEFAULT_SIZE
index 2f979fe..c6f5e04 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __NET_NETLINK_WRAPPER_H
 #define __NET_NETLINK_WRAPPER_H 1
 
+#include <linux/version.h>
 #include_next <net/netlink.h>
 
 #ifndef HAVE_NLA_NUL_STRING
@@ -37,4 +38,16 @@ static inline __be16 nla_get_be16(struct nlattr *nla)
 }
 #endif  /* !HAVE_NLA_GET_BE16 */
 
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+/**
+ * nla_type - attribute type
+ * @nla: netlink attribute
+ */
+static inline int nla_type(const struct nlattr *nla)
+{
+        return nla->nla_type & NLA_TYPE_MASK;
+}
+#endif
+
 #endif /* net/netlink.h */