blob: 53f44b8cd75f3336fedf76d07b9dc24bd8077f90 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Lars Ellenbergec2c35a2011-03-07 10:20:08 +01002/*
3 * General overview:
4 * full generic netlink message:
5 * |nlmsghdr|genlmsghdr|<payload>
6 *
7 * payload:
8 * |optional fixed size family header|<sequence of netlink attributes>
9 *
10 * sequence of netlink attributes:
11 * I chose to have all "top level" attributes NLA_NESTED,
12 * corresponding to some real struct.
13 * So we have a sequence of |tla, len|<nested nla sequence>
14 *
15 * nested nla sequence:
16 * may be empty, or contain a sequence of netlink attributes
17 * representing the struct fields.
18 *
19 * The tag number of any field (regardless of containing struct)
20 * will be available as T_ ## field_name,
21 * so you cannot have the same field name in two differnt structs.
22 *
23 * The tag numbers themselves are per struct, though,
24 * so should always begin at 1 (not 0, that is the special "NLA_UNSPEC" type,
25 * which we won't use here).
26 * The tag numbers are used as index in the respective nla_policy array.
27 *
28 * GENL_struct(tag_name, tag_number, struct name, struct fields) - struct and policy
29 * genl_magic_struct.h
30 * generates the struct declaration,
31 * generates an entry in the tla enum,
32 * genl_magic_func.h
33 * generates an entry in the static tla policy
34 * with .type = NLA_NESTED
35 * generates the static <struct_name>_nl_policy definition,
36 * and static conversion functions
37 *
38 * genl_magic_func.h
39 *
40 * GENL_mc_group(group)
41 * genl_magic_struct.h
42 * does nothing
43 * genl_magic_func.h
44 * defines and registers the mcast group,
45 * and provides a send helper
46 *
47 * GENL_notification(op_name, op_num, mcast_group, tla list)
48 * These are notifications to userspace.
49 *
50 * genl_magic_struct.h
51 * generates an entry in the genl_ops enum,
52 * genl_magic_func.h
53 * does nothing
54 *
55 * mcast group: the name of the mcast group this notification should be
56 * expected on
57 * tla list: the list of expected top level attributes,
58 * for documentation and sanity checking.
59 *
60 * GENL_op(op_name, op_num, flags and handler, tla list) - "genl operations"
61 * These are requests from userspace.
62 *
63 * _op and _notification share the same "number space",
64 * op_nr will be assigned to "genlmsghdr->cmd"
65 *
66 * genl_magic_struct.h
67 * generates an entry in the genl_ops enum,
68 * genl_magic_func.h
69 * generates an entry in the static genl_ops array,
70 * and static register/unregister functions to
Johannes Berg489111e2016-10-24 14:40:03 +020071 * genl_register_family().
Lars Ellenbergec2c35a2011-03-07 10:20:08 +010072 *
73 * flags and handler:
74 * GENL_op_init( .doit = x, .dumpit = y, .flags = something)
75 * GENL_doit(x) => .dumpit = NULL, .flags = GENL_ADMIN_PERM
76 * tla list: the list of expected top level attributes,
77 * for documentation and sanity checking.
78 */
79
80/*
81 * STRUCTS
82 */
83
84/* this is sent kernel -> userland on various error conditions, and contains
85 * informational textual info, which is supposedly human readable.
86 * The computer relevant return code is in the drbd_genlmsghdr.
87 */
88GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply,
89 /* "arbitrary" size strings, nla_policy.len = 0 */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +020090 __str_field(1, DRBD_GENLA_F_MANDATORY, info_text, 0)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +010091)
92
93/* Configuration requests typically need a context to operate on.
94 * Possible keys are device minor (fits in the drbd_genlmsghdr),
95 * the replication link (aka connection) name,
96 * and/or the replication group (aka resource) name,
97 * and the volume id within the resource. */
98GENL_struct(DRBD_NLA_CFG_CONTEXT, 2, drbd_cfg_context,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +020099 __u32_field(1, DRBD_GENLA_F_MANDATORY, ctx_volume)
Andreas Gruenbacher7c3063c2011-06-09 17:52:12 +0200100 __str_field(2, DRBD_GENLA_F_MANDATORY, ctx_resource_name, 128)
Andreas Gruenbacher089c0752011-06-14 18:28:09 +0200101 __bin_field(3, DRBD_GENLA_F_MANDATORY, ctx_my_addr, 128)
102 __bin_field(4, DRBD_GENLA_F_MANDATORY, ctx_peer_addr, 128)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100103)
104
105GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200106 __str_field(1, DRBD_F_REQUIRED | DRBD_F_INVARIANT, backing_dev, 128)
107 __str_field(2, DRBD_F_REQUIRED | DRBD_F_INVARIANT, meta_dev, 128)
108 __s32_field(3, DRBD_F_REQUIRED | DRBD_F_INVARIANT, meta_dev_idx)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100109
110 /* use the resize command to try and change the disk_size */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200111 __u64_field(4, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, disk_size)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100112 /* we could change the max_bio_bvecs,
113 * but it won't propagate through the stack */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200114 __u32_field(5, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, max_bio_bvecs)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100115
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200116 __u32_field_def(6, DRBD_GENLA_F_MANDATORY, on_io_error, DRBD_ON_IO_ERROR_DEF)
117 __u32_field_def(7, DRBD_GENLA_F_MANDATORY, fencing, DRBD_FENCING_DEF)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100118
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200119 __u32_field_def(8, DRBD_GENLA_F_MANDATORY, resync_rate, DRBD_RESYNC_RATE_DEF)
120 __s32_field_def(9, DRBD_GENLA_F_MANDATORY, resync_after, DRBD_MINOR_NUMBER_DEF)
121 __u32_field_def(10, DRBD_GENLA_F_MANDATORY, al_extents, DRBD_AL_EXTENTS_DEF)
122 __u32_field_def(11, DRBD_GENLA_F_MANDATORY, c_plan_ahead, DRBD_C_PLAN_AHEAD_DEF)
123 __u32_field_def(12, DRBD_GENLA_F_MANDATORY, c_delay_target, DRBD_C_DELAY_TARGET_DEF)
124 __u32_field_def(13, DRBD_GENLA_F_MANDATORY, c_fill_target, DRBD_C_FILL_TARGET_DEF)
125 __u32_field_def(14, DRBD_GENLA_F_MANDATORY, c_max_rate, DRBD_C_MAX_RATE_DEF)
126 __u32_field_def(15, DRBD_GENLA_F_MANDATORY, c_min_rate, DRBD_C_MIN_RATE_DEF)
Philipp Reisnera5ca66c2016-06-14 00:26:14 +0200127 __u32_field_def(20, DRBD_GENLA_F_MANDATORY, disk_timeout, DRBD_DISK_TIMEOUT_DEF)
128 __u32_field_def(21, 0 /* OPTIONAL */, read_balancing, DRBD_READ_BALANCING_DEF)
129 __u32_field_def(25, 0 /* OPTIONAL */, rs_discard_granularity, DRBD_RS_DISCARD_GRANULARITY_DEF)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100130
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200131 __flg_field_def(16, DRBD_GENLA_F_MANDATORY, disk_barrier, DRBD_DISK_BARRIER_DEF)
132 __flg_field_def(17, DRBD_GENLA_F_MANDATORY, disk_flushes, DRBD_DISK_FLUSHES_DEF)
133 __flg_field_def(18, DRBD_GENLA_F_MANDATORY, disk_drain, DRBD_DISK_DRAIN_DEF)
134 __flg_field_def(19, DRBD_GENLA_F_MANDATORY, md_flushes, DRBD_MD_FLUSHES_DEF)
Philipp Reisner9a51ab12012-02-20 21:53:28 +0100135 __flg_field_def(23, 0 /* OPTIONAL */, al_updates, DRBD_AL_UPDATES_DEF)
Lars Ellenberg9de7e142017-08-29 10:20:38 +0200136 __flg_field_def(24, 0 /* OPTIONAL */, discard_zeroes_if_aligned, DRBD_DISCARD_ZEROES_IF_ALIGNED_DEF)
137 __flg_field_def(26, 0 /* OPTIONAL */, disable_write_same, DRBD_DISABLE_WRITE_SAME_DEF)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100138)
139
Lars Ellenbergf3990022011-03-23 14:31:09 +0100140GENL_struct(DRBD_NLA_RESOURCE_OPTS, 4, res_opts,
Andreas Gruenbacherf44d0432011-07-22 13:53:19 +0200141 __str_field_def(1, DRBD_GENLA_F_MANDATORY, cpu_mask, DRBD_CPU_MASK_SIZE)
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200142 __u32_field_def(2, DRBD_GENLA_F_MANDATORY, on_no_data, DRBD_ON_NO_DATA_DEF)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100143)
144
145GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf,
Andreas Gruenbacher089c0752011-06-14 18:28:09 +0200146 __str_field_def(1, DRBD_GENLA_F_MANDATORY | DRBD_F_SENSITIVE,
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100147 shared_secret, SHARED_SECRET_MAX)
Andreas Gruenbacher089c0752011-06-14 18:28:09 +0200148 __str_field_def(2, DRBD_GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX)
149 __str_field_def(3, DRBD_GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX)
150 __str_field_def(4, DRBD_GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX)
151 __str_field_def(5, DRBD_GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX)
152 __u32_field_def(6, DRBD_GENLA_F_MANDATORY, wire_protocol, DRBD_PROTOCOL_DEF)
153 __u32_field_def(7, DRBD_GENLA_F_MANDATORY, connect_int, DRBD_CONNECT_INT_DEF)
154 __u32_field_def(8, DRBD_GENLA_F_MANDATORY, timeout, DRBD_TIMEOUT_DEF)
155 __u32_field_def(9, DRBD_GENLA_F_MANDATORY, ping_int, DRBD_PING_INT_DEF)
156 __u32_field_def(10, DRBD_GENLA_F_MANDATORY, ping_timeo, DRBD_PING_TIMEO_DEF)
157 __u32_field_def(11, DRBD_GENLA_F_MANDATORY, sndbuf_size, DRBD_SNDBUF_SIZE_DEF)
158 __u32_field_def(12, DRBD_GENLA_F_MANDATORY, rcvbuf_size, DRBD_RCVBUF_SIZE_DEF)
159 __u32_field_def(13, DRBD_GENLA_F_MANDATORY, ko_count, DRBD_KO_COUNT_DEF)
160 __u32_field_def(14, DRBD_GENLA_F_MANDATORY, max_buffers, DRBD_MAX_BUFFERS_DEF)
161 __u32_field_def(15, DRBD_GENLA_F_MANDATORY, max_epoch_size, DRBD_MAX_EPOCH_SIZE_DEF)
162 __u32_field_def(16, DRBD_GENLA_F_MANDATORY, unplug_watermark, DRBD_UNPLUG_WATERMARK_DEF)
163 __u32_field_def(17, DRBD_GENLA_F_MANDATORY, after_sb_0p, DRBD_AFTER_SB_0P_DEF)
164 __u32_field_def(18, DRBD_GENLA_F_MANDATORY, after_sb_1p, DRBD_AFTER_SB_1P_DEF)
165 __u32_field_def(19, DRBD_GENLA_F_MANDATORY, after_sb_2p, DRBD_AFTER_SB_2P_DEF)
166 __u32_field_def(20, DRBD_GENLA_F_MANDATORY, rr_conflict, DRBD_RR_CONFLICT_DEF)
167 __u32_field_def(21, DRBD_GENLA_F_MANDATORY, on_congestion, DRBD_ON_CONGESTION_DEF)
168 __u32_field_def(22, DRBD_GENLA_F_MANDATORY, cong_fill, DRBD_CONG_FILL_DEF)
169 __u32_field_def(23, DRBD_GENLA_F_MANDATORY, cong_extents, DRBD_CONG_EXTENTS_DEF)
170 __flg_field_def(24, DRBD_GENLA_F_MANDATORY, two_primaries, DRBD_ALLOW_TWO_PRIMARIES_DEF)
171 __flg_field(25, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, discard_my_data)
172 __flg_field_def(26, DRBD_GENLA_F_MANDATORY, tcp_cork, DRBD_TCP_CORK_DEF)
173 __flg_field_def(27, DRBD_GENLA_F_MANDATORY, always_asbp, DRBD_ALWAYS_ASBP_DEF)
Andreas Gruenbacher6dff2902011-06-28 14:18:12 +0200174 __flg_field(28, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, tentative)
Andreas Gruenbacher089c0752011-06-14 18:28:09 +0200175 __flg_field_def(29, DRBD_GENLA_F_MANDATORY, use_rle, DRBD_USE_RLE_DEF)
Philipp Reisner9a51ab12012-02-20 21:53:28 +0100176 /* 9: __u32_field_def(30, DRBD_GENLA_F_MANDATORY, fencing_policy, DRBD_FENCING_DEF) */
Lars Ellenbergaaaba342014-03-18 12:30:09 +0100177 /* 9: __str_field_def(31, DRBD_GENLA_F_MANDATORY, name, SHARED_SECRET_MAX) */
178 /* 9: __u32_field(32, DRBD_F_REQUIRED | DRBD_F_INVARIANT, peer_node_id) */
179 __flg_field_def(33, 0 /* OPTIONAL */, csums_after_crash_only, DRBD_CSUMS_AFTER_CRASH_ONLY_DEF)
Philipp Reisner5d0b17f2014-03-18 14:24:35 +0100180 __u32_field_def(34, 0 /* OPTIONAL */, sock_check_timeo, DRBD_SOCKET_CHECK_TIMEO_DEF)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100181)
182
183GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200184 __flg_field(1, DRBD_GENLA_F_MANDATORY, assume_uptodate)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100185)
186
187GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200188 __u64_field(1, DRBD_GENLA_F_MANDATORY, resize_size)
189 __flg_field(2, DRBD_GENLA_F_MANDATORY, resize_force)
190 __flg_field(3, DRBD_GENLA_F_MANDATORY, no_resync)
Philipp Reisnerd752b262013-06-25 16:50:08 +0200191 __u32_field_def(4, 0 /* OPTIONAL */, al_stripes, DRBD_AL_STRIPES_DEF)
192 __u32_field_def(5, 0 /* OPTIONAL */, al_stripe_size, DRBD_AL_STRIPE_SIZE_DEF)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100193)
194
195GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info,
196 /* the reason of the broadcast,
197 * if this is an event triggered broadcast. */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200198 __u32_field(1, DRBD_GENLA_F_MANDATORY, sib_reason)
199 __u32_field(2, DRBD_F_REQUIRED, current_state)
200 __u64_field(3, DRBD_GENLA_F_MANDATORY, capacity)
201 __u64_field(4, DRBD_GENLA_F_MANDATORY, ed_uuid)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100202
203 /* These are for broadcast from after state change work.
204 * prev_state and new_state are from the moment the state change took
205 * place, new_state is not neccessarily the same as current_state,
206 * there may have been more state changes since. Which will be
207 * broadcasted soon, in their respective after state change work. */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200208 __u32_field(5, DRBD_GENLA_F_MANDATORY, prev_state)
209 __u32_field(6, DRBD_GENLA_F_MANDATORY, new_state)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100210
211 /* if we have a local disk: */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200212 __bin_field(7, DRBD_GENLA_F_MANDATORY, uuids, (UI_SIZE*sizeof(__u64)))
213 __u32_field(8, DRBD_GENLA_F_MANDATORY, disk_flags)
214 __u64_field(9, DRBD_GENLA_F_MANDATORY, bits_total)
215 __u64_field(10, DRBD_GENLA_F_MANDATORY, bits_oos)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100216 /* and in case resync or online verify is active */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200217 __u64_field(11, DRBD_GENLA_F_MANDATORY, bits_rs_total)
218 __u64_field(12, DRBD_GENLA_F_MANDATORY, bits_rs_failed)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100219
220 /* for pre and post notifications of helper execution */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200221 __str_field(13, DRBD_GENLA_F_MANDATORY, helper, 32)
222 __u32_field(14, DRBD_GENLA_F_MANDATORY, helper_exit_code)
Philipp Marek3174f8c2012-03-03 21:04:30 +0100223
224 __u64_field(15, 0, send_cnt)
225 __u64_field(16, 0, recv_cnt)
226 __u64_field(17, 0, read_cnt)
227 __u64_field(18, 0, writ_cnt)
228 __u64_field(19, 0, al_writ_cnt)
229 __u64_field(20, 0, bm_writ_cnt)
230 __u32_field(21, 0, ap_bio_cnt)
231 __u32_field(22, 0, ap_pending_cnt)
232 __u32_field(23, 0, rs_pending_cnt)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100233)
234
235GENL_struct(DRBD_NLA_START_OV_PARMS, 9, start_ov_parms,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200236 __u64_field(1, DRBD_GENLA_F_MANDATORY, ov_start_sector)
Lars Ellenberg58ffa582012-07-26 14:09:49 +0200237 __u64_field(2, DRBD_GENLA_F_MANDATORY, ov_stop_sector)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100238)
239
240GENL_struct(DRBD_NLA_NEW_C_UUID_PARMS, 10, new_c_uuid_parms,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200241 __flg_field(1, DRBD_GENLA_F_MANDATORY, clear_bm)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100242)
243
244GENL_struct(DRBD_NLA_TIMEOUT_PARMS, 11, timeout_parms,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200245 __u32_field(1, DRBD_F_REQUIRED, timeout_type)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100246)
247
248GENL_struct(DRBD_NLA_DISCONNECT_PARMS, 12, disconnect_parms,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200249 __flg_field(1, DRBD_GENLA_F_MANDATORY, force_disconnect)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100250)
251
Philipp Reisnercdfda632011-07-05 15:38:59 +0200252GENL_struct(DRBD_NLA_DETACH_PARMS, 13, detach_parms,
253 __flg_field(1, DRBD_GENLA_F_MANDATORY, force_detach)
254)
255
Andreas Gruenbachera2972842014-07-31 17:41:33 +0200256GENL_struct(DRBD_NLA_RESOURCE_INFO, 15, resource_info,
257 __u32_field(1, 0, res_role)
258 __flg_field(2, 0, res_susp)
259 __flg_field(3, 0, res_susp_nod)
260 __flg_field(4, 0, res_susp_fen)
261 /* __flg_field(5, 0, res_weak) */
262)
263
264GENL_struct(DRBD_NLA_DEVICE_INFO, 16, device_info,
265 __u32_field(1, 0, dev_disk_state)
266)
267
268GENL_struct(DRBD_NLA_CONNECTION_INFO, 17, connection_info,
269 __u32_field(1, 0, conn_connection_state)
270 __u32_field(2, 0, conn_role)
271)
272
273GENL_struct(DRBD_NLA_PEER_DEVICE_INFO, 18, peer_device_info,
274 __u32_field(1, 0, peer_repl_state)
275 __u32_field(2, 0, peer_disk_state)
276 __u32_field(3, 0, peer_resync_susp_user)
277 __u32_field(4, 0, peer_resync_susp_peer)
278 __u32_field(5, 0, peer_resync_susp_dependency)
279)
280
281GENL_struct(DRBD_NLA_RESOURCE_STATISTICS, 19, resource_statistics,
282 __u32_field(1, 0, res_stat_write_ordering)
283)
284
285GENL_struct(DRBD_NLA_DEVICE_STATISTICS, 20, device_statistics,
286 __u64_field(1, 0, dev_size) /* (sectors) */
287 __u64_field(2, 0, dev_read) /* (sectors) */
288 __u64_field(3, 0, dev_write) /* (sectors) */
289 __u64_field(4, 0, dev_al_writes) /* activity log writes (count) */
290 __u64_field(5, 0, dev_bm_writes) /* bitmap writes (count) */
291 __u32_field(6, 0, dev_upper_pending) /* application requests in progress */
292 __u32_field(7, 0, dev_lower_pending) /* backing device requests in progress */
293 __flg_field(8, 0, dev_upper_blocked)
294 __flg_field(9, 0, dev_lower_blocked)
295 __flg_field(10, 0, dev_al_suspended) /* activity log suspended */
296 __u64_field(11, 0, dev_exposed_data_uuid)
297 __u64_field(12, 0, dev_current_uuid)
298 __u32_field(13, 0, dev_disk_flags)
299 __bin_field(14, 0, history_uuids, HISTORY_UUIDS * sizeof(__u64))
300)
301
302GENL_struct(DRBD_NLA_CONNECTION_STATISTICS, 21, connection_statistics,
303 __flg_field(1, 0, conn_congested)
304)
305
306GENL_struct(DRBD_NLA_PEER_DEVICE_STATISTICS, 22, peer_device_statistics,
307 __u64_field(1, 0, peer_dev_received) /* sectors */
308 __u64_field(2, 0, peer_dev_sent) /* sectors */
309 __u32_field(3, 0, peer_dev_pending) /* number of requests */
310 __u32_field(4, 0, peer_dev_unacked) /* number of requests */
311 __u64_field(5, 0, peer_dev_out_of_sync) /* sectors */
312 __u64_field(6, 0, peer_dev_resync_failed) /* sectors */
313 __u64_field(7, 0, peer_dev_bitmap_uuid)
314 __u32_field(9, 0, peer_dev_flags)
315)
316
317GENL_struct(DRBD_NLA_NOTIFICATION_HEADER, 23, drbd_notification_header,
318 __u32_field(1, DRBD_GENLA_F_MANDATORY, nh_type)
319)
320
321GENL_struct(DRBD_NLA_HELPER, 24, drbd_helper_info,
322 __str_field(1, DRBD_GENLA_F_MANDATORY, helper_name, 32)
323 __u32_field(2, DRBD_GENLA_F_MANDATORY, helper_status)
324)
325
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100326/*
327 * Notifications and commands (genlmsghdr->cmd)
328 */
329GENL_mc_group(events)
330
331 /* kernel -> userspace announcement of changes */
332GENL_notification(
333 DRBD_EVENT, 1, events,
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200334 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
335 GENL_tla_expected(DRBD_NLA_STATE_INFO, DRBD_F_REQUIRED)
336 GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_GENLA_F_MANDATORY)
337 GENL_tla_expected(DRBD_NLA_DISK_CONF, DRBD_GENLA_F_MANDATORY)
338 GENL_tla_expected(DRBD_NLA_SYNCER_CONF, DRBD_GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100339)
340
341 /* query kernel for specific or all info */
342GENL_op(
343 DRBD_ADM_GET_STATUS, 2,
344 GENL_op_init(
345 .doit = drbd_adm_get_status,
346 .dumpit = drbd_adm_get_status_all,
347 /* anyone may ask for the status,
348 * it is broadcasted anyways */
349 ),
350 /* To select the object .doit.
351 * Or a subset of objects in .dumpit. */
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200352 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100353)
354
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100355 /* add DRBD minor devices as volumes to resources */
Andreas Gruenbacher05a10ec2011-06-07 22:54:17 +0200356GENL_op(DRBD_ADM_NEW_MINOR, 5, GENL_doit(drbd_adm_new_minor),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200357 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Andreas Gruenbacher05a10ec2011-06-07 22:54:17 +0200358GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_del_minor),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200359 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100360
Andreas Gruenbacher789c1b62011-06-06 16:16:44 +0200361 /* add or delete resources */
362GENL_op(DRBD_ADM_NEW_RESOURCE, 7, GENL_doit(drbd_adm_new_resource),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200363 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Andreas Gruenbacher789c1b62011-06-06 16:16:44 +0200364GENL_op(DRBD_ADM_DEL_RESOURCE, 8, GENL_doit(drbd_adm_del_resource),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200365 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100366
Lars Ellenbergf3990022011-03-23 14:31:09 +0100367GENL_op(DRBD_ADM_RESOURCE_OPTS, 9,
368 GENL_doit(drbd_adm_resource_opts),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200369 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
370 GENL_tla_expected(DRBD_NLA_RESOURCE_OPTS, DRBD_GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100371)
372
373GENL_op(
374 DRBD_ADM_CONNECT, 10,
375 GENL_doit(drbd_adm_connect),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200376 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
377 GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_F_REQUIRED)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100378)
379
Lars Ellenbergf3990022011-03-23 14:31:09 +0100380GENL_op(
381 DRBD_ADM_CHG_NET_OPTS, 29,
382 GENL_doit(drbd_adm_net_opts),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200383 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
384 GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_F_REQUIRED)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100385)
386
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100387GENL_op(DRBD_ADM_DISCONNECT, 11, GENL_doit(drbd_adm_disconnect),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200388 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100389
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100390GENL_op(DRBD_ADM_ATTACH, 12,
391 GENL_doit(drbd_adm_attach),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200392 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
393 GENL_tla_expected(DRBD_NLA_DISK_CONF, DRBD_F_REQUIRED)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100394)
395
Lars Ellenbergf3990022011-03-23 14:31:09 +0100396GENL_op(DRBD_ADM_CHG_DISK_OPTS, 28,
397 GENL_doit(drbd_adm_disk_opts),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200398 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
399 GENL_tla_expected(DRBD_NLA_DISK_OPTS, DRBD_F_REQUIRED)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100400)
401
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100402GENL_op(
403 DRBD_ADM_RESIZE, 13,
404 GENL_doit(drbd_adm_resize),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200405 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
406 GENL_tla_expected(DRBD_NLA_RESIZE_PARMS, DRBD_GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100407)
408
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100409GENL_op(
410 DRBD_ADM_PRIMARY, 14,
411 GENL_doit(drbd_adm_set_role),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200412 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
413 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, DRBD_F_REQUIRED)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100414)
415
416GENL_op(
417 DRBD_ADM_SECONDARY, 15,
418 GENL_doit(drbd_adm_set_role),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200419 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
420 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, DRBD_F_REQUIRED)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100421)
422
423GENL_op(
424 DRBD_ADM_NEW_C_UUID, 16,
425 GENL_doit(drbd_adm_new_c_uuid),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200426 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
427 GENL_tla_expected(DRBD_NLA_NEW_C_UUID_PARMS, DRBD_GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100428)
429
430GENL_op(
431 DRBD_ADM_START_OV, 17,
432 GENL_doit(drbd_adm_start_ov),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200433 GENL_tla_expected(DRBD_NLA_START_OV_PARMS, DRBD_GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100434)
435
436GENL_op(DRBD_ADM_DETACH, 18, GENL_doit(drbd_adm_detach),
Philipp Reisnercdfda632011-07-05 15:38:59 +0200437 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
438 GENL_tla_expected(DRBD_NLA_DETACH_PARMS, DRBD_GENLA_F_MANDATORY))
439
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100440GENL_op(DRBD_ADM_INVALIDATE, 19, GENL_doit(drbd_adm_invalidate),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200441 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100442GENL_op(DRBD_ADM_INVAL_PEER, 20, GENL_doit(drbd_adm_invalidate_peer),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200443 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100444GENL_op(DRBD_ADM_PAUSE_SYNC, 21, GENL_doit(drbd_adm_pause_sync),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200445 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100446GENL_op(DRBD_ADM_RESUME_SYNC, 22, GENL_doit(drbd_adm_resume_sync),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200447 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100448GENL_op(DRBD_ADM_SUSPEND_IO, 23, GENL_doit(drbd_adm_suspend_io),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200449 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100450GENL_op(DRBD_ADM_RESUME_IO, 24, GENL_doit(drbd_adm_resume_io),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200451 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100452GENL_op(DRBD_ADM_OUTDATE, 25, GENL_doit(drbd_adm_outdate),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200453 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100454GENL_op(DRBD_ADM_GET_TIMEOUT_TYPE, 26, GENL_doit(drbd_adm_get_timeout_type),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200455 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Lars Ellenberg85f75dd72011-03-15 16:26:37 +0100456GENL_op(DRBD_ADM_DOWN, 27, GENL_doit(drbd_adm_down),
Andreas Gruenbacher5f935922011-05-19 17:39:28 +0200457 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
Andreas Gruenbachera2972842014-07-31 17:41:33 +0200458
Andreas Gruenbachera55bbd32014-08-28 13:31:14 +0200459GENL_op(DRBD_ADM_GET_RESOURCES, 30,
460 GENL_op_init(
461 .dumpit = drbd_adm_dump_resources,
462 ),
463 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY)
464 GENL_tla_expected(DRBD_NLA_RESOURCE_INFO, DRBD_GENLA_F_MANDATORY)
465 GENL_tla_expected(DRBD_NLA_RESOURCE_STATISTICS, DRBD_GENLA_F_MANDATORY))
466
467GENL_op(DRBD_ADM_GET_DEVICES, 31,
468 GENL_op_init(
469 .dumpit = drbd_adm_dump_devices,
470 .done = drbd_adm_dump_devices_done,
471 ),
472 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY)
473 GENL_tla_expected(DRBD_NLA_DEVICE_INFO, DRBD_GENLA_F_MANDATORY)
474 GENL_tla_expected(DRBD_NLA_DEVICE_STATISTICS, DRBD_GENLA_F_MANDATORY))
475
476GENL_op(DRBD_ADM_GET_CONNECTIONS, 32,
477 GENL_op_init(
478 .dumpit = drbd_adm_dump_connections,
479 .done = drbd_adm_dump_connections_done,
480 ),
481 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY)
482 GENL_tla_expected(DRBD_NLA_CONNECTION_INFO, DRBD_GENLA_F_MANDATORY)
483 GENL_tla_expected(DRBD_NLA_CONNECTION_STATISTICS, DRBD_GENLA_F_MANDATORY))
484
485GENL_op(DRBD_ADM_GET_PEER_DEVICES, 33,
486 GENL_op_init(
487 .dumpit = drbd_adm_dump_peer_devices,
488 .done = drbd_adm_dump_peer_devices_done,
489 ),
490 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY)
491 GENL_tla_expected(DRBD_NLA_PEER_DEVICE_INFO, DRBD_GENLA_F_MANDATORY)
492 GENL_tla_expected(DRBD_NLA_PEER_DEVICE_STATISTICS, DRBD_GENLA_F_MANDATORY))
493
Andreas Gruenbachera2972842014-07-31 17:41:33 +0200494GENL_notification(
495 DRBD_RESOURCE_STATE, 34, events,
496 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
497 GENL_tla_expected(DRBD_NLA_NOTIFICATION_HEADER, DRBD_F_REQUIRED)
498 GENL_tla_expected(DRBD_NLA_RESOURCE_INFO, DRBD_F_REQUIRED)
499 GENL_tla_expected(DRBD_NLA_RESOURCE_STATISTICS, DRBD_F_REQUIRED))
500
501GENL_notification(
502 DRBD_DEVICE_STATE, 35, events,
503 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
504 GENL_tla_expected(DRBD_NLA_NOTIFICATION_HEADER, DRBD_F_REQUIRED)
505 GENL_tla_expected(DRBD_NLA_DEVICE_INFO, DRBD_F_REQUIRED)
506 GENL_tla_expected(DRBD_NLA_DEVICE_STATISTICS, DRBD_F_REQUIRED))
507
508GENL_notification(
509 DRBD_CONNECTION_STATE, 36, events,
510 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
511 GENL_tla_expected(DRBD_NLA_NOTIFICATION_HEADER, DRBD_F_REQUIRED)
512 GENL_tla_expected(DRBD_NLA_CONNECTION_INFO, DRBD_F_REQUIRED)
513 GENL_tla_expected(DRBD_NLA_CONNECTION_STATISTICS, DRBD_F_REQUIRED))
514
515GENL_notification(
516 DRBD_PEER_DEVICE_STATE, 37, events,
517 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
518 GENL_tla_expected(DRBD_NLA_NOTIFICATION_HEADER, DRBD_F_REQUIRED)
519 GENL_tla_expected(DRBD_NLA_PEER_DEVICE_INFO, DRBD_F_REQUIRED)
520 GENL_tla_expected(DRBD_NLA_PEER_DEVICE_STATISTICS, DRBD_F_REQUIRED))
521
522GENL_op(
523 DRBD_ADM_GET_INITIAL_STATE, 38,
524 GENL_op_init(
525 .dumpit = drbd_adm_get_initial_state,
526 ),
527 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY))
528
529GENL_notification(
530 DRBD_HELPER, 40, events,
531 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
532 GENL_tla_expected(DRBD_NLA_HELPER, DRBD_F_REQUIRED))
533
534GENL_notification(
535 DRBD_INITIAL_STATE_DONE, 41, events,
536 GENL_tla_expected(DRBD_NLA_NOTIFICATION_HEADER, DRBD_F_REQUIRED))