aboutsummaryrefslogtreecommitdiff
path: root/lib/netlink.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-12-07 09:37:59 -0800
committerBen Pfaff <blp@nicira.com>2010-12-10 11:13:31 -0800
commit7c6244783982509fddd62b3296bc627943bb7a1a (patch)
tree0e2064b181295e6432aa24cd048dde6b9442237a /lib/netlink.c
parentee913f985d470515cc018e57ea56aac3f087702f (diff)
netlink: New function nl_attr_type().
Linux since v2.6.24 has a couple of couple of bits at the top of nla_type that one is apparently supposed to ignore. This commit starts doing that in Open vSwitch userspace. Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'lib/netlink.c')
-rw-r--r--lib/netlink.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/netlink.c b/lib/netlink.c
index 3ed2f53a..f1234ad4 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -358,6 +358,14 @@ nl_msg_next(struct ofpbuf *buffer, struct ofpbuf *msg)
/* Attributes. */
+/* Returns the bits of 'nla->nla_type' that are significant for determining its
+ * type. */
+int
+nl_attr_type(const struct nlattr *nla)
+{
+ return nla->nla_type & NLA_TYPE_MASK;
+}
+
/* Returns the first byte in the payload of attribute 'nla'. */
const void *
nl_attr_get(const struct nlattr *nla)
@@ -539,12 +547,12 @@ nl_policy_parse(const struct ofpbuf *msg, size_t nla_offset,
if (aligned_len > (char*)tail - (char*)p) {
VLOG_DBG_RL(&rl, "%zu: attr %"PRIu16" aligned data len (%zu) "
"> bytes left (%tu)",
- offset, nla->nla_type, aligned_len,
+ offset, nl_attr_type(nla), aligned_len,
(char*)tail - (char*)p);
return false;
}
- type = nla->nla_type;
+ type = nl_attr_type(nla);
if (type < n_attrs && policy[type].type != NL_A_NO_ATTR) {
const struct nl_policy *e = &policy[type];
size_t min_len, max_len;