datapath: Account for RHEL6.4 backports in compat layer
[sliver-openvswitch.git] / datapath / linux / compat / include / net / netlink.h
index 10558b0..308cd69 100644 (file)
@@ -7,9 +7,9 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
 /* Before v2.6.29, a NLA_NESTED attribute, if it was present, was not allowed
  * to be empty.  However, OVS depends on the ability to accept empty
- * attributes.  For example, a present but empty ODP_FLOW_ATTR_ACTIONS on
- * ODP_FLOW_CMD_SET replaces the existing set of actions by an empty "drop"
- * action, whereas a missing ODP_FLOW_ATTR_ACTIONS leaves the existing
+ * attributes.  For example, a present but empty OVS_FLOW_ATTR_ACTIONS on
+ * OVS_FLOW_CMD_SET replaces the existing set of actions by an empty "drop"
+ * action, whereas a missing OVS_FLOW_ATTR_ACTIONS leaves the existing
  * actions, if any, unchanged.
  *
  * NLA_NESTED is different from NLA_UNSPEC in only two ways:
 #define NLA_NESTED NLA_UNSPEC
 #endif
 
-#ifndef NLA_PUT_BE16
-#define NLA_PUT_BE16(skb, attrtype, value) \
-        NLA_PUT_TYPE(skb, __be16, attrtype, value)
-#endif  /* !NLA_PUT_BE16 */
-
-#ifndef NLA_PUT_BE32
-#define NLA_PUT_BE32(skb, attrtype, value) \
-        NLA_PUT_TYPE(skb, __be32, attrtype, value)
-#endif  /* !NLA_PUT_BE32 */
-
-#ifndef NLA_PUT_BE64
-#define NLA_PUT_BE64(skb, attrtype, value) \
-        NLA_PUT_TYPE(skb, __be64, attrtype, value)
-#endif  /* !NLA_PUT_BE64 */
-
 #ifndef HAVE_NLA_GET_BE16
 /**
  * nla_get_be16 - return payload of __be16 attribute
@@ -51,7 +36,7 @@
  */
 static inline __be16 nla_get_be16(const struct nlattr *nla)
 {
-        return *(__be16 *) nla_data(nla);
+       return *(__be16 *) nla_data(nla);
 }
 #endif  /* !HAVE_NLA_GET_BE16 */
 
@@ -62,7 +47,7 @@ static inline __be16 nla_get_be16(const struct nlattr *nla)
  */
 static inline __be32 nla_get_be32(const struct nlattr *nla)
 {
-        return *(__be32 *) nla_data(nla);
+       return *(__be32 *) nla_data(nla);
 }
 #endif
 
@@ -91,12 +76,33 @@ static inline __be32 nla_get_be32(const struct nlattr *nla)
 #define nla_get_be64 rpl_nla_get_be64
 static inline __be64 nla_get_be64(const struct nlattr *nla)
 {
-        __be64 tmp;
+       __be64 tmp;
 
        /* The additional cast is necessary because  */
-        nla_memcpy(&tmp, (struct nlattr *) nla, sizeof(tmp));
+       nla_memcpy(&tmp, (struct nlattr *) nla, sizeof(tmp));
+
+       return tmp;
+}
+#endif
 
-        return tmp;
+#ifndef HAVE_NLA_PUT_BE16
+static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)
+{
+       return nla_put(skb, attrtype, sizeof(__be16), &value);
+}
+#endif
+
+#ifndef HAVE_NLA_PUT_BE32
+static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)
+{
+       return nla_put(skb, attrtype, sizeof(__be32), &value);
+}
+#endif
+
+#ifndef HAVE_NLA_PUT_BE64
+static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)
+{
+       return nla_put(skb, attrtype, sizeof(__be64), &value);
 }
 #endif
 
@@ -107,13 +113,14 @@ static inline __be64 nla_get_be64(const struct nlattr *nla)
  */
 static inline int nla_type(const struct nlattr *nla)
 {
-        return nla->nla_type & NLA_TYPE_MASK;
+       return nla->nla_type & NLA_TYPE_MASK;
 }
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
 #define nla_parse_nested(tb, maxtype, nla, policy) \
-       nla_parse_nested(tb, maxtype, (struct nlattr *)(nla), (struct nla_policy *)(policy))
+       nla_parse_nested(tb, maxtype, (struct nlattr *)(nla), \
+                       (struct nla_policy *)(policy))
 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
 #define nla_parse_nested(tb, maxtype, nla, policy) \
        nla_parse_nested(tb, maxtype, (struct nlattr *)(nla), policy)
@@ -144,7 +151,7 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh)
 }
 
 extern int             nlmsg_notify(struct sock *sk, struct sk_buff *skb,
-                                    u32 pid, unsigned int group, int report,
+                                    u32 portid, unsigned int group, int report,
                                     gfp_t flags);
 #endif /* linux kernel < 2.6.19 */
 
@@ -155,13 +162,13 @@ extern int                nlmsg_notify(struct sock *sk, struct sk_buff *skb,
  * argument. */
 #define nlmsg_multicast rpl_nlmsg_multicast
 static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb,
-                                 u32 pid, unsigned int group, gfp_t flags)
+                                 u32 portid, unsigned int group, gfp_t flags)
 {
        int err;
 
        NETLINK_CB(skb).dst_group = group;
 
-       err = netlink_broadcast(sk, skb, pid, group, flags);
+       err = netlink_broadcast(sk, skb, portid, group, flags);
        if (err > 0)
                err = 0;