summaryrefslogtreecommitdiff
path: root/include/linux/genl_magic_func.h
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2011-03-23 14:31:09 +0100
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-08 16:44:20 +0100
commitf399002e68e626e7bc443e6fcab1772704cc197f (patch)
tree0d6abf88f3ebf5c619994c929d5baf728a3f579c /include/linux/genl_magic_func.h
parent6b75dced005c7f06b81934167e36bcfc690cc3a7 (diff)
drbd: distribute former syncer_conf settings to disk, connection, and resource level
This commit breaks the API again. Move per-volume former syncer options into disk_conf. Move per-connection former syncer options into net_conf. Renamed the remainign sync_conf to res_opts Syncer settings have been changeable at runtime, so we need to prepare for these settings to be runtime-changeable in their new home as well. Introduce new configuration operations, and share the netlink attribute between "attach" (create new disk) and "disk-opts" (change options). Same for "connect" and "net-opts". Some fields cannot be changed at runtime, however. Introduce a new flag GENLA_F_INVARIANT to be able to trigger on that in the generated validation and assignment functions. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'include/linux/genl_magic_func.h')
-rw-r--r--include/linux/genl_magic_func.h49
1 files changed, 33 insertions, 16 deletions
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
index c8c67239f616..e458282a3728 100644
--- a/include/linux/genl_magic_func.h
+++ b/include/linux/genl_magic_func.h
@@ -190,11 +190,12 @@ static struct nlattr *nested_attr_tb[128];
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
- /* static, potentially unused */ \
-int s_name ## _from_attrs(struct s_name *s, struct nlattr *tb[]) \
+/* *_from_attrs functions are static, but potentially unused */ \
+static int __ ## s_name ## _from_attrs(struct s_name *s, \
+ struct genl_info *info, bool exclude_invariants) \
{ \
const int maxtype = ARRAY_SIZE(s_name ## _nl_policy)-1; \
- struct nlattr *tla = tb[tag_number]; \
+ struct nlattr *tla = info->attrs[tag_number]; \
struct nlattr **ntb = nested_attr_tb; \
struct nlattr *nla; \
int err; \
@@ -211,33 +212,49 @@ int s_name ## _from_attrs(struct s_name *s, struct nlattr *tb[]) \
\
s_fields \
return 0; \
-}
+} __attribute__((unused)) \
+static int s_name ## _from_attrs(struct s_name *s, \
+ struct genl_info *info) \
+{ \
+ return __ ## s_name ## _from_attrs(s, info, false); \
+} __attribute__((unused)) \
+static int s_name ## _from_attrs_for_change(struct s_name *s, \
+ struct genl_info *info) \
+{ \
+ return __ ## s_name ## _from_attrs(s, info, true); \
+} __attribute__((unused)) \
-#undef __field
-#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \
+#define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) \
nla = ntb[__nla_type(attr_nr)]; \
if (nla) { \
- if (s) \
- s->name = __get(nla); \
- DPRINT_FIELD("<<", nla_type, name, s, nla); \
+ if (exclude_invariants && ((attr_flag) & GENLA_F_INVARIANT)) { \
+ pr_info("<< must not change invariant attr: %s\n", #name); \
+ return -EEXIST; \
+ } \
+ assignment; \
+ } else if (exclude_invariants && ((attr_flag) & GENLA_F_INVARIANT)) { \
+ /* attribute missing from payload, */ \
+ /* which was expected */ \
} else if ((attr_flag) & GENLA_F_REQUIRED) { \
pr_info("<< missing attr: %s\n", #name); \
return -ENOMSG; \
}
+#undef __field
+#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \
+ __assign(attr_nr, attr_flag, name, nla_type, type, \
+ if (s) \
+ s->name = __get(nla); \
+ DPRINT_FIELD("<<", nla_type, name, s, nla))
+
/* validate_nla() already checked nla_len <= maxlen appropriately. */
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put) \
- nla = ntb[__nla_type(attr_nr)]; \
- if (nla) { \
+ __assign(attr_nr, attr_flag, name, nla_type, type, \
if (s) \
s->name ## _len = \
__get(s->name, nla, maxlen); \
- DPRINT_ARRAY("<<", nla_type, name, s, nla); \
- } else if ((attr_flag) & GENLA_F_REQUIRED) { \
- pr_info("<< missing attr: %s\n", #name); \
- return -ENOMSG; \
- } \
+ DPRINT_ARRAY("<<", nla_type, name, s, nla))
#include GENL_MAGIC_INCLUDE_FILE