@@ -1320,7 +1320,13 @@ struct lnet {
struct list_head ln_udsp_list;
};
-static const struct nla_policy scalar_attr_policy[LN_SCALAR_CNT + 1] = {
+struct genl_filter_list {
+ struct list_head lp_list;
+ void *lp_cursor;
+ bool lp_first;
+};
+
+static const struct nla_policy scalar_attr_policy[LN_SCALAR_MAX + 1] = {
[LN_SCALAR_ATTR_LIST] = { .type = NLA_NESTED },
[LN_SCALAR_ATTR_LIST_SIZE] = { .type = NLA_U16 },
[LN_SCALAR_ATTR_INDEX] = { .type = NLA_U16 },
@@ -38,23 +38,44 @@ enum lnet_nl_key_format {
LNKF_SEQUENCE = 4,
};
+/**
+ * enum lnet_nl_scalar_attrs - scalar LNet netlink attributes used
+ * to compose messages for sending or
+ * receiving.
+ *
+ * @LN_SCALAR_ATTR_UNSPEC: unspecified attribute to catch errors
+ * @LN_SCALAR_ATTR_PAD: padding for 64-bit attributes, ignore
+ *
+ * @LN_SCALAR_ATTR_LIST: List of scalar attributes (NLA_NESTED)
+ * @LN_SCALAR_ATTR_LIST_SIZE: Number of items in scalar list (NLA_U16)
+ * @LN_SCALAR_ATTR_INDEX: True Netlink attr value (NLA_U16)
+ * @LN_SCALAR_ATTR_NLA_TYPE: Data format for value part of the pair
+ * (NLA_U16)
+ * @LN_SCALAR_ATTR_VALUE: String value of key part of the pair.
+ * (NLA_NUL_STRING)
+ * @LN_SCALAR_ATTR_INT_VALUE: Numeric value of key part of the pair.
+ * (NLA_S64)
+ * @LN_SCALAR_ATTR_KEY_FORMAT: LNKF_* format of the key value pair.
+ */
enum lnet_nl_scalar_attrs {
LN_SCALAR_ATTR_UNSPEC = 0,
- LN_SCALAR_ATTR_LIST,
+ LN_SCALAR_ATTR_PAD = LN_SCALAR_ATTR_UNSPEC,
+ LN_SCALAR_ATTR_LIST,
LN_SCALAR_ATTR_LIST_SIZE,
LN_SCALAR_ATTR_INDEX,
LN_SCALAR_ATTR_NLA_TYPE,
LN_SCALAR_ATTR_VALUE,
+ LN_SCALAR_ATTR_INT_VALUE,
LN_SCALAR_ATTR_KEY_FORMAT,
- __LN_SCALAR_ATTR_LAST,
+ __LN_SCALAR_ATTR_MAX_PLUS_ONE,
};
-#define LN_SCALAR_CNT (__LN_SCALAR_ATTR_LAST - 1)
+#define LN_SCALAR_MAX (__LN_SCALAR_ATTR_MAX_PLUS_ONE - 1)
struct ln_key_props {
- char *lkp_values;
+ char *lkp_value;
__u16 lkp_key_format;
__u16 lkp_data_type;
};
@@ -2670,9 +2670,9 @@ static int lnet_genl_parse_list(struct sk_buff *msg,
list->lkl_maxattr);
nla_put_u16(msg, LN_SCALAR_ATTR_INDEX, count);
- if (props[count].lkp_values)
+ if (props[count].lkp_value)
nla_put_string(msg, LN_SCALAR_ATTR_VALUE,
- props[count].lkp_values);
+ props[count].lkp_value);
if (props[count].lkp_key_format)
nla_put_u16(msg, LN_SCALAR_ATTR_KEY_FORMAT,
props[count].lkp_key_format);
@@ -2684,13 +2684,14 @@ static int lnet_genl_parse_list(struct sk_buff *msg,
rc = lnet_genl_parse_list(msg, data, ++idx);
if (rc < 0)
return rc;
+ idx = rc;
}
nla_nest_end(msg, key);
}
nla_nest_end(msg, node);
- return 0;
+ return idx;
}
int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
@@ -2717,7 +2718,7 @@ int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
canceled:
if (rc < 0)
genlmsg_cancel(msg, hdr);
- return rc;
+ return rc > 0 ? 0 : rc;
}
EXPORT_SYMBOL(lnet_genl_send_scalar_list);