blob: 938e8560a8333045cae588162c05e77958c522ac [file] [log] [blame]
Lars Ellenbergec2c35a2011-03-07 10:20:08 +01001/*
2 * General overview:
3 * full generic netlink message:
4 * |nlmsghdr|genlmsghdr|<payload>
5 *
6 * payload:
7 * |optional fixed size family header|<sequence of netlink attributes>
8 *
9 * sequence of netlink attributes:
10 * I chose to have all "top level" attributes NLA_NESTED,
11 * corresponding to some real struct.
12 * So we have a sequence of |tla, len|<nested nla sequence>
13 *
14 * nested nla sequence:
15 * may be empty, or contain a sequence of netlink attributes
16 * representing the struct fields.
17 *
18 * The tag number of any field (regardless of containing struct)
19 * will be available as T_ ## field_name,
20 * so you cannot have the same field name in two differnt structs.
21 *
22 * The tag numbers themselves are per struct, though,
23 * so should always begin at 1 (not 0, that is the special "NLA_UNSPEC" type,
24 * which we won't use here).
25 * The tag numbers are used as index in the respective nla_policy array.
26 *
27 * GENL_struct(tag_name, tag_number, struct name, struct fields) - struct and policy
28 * genl_magic_struct.h
29 * generates the struct declaration,
30 * generates an entry in the tla enum,
31 * genl_magic_func.h
32 * generates an entry in the static tla policy
33 * with .type = NLA_NESTED
34 * generates the static <struct_name>_nl_policy definition,
35 * and static conversion functions
36 *
37 * genl_magic_func.h
38 *
39 * GENL_mc_group(group)
40 * genl_magic_struct.h
41 * does nothing
42 * genl_magic_func.h
43 * defines and registers the mcast group,
44 * and provides a send helper
45 *
46 * GENL_notification(op_name, op_num, mcast_group, tla list)
47 * These are notifications to userspace.
48 *
49 * genl_magic_struct.h
50 * generates an entry in the genl_ops enum,
51 * genl_magic_func.h
52 * does nothing
53 *
54 * mcast group: the name of the mcast group this notification should be
55 * expected on
56 * tla list: the list of expected top level attributes,
57 * for documentation and sanity checking.
58 *
59 * GENL_op(op_name, op_num, flags and handler, tla list) - "genl operations"
60 * These are requests from userspace.
61 *
62 * _op and _notification share the same "number space",
63 * op_nr will be assigned to "genlmsghdr->cmd"
64 *
65 * genl_magic_struct.h
66 * generates an entry in the genl_ops enum,
67 * genl_magic_func.h
68 * generates an entry in the static genl_ops array,
69 * and static register/unregister functions to
70 * genl_register_family_with_ops().
71 *
72 * flags and handler:
73 * GENL_op_init( .doit = x, .dumpit = y, .flags = something)
74 * GENL_doit(x) => .dumpit = NULL, .flags = GENL_ADMIN_PERM
75 * tla list: the list of expected top level attributes,
76 * for documentation and sanity checking.
77 */
78
79/*
80 * STRUCTS
81 */
82
83/* this is sent kernel -> userland on various error conditions, and contains
84 * informational textual info, which is supposedly human readable.
85 * The computer relevant return code is in the drbd_genlmsghdr.
86 */
87GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply,
88 /* "arbitrary" size strings, nla_policy.len = 0 */
89 __str_field(1, GENLA_F_MANDATORY, info_text, 0)
90)
91
92/* Configuration requests typically need a context to operate on.
93 * Possible keys are device minor (fits in the drbd_genlmsghdr),
94 * the replication link (aka connection) name,
95 * and/or the replication group (aka resource) name,
96 * and the volume id within the resource. */
97GENL_struct(DRBD_NLA_CFG_CONTEXT, 2, drbd_cfg_context,
98 /* currently only 256 volumes per group,
99 * but maybe we still change that */
100 __u32_field(1, GENLA_F_MANDATORY, ctx_volume)
101 __str_field(2, GENLA_F_MANDATORY, ctx_conn_name, 128)
102)
103
104GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf,
Lars Ellenbergf3990022011-03-23 14:31:09 +0100105 __str_field(1, GENLA_F_REQUIRED | GENLA_F_INVARIANT, backing_dev, 128)
106 __str_field(2, GENLA_F_REQUIRED | GENLA_F_INVARIANT, meta_dev, 128)
107 __u32_field(3, GENLA_F_REQUIRED | GENLA_F_INVARIANT, meta_dev_idx)
108
109 /* use the resize command to try and change the disk_size */
110 __u64_field(4, GENLA_F_MANDATORY | GENLA_F_INVARIANT, disk_size)
111 /* we could change the max_bio_bvecs,
112 * but it won't propagate through the stack */
113 __u32_field(5, GENLA_F_MANDATORY | GENLA_F_INVARIANT, max_bio_bvecs)
114
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100115 __u32_field(6, GENLA_F_MANDATORY, on_io_error)
116 __u32_field(7, GENLA_F_MANDATORY, fencing)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100117
118 __u32_field(8, GENLA_F_MANDATORY, resync_rate)
119 __u32_field(9, GENLA_F_MANDATORY, resync_after)
120 __u32_field(10, GENLA_F_MANDATORY, al_extents)
121 __u32_field(11, GENLA_F_MANDATORY, c_plan_ahead)
122 __u32_field(12, GENLA_F_MANDATORY, c_delay_target)
123 __u32_field(13, GENLA_F_MANDATORY, c_fill_target)
124 __u32_field(14, GENLA_F_MANDATORY, c_max_rate)
125 __u32_field(15, GENLA_F_MANDATORY, c_min_rate)
126
127 __flg_field(16, GENLA_F_MANDATORY, no_disk_barrier)
128 __flg_field(17, GENLA_F_MANDATORY, no_disk_flush)
129 __flg_field(18, GENLA_F_MANDATORY, no_disk_drain)
130 __flg_field(19, GENLA_F_MANDATORY, no_md_flush)
131
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100132)
133
Lars Ellenbergf3990022011-03-23 14:31:09 +0100134GENL_struct(DRBD_NLA_RESOURCE_OPTS, 4, res_opts,
135 __str_field(1, GENLA_F_MANDATORY, cpu_mask, 32)
136 __u32_field(2, GENLA_F_MANDATORY, on_no_data)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100137)
138
139GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf,
Lars Ellenbergf3990022011-03-23 14:31:09 +0100140 __bin_field(1, GENLA_F_REQUIRED | GENLA_F_INVARIANT, my_addr, 128)
141 __bin_field(2, GENLA_F_REQUIRED | GENLA_F_INVARIANT, peer_addr, 128)
142 __str_field(3, GENLA_F_MANDATORY | GENLA_F_SENSITIVE,
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100143 shared_secret, SHARED_SECRET_MAX)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100144 __str_field(4, GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX)
145 __str_field(5, GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX)
146 __str_field(6, GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX)
147 __str_field(7, GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX)
148 __u32_field(8, GENLA_F_MANDATORY, wire_protocol)
149 __u32_field(9, GENLA_F_MANDATORY, try_connect_int)
150 __u32_field(10, GENLA_F_MANDATORY, timeout)
151 __u32_field(11, GENLA_F_MANDATORY, ping_int)
152 __u32_field(12, GENLA_F_MANDATORY, ping_timeo)
153 __u32_field(13, GENLA_F_MANDATORY, sndbuf_size)
154 __u32_field(14, GENLA_F_MANDATORY, rcvbuf_size)
155 __u32_field(15, GENLA_F_MANDATORY, ko_count)
156 __u32_field(16, GENLA_F_MANDATORY, max_buffers)
157 __u32_field(17, GENLA_F_MANDATORY, max_epoch_size)
158 __u32_field(18, GENLA_F_MANDATORY, unplug_watermark)
159 __u32_field(19, GENLA_F_MANDATORY, after_sb_0p)
160 __u32_field(20, GENLA_F_MANDATORY, after_sb_1p)
161 __u32_field(21, GENLA_F_MANDATORY, after_sb_2p)
162 __u32_field(22, GENLA_F_MANDATORY, rr_conflict)
163 __u32_field(23, GENLA_F_MANDATORY, on_congestion)
164 __u32_field(24, GENLA_F_MANDATORY, cong_fill)
165 __u32_field(25, GENLA_F_MANDATORY, cong_extents)
166 __flg_field(26, GENLA_F_MANDATORY, two_primaries)
167 __flg_field(27, GENLA_F_MANDATORY | GENLA_F_INVARIANT, want_lose)
168 __flg_field(28, GENLA_F_MANDATORY, no_cork)
169 __flg_field(29, GENLA_F_MANDATORY, always_asbp)
170 __flg_field(30, GENLA_F_MANDATORY | GENLA_F_INVARIANT, dry_run)
171 __flg_field(31, GENLA_F_MANDATORY, use_rle)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100172)
173
174GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms,
175 __flg_field(1, GENLA_F_MANDATORY, assume_uptodate)
176)
177
178GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms,
179 __u64_field(1, GENLA_F_MANDATORY, resize_size)
180 __flg_field(2, GENLA_F_MANDATORY, resize_force)
181 __flg_field(3, GENLA_F_MANDATORY, no_resync)
182)
183
184GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info,
185 /* the reason of the broadcast,
186 * if this is an event triggered broadcast. */
187 __u32_field(1, GENLA_F_MANDATORY, sib_reason)
188 __u32_field(2, GENLA_F_REQUIRED, current_state)
189 __u64_field(3, GENLA_F_MANDATORY, capacity)
190 __u64_field(4, GENLA_F_MANDATORY, ed_uuid)
191
192 /* These are for broadcast from after state change work.
193 * prev_state and new_state are from the moment the state change took
194 * place, new_state is not neccessarily the same as current_state,
195 * there may have been more state changes since. Which will be
196 * broadcasted soon, in their respective after state change work. */
197 __u32_field(5, GENLA_F_MANDATORY, prev_state)
198 __u32_field(6, GENLA_F_MANDATORY, new_state)
199
200 /* if we have a local disk: */
201 __bin_field(7, GENLA_F_MANDATORY, uuids, (UI_SIZE*sizeof(__u64)))
202 __u32_field(8, GENLA_F_MANDATORY, disk_flags)
203 __u64_field(9, GENLA_F_MANDATORY, bits_total)
204 __u64_field(10, GENLA_F_MANDATORY, bits_oos)
205 /* and in case resync or online verify is active */
206 __u64_field(11, GENLA_F_MANDATORY, bits_rs_total)
207 __u64_field(12, GENLA_F_MANDATORY, bits_rs_failed)
208
209 /* for pre and post notifications of helper execution */
210 __str_field(13, GENLA_F_MANDATORY, helper, 32)
211 __u32_field(14, GENLA_F_MANDATORY, helper_exit_code)
212)
213
214GENL_struct(DRBD_NLA_START_OV_PARMS, 9, start_ov_parms,
215 __u64_field(1, GENLA_F_MANDATORY, ov_start_sector)
216)
217
218GENL_struct(DRBD_NLA_NEW_C_UUID_PARMS, 10, new_c_uuid_parms,
219 __flg_field(1, GENLA_F_MANDATORY, clear_bm)
220)
221
222GENL_struct(DRBD_NLA_TIMEOUT_PARMS, 11, timeout_parms,
223 __u32_field(1, GENLA_F_REQUIRED, timeout_type)
224)
225
226GENL_struct(DRBD_NLA_DISCONNECT_PARMS, 12, disconnect_parms,
227 __flg_field(1, GENLA_F_MANDATORY, force_disconnect)
228)
229
230/*
231 * Notifications and commands (genlmsghdr->cmd)
232 */
233GENL_mc_group(events)
234
235 /* kernel -> userspace announcement of changes */
236GENL_notification(
237 DRBD_EVENT, 1, events,
238 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
239 GENL_tla_expected(DRBD_NLA_STATE_INFO, GENLA_F_REQUIRED)
240 GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_MANDATORY)
241 GENL_tla_expected(DRBD_NLA_DISK_CONF, GENLA_F_MANDATORY)
242 GENL_tla_expected(DRBD_NLA_SYNCER_CONF, GENLA_F_MANDATORY)
243)
244
245 /* query kernel for specific or all info */
246GENL_op(
247 DRBD_ADM_GET_STATUS, 2,
248 GENL_op_init(
249 .doit = drbd_adm_get_status,
250 .dumpit = drbd_adm_get_status_all,
251 /* anyone may ask for the status,
252 * it is broadcasted anyways */
253 ),
254 /* To select the object .doit.
255 * Or a subset of objects in .dumpit. */
256 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_MANDATORY)
257)
258
259#if 0
260 /* TO BE DONE */
261 /* create or destroy resources, aka replication groups */
262GENL_op(DRBD_ADM_CREATE_RESOURCE, 3, GENL_doit(drbd_adm_create_resource),
263 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
264GENL_op(DRBD_ADM_DELETE_RESOURCE, 4, GENL_doit(drbd_adm_delete_resource),
265 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
266#endif
267
268 /* add DRBD minor devices as volumes to resources */
269GENL_op(DRBD_ADM_ADD_MINOR, 5, GENL_doit(drbd_adm_add_minor),
270 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
271GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_delete_minor),
272 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
273
274 /* add or delete replication links to resources */
275GENL_op(DRBD_ADM_ADD_LINK, 7, GENL_doit(drbd_adm_create_connection),
276 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
277GENL_op(DRBD_ADM_DEL_LINK, 8, GENL_doit(drbd_adm_delete_connection),
278 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
279
Lars Ellenbergf3990022011-03-23 14:31:09 +0100280GENL_op(DRBD_ADM_RESOURCE_OPTS, 9,
281 GENL_doit(drbd_adm_resource_opts),
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100282 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
Lars Ellenbergf3990022011-03-23 14:31:09 +0100283 GENL_tla_expected(DRBD_NLA_RESOURCE_OPTS, GENLA_F_MANDATORY)
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100284)
285
286GENL_op(
287 DRBD_ADM_CONNECT, 10,
288 GENL_doit(drbd_adm_connect),
289 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
290 GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_REQUIRED)
291)
292
Lars Ellenbergf3990022011-03-23 14:31:09 +0100293GENL_op(
294 DRBD_ADM_CHG_NET_OPTS, 29,
295 GENL_doit(drbd_adm_net_opts),
296 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
297 GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_REQUIRED)
298)
299
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100300GENL_op(DRBD_ADM_DISCONNECT, 11, GENL_doit(drbd_adm_disconnect),
301 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
302
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100303GENL_op(DRBD_ADM_ATTACH, 12,
304 GENL_doit(drbd_adm_attach),
305 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
306 GENL_tla_expected(DRBD_NLA_DISK_CONF, GENLA_F_REQUIRED)
307)
308
Lars Ellenbergf3990022011-03-23 14:31:09 +0100309GENL_op(DRBD_ADM_CHG_DISK_OPTS, 28,
310 GENL_doit(drbd_adm_disk_opts),
311 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
312 GENL_tla_expected(DRBD_NLA_DISK_OPTS, GENLA_F_REQUIRED)
313)
314
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100315GENL_op(
316 DRBD_ADM_RESIZE, 13,
317 GENL_doit(drbd_adm_resize),
318 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
319 GENL_tla_expected(DRBD_NLA_RESIZE_PARMS, GENLA_F_MANDATORY)
320)
321
Lars Ellenbergec2c35a2011-03-07 10:20:08 +0100322GENL_op(
323 DRBD_ADM_PRIMARY, 14,
324 GENL_doit(drbd_adm_set_role),
325 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
326 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, GENLA_F_REQUIRED)
327)
328
329GENL_op(
330 DRBD_ADM_SECONDARY, 15,
331 GENL_doit(drbd_adm_set_role),
332 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
333 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, GENLA_F_REQUIRED)
334)
335
336GENL_op(
337 DRBD_ADM_NEW_C_UUID, 16,
338 GENL_doit(drbd_adm_new_c_uuid),
339 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)
340 GENL_tla_expected(DRBD_NLA_NEW_C_UUID_PARMS, GENLA_F_MANDATORY)
341)
342
343GENL_op(
344 DRBD_ADM_START_OV, 17,
345 GENL_doit(drbd_adm_start_ov),
346 GENL_tla_expected(DRBD_NLA_START_OV_PARMS, GENLA_F_MANDATORY)
347)
348
349GENL_op(DRBD_ADM_DETACH, 18, GENL_doit(drbd_adm_detach),
350 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
351GENL_op(DRBD_ADM_INVALIDATE, 19, GENL_doit(drbd_adm_invalidate),
352 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
353GENL_op(DRBD_ADM_INVAL_PEER, 20, GENL_doit(drbd_adm_invalidate_peer),
354 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
355GENL_op(DRBD_ADM_PAUSE_SYNC, 21, GENL_doit(drbd_adm_pause_sync),
356 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
357GENL_op(DRBD_ADM_RESUME_SYNC, 22, GENL_doit(drbd_adm_resume_sync),
358 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
359GENL_op(DRBD_ADM_SUSPEND_IO, 23, GENL_doit(drbd_adm_suspend_io),
360 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
361GENL_op(DRBD_ADM_RESUME_IO, 24, GENL_doit(drbd_adm_resume_io),
362 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
363GENL_op(DRBD_ADM_OUTDATE, 25, GENL_doit(drbd_adm_outdate),
364 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
365GENL_op(DRBD_ADM_GET_TIMEOUT_TYPE, 26, GENL_doit(drbd_adm_get_timeout_type),
366 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))
Lars Ellenberg85f75dd72011-03-15 16:26:37 +0100367GENL_op(DRBD_ADM_DOWN, 27, GENL_doit(drbd_adm_down),
368 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED))