diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2011-03-23 09:31:09 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:44:20 -0500 |
commit | f399002e68e626e7bc443e6fcab1772704cc197f (patch) | |
tree | 0d6abf88f3ebf5c619994c929d5baf728a3f579c /include/linux/genl_magic_func.h | |
parent | 6b75dced005c7f06b81934167e36bcfc690cc3a7 (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.h | 49 |
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]; | |||
190 | 190 | ||
191 | #undef GENL_struct | 191 | #undef GENL_struct |
192 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | 192 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ |
193 | /* static, potentially unused */ \ | 193 | /* *_from_attrs functions are static, but potentially unused */ \ |
194 | int s_name ## _from_attrs(struct s_name *s, struct nlattr *tb[]) \ | 194 | static int __ ## s_name ## _from_attrs(struct s_name *s, \ |
195 | struct genl_info *info, bool exclude_invariants) \ | ||
195 | { \ | 196 | { \ |
196 | const int maxtype = ARRAY_SIZE(s_name ## _nl_policy)-1; \ | 197 | const int maxtype = ARRAY_SIZE(s_name ## _nl_policy)-1; \ |
197 | struct nlattr *tla = tb[tag_number]; \ | 198 | struct nlattr *tla = info->attrs[tag_number]; \ |
198 | struct nlattr **ntb = nested_attr_tb; \ | 199 | struct nlattr **ntb = nested_attr_tb; \ |
199 | struct nlattr *nla; \ | 200 | struct nlattr *nla; \ |
200 | int err; \ | 201 | int err; \ |
@@ -211,33 +212,49 @@ int s_name ## _from_attrs(struct s_name *s, struct nlattr *tb[]) \ | |||
211 | \ | 212 | \ |
212 | s_fields \ | 213 | s_fields \ |
213 | return 0; \ | 214 | return 0; \ |
214 | } | 215 | } __attribute__((unused)) \ |
216 | static int s_name ## _from_attrs(struct s_name *s, \ | ||
217 | struct genl_info *info) \ | ||
218 | { \ | ||
219 | return __ ## s_name ## _from_attrs(s, info, false); \ | ||
220 | } __attribute__((unused)) \ | ||
221 | static int s_name ## _from_attrs_for_change(struct s_name *s, \ | ||
222 | struct genl_info *info) \ | ||
223 | { \ | ||
224 | return __ ## s_name ## _from_attrs(s, info, true); \ | ||
225 | } __attribute__((unused)) \ | ||
215 | 226 | ||
216 | #undef __field | 227 | #define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) \ |
217 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \ | ||
218 | nla = ntb[__nla_type(attr_nr)]; \ | 228 | nla = ntb[__nla_type(attr_nr)]; \ |
219 | if (nla) { \ | 229 | if (nla) { \ |
220 | if (s) \ | 230 | if (exclude_invariants && ((attr_flag) & GENLA_F_INVARIANT)) { \ |
221 | s->name = __get(nla); \ | 231 | pr_info("<< must not change invariant attr: %s\n", #name); \ |
222 | DPRINT_FIELD("<<", nla_type, name, s, nla); \ | 232 | return -EEXIST; \ |
233 | } \ | ||
234 | assignment; \ | ||
235 | } else if (exclude_invariants && ((attr_flag) & GENLA_F_INVARIANT)) { \ | ||
236 | /* attribute missing from payload, */ \ | ||
237 | /* which was expected */ \ | ||
223 | } else if ((attr_flag) & GENLA_F_REQUIRED) { \ | 238 | } else if ((attr_flag) & GENLA_F_REQUIRED) { \ |
224 | pr_info("<< missing attr: %s\n", #name); \ | 239 | pr_info("<< missing attr: %s\n", #name); \ |
225 | return -ENOMSG; \ | 240 | return -ENOMSG; \ |
226 | } | 241 | } |
227 | 242 | ||
243 | #undef __field | ||
244 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \ | ||
245 | __assign(attr_nr, attr_flag, name, nla_type, type, \ | ||
246 | if (s) \ | ||
247 | s->name = __get(nla); \ | ||
248 | DPRINT_FIELD("<<", nla_type, name, s, nla)) | ||
249 | |||
228 | /* validate_nla() already checked nla_len <= maxlen appropriately. */ | 250 | /* validate_nla() already checked nla_len <= maxlen appropriately. */ |
229 | #undef __array | 251 | #undef __array |
230 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put) \ | 252 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put) \ |
231 | nla = ntb[__nla_type(attr_nr)]; \ | 253 | __assign(attr_nr, attr_flag, name, nla_type, type, \ |
232 | if (nla) { \ | ||
233 | if (s) \ | 254 | if (s) \ |
234 | s->name ## _len = \ | 255 | s->name ## _len = \ |
235 | __get(s->name, nla, maxlen); \ | 256 | __get(s->name, nla, maxlen); \ |
236 | DPRINT_ARRAY("<<", nla_type, name, s, nla); \ | 257 | DPRINT_ARRAY("<<", nla_type, name, s, nla)) |
237 | } else if ((attr_flag) & GENLA_F_REQUIRED) { \ | ||
238 | pr_info("<< missing attr: %s\n", #name); \ | ||
239 | return -ENOMSG; \ | ||
240 | } \ | ||
241 | 258 | ||
242 | #include GENL_MAGIC_INCLUDE_FILE | 259 | #include GENL_MAGIC_INCLUDE_FILE |
243 | 260 | ||