summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2011-05-03 16:56:09 +0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-08 19:55:38 +0400
commitb966b5dd8e17e6c105ca55533fd412de5d5b429e (patch)
tree5597a93a0753ccd2476f4ba9ff31de5eeb09d83c /include
parentd8cd289dbe69ce9b8115d6f200ceff657e5dafa0 (diff)
downloadlinux-b966b5dd8e17e6c105ca55533fd412de5d5b429e.tar.xz
drbd: Generate the drbd_set_*_defaults() functions from drbd_genl.h
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/drbd_genl.h91
-rw-r--r--include/linux/genl_magic_func.h26
-rw-r--r--include/linux/genl_magic_struct.h8
3 files changed, 79 insertions, 46 deletions
diff --git a/include/linux/drbd_genl.h b/include/linux/drbd_genl.h
index 10144d546a66..549800668cb9 100644
--- a/include/linux/drbd_genl.h
+++ b/include/linux/drbd_genl.h
@@ -110,63 +110,62 @@ GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf,
* but it won't propagate through the stack */
__u32_field(5, GENLA_F_MANDATORY | GENLA_F_INVARIANT, max_bio_bvecs)
- __u32_field(6, GENLA_F_MANDATORY, on_io_error)
- __u32_field(7, GENLA_F_MANDATORY, fencing)
-
- __u32_field(8, GENLA_F_MANDATORY, resync_rate)
- __u32_field(9, GENLA_F_MANDATORY, resync_after)
- __u32_field(10, GENLA_F_MANDATORY, al_extents)
- __u32_field(11, GENLA_F_MANDATORY, c_plan_ahead)
- __u32_field(12, GENLA_F_MANDATORY, c_delay_target)
- __u32_field(13, GENLA_F_MANDATORY, c_fill_target)
- __u32_field(14, GENLA_F_MANDATORY, c_max_rate)
- __u32_field(15, GENLA_F_MANDATORY, c_min_rate)
-
- __flg_field(16, GENLA_F_MANDATORY, no_disk_barrier)
- __flg_field(17, GENLA_F_MANDATORY, no_disk_flush)
- __flg_field(18, GENLA_F_MANDATORY, no_disk_drain)
- __flg_field(19, GENLA_F_MANDATORY, no_md_flush)
-
+ __u32_field_def(6, GENLA_F_MANDATORY, on_io_error, DRBD_ON_IO_ERROR_DEF)
+ __u32_field_def(7, GENLA_F_MANDATORY, fencing, DRBD_FENCING_DEF)
+
+ __u32_field_def(8, GENLA_F_MANDATORY, resync_rate, DRBD_RATE_DEF)
+ __u32_field_def(9, GENLA_F_MANDATORY, resync_after, DRBD_AFTER_DEF)
+ __u32_field_def(10, GENLA_F_MANDATORY, al_extents, DRBD_AL_EXTENTS_DEF)
+ __u32_field_def(11, GENLA_F_MANDATORY, c_plan_ahead, DRBD_C_PLAN_AHEAD_DEF)
+ __u32_field_def(12, GENLA_F_MANDATORY, c_delay_target, DRBD_C_DELAY_TARGET_DEF)
+ __u32_field_def(13, GENLA_F_MANDATORY, c_fill_target, DRBD_C_FILL_TARGET_DEF)
+ __u32_field_def(14, GENLA_F_MANDATORY, c_max_rate, DRBD_C_MAX_RATE_DEF)
+ __u32_field_def(15, GENLA_F_MANDATORY, c_min_rate, DRBD_C_MIN_RATE_DEF)
+
+ __flg_field_def(16, GENLA_F_MANDATORY, no_disk_barrier, 0)
+ __flg_field_def(17, GENLA_F_MANDATORY, no_disk_flush, 0)
+ __flg_field_def(18, GENLA_F_MANDATORY, no_disk_drain, 0)
+ __flg_field_def(19, GENLA_F_MANDATORY, no_md_flush, 0)
)
GENL_struct(DRBD_NLA_RESOURCE_OPTS, 4, res_opts,
- __str_field(1, GENLA_F_MANDATORY, cpu_mask, 32)
- __u32_field(2, GENLA_F_MANDATORY, on_no_data)
+ __str_field_def(1, GENLA_F_MANDATORY, cpu_mask, 32)
+ __u32_field_def(2, GENLA_F_MANDATORY, on_no_data, DRBD_ON_NO_DATA_DEF)
)
GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf,
__bin_field(1, GENLA_F_REQUIRED | GENLA_F_INVARIANT, my_addr, 128)
__bin_field(2, GENLA_F_REQUIRED | GENLA_F_INVARIANT, peer_addr, 128)
- __str_field(3, GENLA_F_MANDATORY | GENLA_F_SENSITIVE,
+ __str_field_def(3, GENLA_F_MANDATORY | GENLA_F_SENSITIVE,
shared_secret, SHARED_SECRET_MAX)
- __str_field(4, GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX)
- __str_field(5, GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX)
- __str_field(6, GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX)
- __str_field(7, GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX)
- __u32_field(8, GENLA_F_MANDATORY, wire_protocol)
- __u32_field(9, GENLA_F_MANDATORY, try_connect_int)
- __u32_field(10, GENLA_F_MANDATORY, timeout)
- __u32_field(11, GENLA_F_MANDATORY, ping_int)
- __u32_field(12, GENLA_F_MANDATORY, ping_timeo)
- __u32_field(13, GENLA_F_MANDATORY, sndbuf_size)
- __u32_field(14, GENLA_F_MANDATORY, rcvbuf_size)
- __u32_field(15, GENLA_F_MANDATORY, ko_count)
- __u32_field(16, GENLA_F_MANDATORY, max_buffers)
- __u32_field(17, GENLA_F_MANDATORY, max_epoch_size)
- __u32_field(18, GENLA_F_MANDATORY, unplug_watermark)
- __u32_field(19, GENLA_F_MANDATORY, after_sb_0p)
- __u32_field(20, GENLA_F_MANDATORY, after_sb_1p)
- __u32_field(21, GENLA_F_MANDATORY, after_sb_2p)
- __u32_field(22, GENLA_F_MANDATORY, rr_conflict)
- __u32_field(23, GENLA_F_MANDATORY, on_congestion)
- __u32_field(24, GENLA_F_MANDATORY, cong_fill)
- __u32_field(25, GENLA_F_MANDATORY, cong_extents)
- __flg_field(26, GENLA_F_MANDATORY, two_primaries)
+ __str_field_def(4, GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX)
+ __str_field_def(5, GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX)
+ __str_field_def(6, GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX)
+ __str_field_def(7, GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX)
+ __u32_field_def(8, GENLA_F_MANDATORY, wire_protocol, DRBD_PROTOCOL_DEF)
+ __u32_field_def(9, GENLA_F_MANDATORY, try_connect_int, DRBD_CONNECT_INT_DEF)
+ __u32_field_def(10, GENLA_F_MANDATORY, timeout, DRBD_TIMEOUT_DEF)
+ __u32_field_def(11, GENLA_F_MANDATORY, ping_int, DRBD_PING_INT_DEF)
+ __u32_field_def(12, GENLA_F_MANDATORY, ping_timeo, DRBD_PING_TIMEO_DEF)
+ __u32_field_def(13, GENLA_F_MANDATORY, sndbuf_size, DRBD_SNDBUF_SIZE_DEF)
+ __u32_field_def(14, GENLA_F_MANDATORY, rcvbuf_size, DRBD_RCVBUF_SIZE_DEF)
+ __u32_field_def(15, GENLA_F_MANDATORY, ko_count, DRBD_KO_COUNT_DEF)
+ __u32_field_def(16, GENLA_F_MANDATORY, max_buffers, DRBD_MAX_BUFFERS_DEF)
+ __u32_field_def(17, GENLA_F_MANDATORY, max_epoch_size, DRBD_MAX_EPOCH_SIZE_DEF)
+ __u32_field_def(18, GENLA_F_MANDATORY, unplug_watermark, DRBD_UNPLUG_WATERMARK_DEF)
+ __u32_field_def(19, GENLA_F_MANDATORY, after_sb_0p, DRBD_AFTER_SB_0P_DEF)
+ __u32_field_def(20, GENLA_F_MANDATORY, after_sb_1p, DRBD_AFTER_SB_1P_DEF)
+ __u32_field_def(21, GENLA_F_MANDATORY, after_sb_2p, DRBD_AFTER_SB_2P_DEF)
+ __u32_field_def(22, GENLA_F_MANDATORY, rr_conflict, DRBD_RR_CONFLICT_DEF)
+ __u32_field_def(23, GENLA_F_MANDATORY, on_congestion, DRBD_ON_CONGESTION_DEF)
+ __u32_field_def(24, GENLA_F_MANDATORY, cong_fill, DRBD_CONG_FILL_DEF)
+ __u32_field_def(25, GENLA_F_MANDATORY, cong_extents, DRBD_CONG_EXTENTS_DEF)
+ __flg_field_def(26, GENLA_F_MANDATORY, two_primaries, 0)
__flg_field(27, GENLA_F_MANDATORY | GENLA_F_INVARIANT, want_lose)
- __flg_field(28, GENLA_F_MANDATORY, no_cork)
- __flg_field(29, GENLA_F_MANDATORY, always_asbp)
+ __flg_field_def(28, GENLA_F_MANDATORY, no_cork, 0)
+ __flg_field_def(29, GENLA_F_MANDATORY, always_asbp, 0)
__flg_field(30, GENLA_F_MANDATORY | GENLA_F_INVARIANT, dry_run)
- __flg_field(31, GENLA_F_MANDATORY, use_rle)
+ __flg_field_def(31, GENLA_F_MANDATORY, use_rle, 0)
)
GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms,
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
index e458282a3728..e908f1c50355 100644
--- a/include/linux/genl_magic_func.h
+++ b/include/linux/genl_magic_func.h
@@ -427,6 +427,32 @@ static inline int s_name ## _to_unpriv_skb(struct sk_buff *skb, \
#include GENL_MAGIC_INCLUDE_FILE
+
+/* Functions for initializing structs to default values. */
+
+#undef __field
+#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put)
+#undef __array
+#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put)
+#undef __u32_field_def
+#define __u32_field_def(attr_nr, attr_flag, name, default) \
+ x->name = default;
+#undef __flg_field_def
+#define __flg_field_def(attr_nr, attr_flag, name, default) \
+ x->name = default;
+#undef __str_field_def
+#define __str_field_def(attr_nr, attr_flag, name, maxlen) \
+ memset(x->name, 0, sizeof(x->name)); \
+ x->name ## _len = 0;
+#undef GENL_struct
+#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
+static void set_ ## s_name ## _defaults(struct s_name *x) __attribute__((unused)); \
+static void set_ ## s_name ## _defaults(struct s_name *x) { \
+s_fields \
+}
+
+#include GENL_MAGIC_INCLUDE_FILE
+
#endif /* __KERNEL__ */
/* }}}1 */
diff --git a/include/linux/genl_magic_struct.h b/include/linux/genl_magic_struct.h
index 9a605b9ee834..f2c7cc7831df 100644
--- a/include/linux/genl_magic_struct.h
+++ b/include/linux/genl_magic_struct.h
@@ -107,6 +107,14 @@ enum {
__array(attr_nr, attr_flag, name, NLA_BINARY, char, maxlen, \
nla_memcpy, NLA_PUT)
+/* fields with default values */
+#define __flg_field_def(attr_nr, attr_flag, name, default) \
+ __flg_field(attr_nr, attr_flag, name)
+#define __u32_field_def(attr_nr, attr_flag, name, default) \
+ __u32_field(attr_nr, attr_flag, name)
+#define __str_field_def(attr_nr, attr_flag, name, maxlen) \
+ __str_field(attr_nr, attr_flag, name, maxlen)
+
#define __nla_put_flag(skb, attrtype, value) \
do { \
if (value) \