aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/drbd_genl.h244
-rw-r--r--include/linux/genl_magic_func.h107
-rw-r--r--include/linux/genl_magic_struct.h64
3 files changed, 193 insertions, 222 deletions
diff --git a/include/linux/drbd_genl.h b/include/linux/drbd_genl.h
index 7b174a093a8d..4ceecb9307d9 100644
--- a/include/linux/drbd_genl.h
+++ b/include/linux/drbd_genl.h
@@ -86,7 +86,7 @@
86 */ 86 */
87GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply, 87GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply,
88 /* "arbitrary" size strings, nla_policy.len = 0 */ 88 /* "arbitrary" size strings, nla_policy.len = 0 */
89 __str_field(1, GENLA_F_MANDATORY, info_text, 0) 89 __str_field(1, DRBD_GENLA_F_MANDATORY, info_text, 0)
90) 90)
91 91
92/* Configuration requests typically need a context to operate on. 92/* Configuration requests typically need a context to operate on.
@@ -95,133 +95,133 @@ GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply,
95 * and/or the replication group (aka resource) name, 95 * and/or the replication group (aka resource) name,
96 * and the volume id within the resource. */ 96 * and the volume id within the resource. */
97GENL_struct(DRBD_NLA_CFG_CONTEXT, 2, drbd_cfg_context, 97GENL_struct(DRBD_NLA_CFG_CONTEXT, 2, drbd_cfg_context,
98 __u32_field(1, GENLA_F_MANDATORY, ctx_volume) 98 __u32_field(1, DRBD_GENLA_F_MANDATORY, ctx_volume)
99 __str_field(2, GENLA_F_MANDATORY, ctx_conn_name, 128) 99 __str_field(2, DRBD_GENLA_F_MANDATORY, ctx_conn_name, 128)
100) 100)
101 101
102GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf, 102GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf,
103 __str_field(1, GENLA_F_REQUIRED | GENLA_F_INVARIANT, backing_dev, 128) 103 __str_field(1, DRBD_F_REQUIRED | DRBD_F_INVARIANT, backing_dev, 128)
104 __str_field(2, GENLA_F_REQUIRED | GENLA_F_INVARIANT, meta_dev, 128) 104 __str_field(2, DRBD_F_REQUIRED | DRBD_F_INVARIANT, meta_dev, 128)
105 __s32_field(3, GENLA_F_REQUIRED | GENLA_F_INVARIANT, meta_dev_idx) 105 __s32_field(3, DRBD_F_REQUIRED | DRBD_F_INVARIANT, meta_dev_idx)
106 106
107 /* use the resize command to try and change the disk_size */ 107 /* use the resize command to try and change the disk_size */
108 __u64_field(4, GENLA_F_MANDATORY | GENLA_F_INVARIANT, disk_size) 108 __u64_field(4, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, disk_size)
109 /* we could change the max_bio_bvecs, 109 /* we could change the max_bio_bvecs,
110 * but it won't propagate through the stack */ 110 * but it won't propagate through the stack */
111 __u32_field(5, GENLA_F_MANDATORY | GENLA_F_INVARIANT, max_bio_bvecs) 111 __u32_field(5, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, max_bio_bvecs)
112 112
113 __u32_field_def(6, GENLA_F_MANDATORY, on_io_error, DRBD_ON_IO_ERROR_DEF) 113 __u32_field_def(6, DRBD_GENLA_F_MANDATORY, on_io_error, DRBD_ON_IO_ERROR_DEF)
114 __u32_field_def(7, GENLA_F_MANDATORY, fencing, DRBD_FENCING_DEF) 114 __u32_field_def(7, DRBD_GENLA_F_MANDATORY, fencing, DRBD_FENCING_DEF)
115 115
116 __u32_field_def(8, GENLA_F_MANDATORY, resync_rate, DRBD_RESYNC_RATE_DEF) 116 __u32_field_def(8, DRBD_GENLA_F_MANDATORY, resync_rate, DRBD_RESYNC_RATE_DEF)
117 __s32_field_def(9, GENLA_F_MANDATORY, resync_after, DRBD_RESYNC_AFTER_DEF) 117 __s32_field_def(9, DRBD_GENLA_F_MANDATORY, resync_after, DRBD_MINOR_NUMBER_DEF)
118 __u32_field_def(10, GENLA_F_MANDATORY, al_extents, DRBD_AL_EXTENTS_DEF) 118 __u32_field_def(10, DRBD_GENLA_F_MANDATORY, al_extents, DRBD_AL_EXTENTS_DEF)
119 __u32_field_def(11, GENLA_F_MANDATORY, c_plan_ahead, DRBD_C_PLAN_AHEAD_DEF) 119 __u32_field_def(11, DRBD_GENLA_F_MANDATORY, c_plan_ahead, DRBD_C_PLAN_AHEAD_DEF)
120 __u32_field_def(12, GENLA_F_MANDATORY, c_delay_target, DRBD_C_DELAY_TARGET_DEF) 120 __u32_field_def(12, DRBD_GENLA_F_MANDATORY, c_delay_target, DRBD_C_DELAY_TARGET_DEF)
121 __u32_field_def(13, GENLA_F_MANDATORY, c_fill_target, DRBD_C_FILL_TARGET_DEF) 121 __u32_field_def(13, DRBD_GENLA_F_MANDATORY, c_fill_target, DRBD_C_FILL_TARGET_DEF)
122 __u32_field_def(14, GENLA_F_MANDATORY, c_max_rate, DRBD_C_MAX_RATE_DEF) 122 __u32_field_def(14, DRBD_GENLA_F_MANDATORY, c_max_rate, DRBD_C_MAX_RATE_DEF)
123 __u32_field_def(15, GENLA_F_MANDATORY, c_min_rate, DRBD_C_MIN_RATE_DEF) 123 __u32_field_def(15, DRBD_GENLA_F_MANDATORY, c_min_rate, DRBD_C_MIN_RATE_DEF)
124 124
125 __flg_field_def(16, GENLA_F_MANDATORY, disk_barrier, DRBD_DISK_BARRIER_DEF) 125 __flg_field_def(16, DRBD_GENLA_F_MANDATORY, disk_barrier, DRBD_DISK_BARRIER_DEF)
126 __flg_field_def(17, GENLA_F_MANDATORY, disk_flushes, DRBD_DISK_FLUSHES_DEF) 126 __flg_field_def(17, DRBD_GENLA_F_MANDATORY, disk_flushes, DRBD_DISK_FLUSHES_DEF)
127 __flg_field_def(18, GENLA_F_MANDATORY, disk_drain, DRBD_DISK_DRAIN_DEF) 127 __flg_field_def(18, DRBD_GENLA_F_MANDATORY, disk_drain, DRBD_DISK_DRAIN_DEF)
128 __flg_field_def(19, GENLA_F_MANDATORY, md_flushes, DRBD_MD_FLUSHES_DEF) 128 __flg_field_def(19, DRBD_GENLA_F_MANDATORY, md_flushes, DRBD_MD_FLUSHES_DEF)
129) 129)
130 130
131GENL_struct(DRBD_NLA_RESOURCE_OPTS, 4, res_opts, 131GENL_struct(DRBD_NLA_RESOURCE_OPTS, 4, res_opts,
132 __str_field_def(1, GENLA_F_MANDATORY, cpu_mask, 32) 132 __str_field_def(1, DRBD_GENLA_F_MANDATORY, cpu_mask, 32)
133 __u32_field_def(2, GENLA_F_MANDATORY, on_no_data, DRBD_ON_NO_DATA_DEF) 133 __u32_field_def(2, DRBD_GENLA_F_MANDATORY, on_no_data, DRBD_ON_NO_DATA_DEF)
134) 134)
135 135
136GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf, 136GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf,
137 __bin_field(1, GENLA_F_REQUIRED | GENLA_F_INVARIANT, my_addr, 128) 137 __bin_field(1, DRBD_F_REQUIRED | DRBD_F_INVARIANT, my_addr, 128)
138 __bin_field(2, GENLA_F_REQUIRED | GENLA_F_INVARIANT, peer_addr, 128) 138 __bin_field(2, DRBD_F_REQUIRED | DRBD_F_INVARIANT, peer_addr, 128)
139 __str_field_def(3, GENLA_F_MANDATORY | GENLA_F_SENSITIVE, 139 __str_field_def(3, DRBD_GENLA_F_MANDATORY | DRBD_F_SENSITIVE,
140 shared_secret, SHARED_SECRET_MAX) 140 shared_secret, SHARED_SECRET_MAX)
141 __str_field_def(4, GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX) 141 __str_field_def(4, DRBD_GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX)
142 __str_field_def(5, GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX) 142 __str_field_def(5, DRBD_GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX)
143 __str_field_def(6, GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX) 143 __str_field_def(6, DRBD_GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX)
144 __str_field_def(7, GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX) 144 __str_field_def(7, DRBD_GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX)
145 __u32_field_def(8, GENLA_F_MANDATORY, wire_protocol, DRBD_PROTOCOL_DEF) 145 __u32_field_def(8, DRBD_GENLA_F_MANDATORY, wire_protocol, DRBD_PROTOCOL_DEF)
146 __u32_field_def(9, GENLA_F_MANDATORY, connect_int, DRBD_CONNECT_INT_DEF) 146 __u32_field_def(9, DRBD_GENLA_F_MANDATORY, connect_int, DRBD_CONNECT_INT_DEF)
147 __u32_field_def(10, GENLA_F_MANDATORY, timeout, DRBD_TIMEOUT_DEF) 147 __u32_field_def(10, DRBD_GENLA_F_MANDATORY, timeout, DRBD_TIMEOUT_DEF)
148 __u32_field_def(11, GENLA_F_MANDATORY, ping_int, DRBD_PING_INT_DEF) 148 __u32_field_def(11, DRBD_GENLA_F_MANDATORY, ping_int, DRBD_PING_INT_DEF)
149 __u32_field_def(12, GENLA_F_MANDATORY, ping_timeo, DRBD_PING_TIMEO_DEF) 149 __u32_field_def(12, DRBD_GENLA_F_MANDATORY, ping_timeo, DRBD_PING_TIMEO_DEF)
150 __u32_field_def(13, GENLA_F_MANDATORY, sndbuf_size, DRBD_SNDBUF_SIZE_DEF) 150 __u32_field_def(13, DRBD_GENLA_F_MANDATORY, sndbuf_size, DRBD_SNDBUF_SIZE_DEF)
151 __u32_field_def(14, GENLA_F_MANDATORY, rcvbuf_size, DRBD_RCVBUF_SIZE_DEF) 151 __u32_field_def(14, DRBD_GENLA_F_MANDATORY, rcvbuf_size, DRBD_RCVBUF_SIZE_DEF)
152 __u32_field_def(15, GENLA_F_MANDATORY, ko_count, DRBD_KO_COUNT_DEF) 152 __u32_field_def(15, DRBD_GENLA_F_MANDATORY, ko_count, DRBD_KO_COUNT_DEF)
153 __u32_field_def(16, GENLA_F_MANDATORY, max_buffers, DRBD_MAX_BUFFERS_DEF) 153 __u32_field_def(16, DRBD_GENLA_F_MANDATORY, max_buffers, DRBD_MAX_BUFFERS_DEF)
154 __u32_field_def(17, GENLA_F_MANDATORY, max_epoch_size, DRBD_MAX_EPOCH_SIZE_DEF) 154 __u32_field_def(17, DRBD_GENLA_F_MANDATORY, max_epoch_size, DRBD_MAX_EPOCH_SIZE_DEF)
155 __u32_field_def(18, GENLA_F_MANDATORY, unplug_watermark, DRBD_UNPLUG_WATERMARK_DEF) 155 __u32_field_def(18, DRBD_GENLA_F_MANDATORY, unplug_watermark, DRBD_UNPLUG_WATERMARK_DEF)
156 __u32_field_def(19, GENLA_F_MANDATORY, after_sb_0p, DRBD_AFTER_SB_0P_DEF) 156 __u32_field_def(19, DRBD_GENLA_F_MANDATORY, after_sb_0p, DRBD_AFTER_SB_0P_DEF)
157 __u32_field_def(20, GENLA_F_MANDATORY, after_sb_1p, DRBD_AFTER_SB_1P_DEF) 157 __u32_field_def(20, DRBD_GENLA_F_MANDATORY, after_sb_1p, DRBD_AFTER_SB_1P_DEF)
158 __u32_field_def(21, GENLA_F_MANDATORY, after_sb_2p, DRBD_AFTER_SB_2P_DEF) 158 __u32_field_def(21, DRBD_GENLA_F_MANDATORY, after_sb_2p, DRBD_AFTER_SB_2P_DEF)
159 __u32_field_def(22, GENLA_F_MANDATORY, rr_conflict, DRBD_RR_CONFLICT_DEF) 159 __u32_field_def(22, DRBD_GENLA_F_MANDATORY, rr_conflict, DRBD_RR_CONFLICT_DEF)
160 __u32_field_def(23, GENLA_F_MANDATORY, on_congestion, DRBD_ON_CONGESTION_DEF) 160 __u32_field_def(23, DRBD_GENLA_F_MANDATORY, on_congestion, DRBD_ON_CONGESTION_DEF)
161 __u32_field_def(24, GENLA_F_MANDATORY, cong_fill, DRBD_CONG_FILL_DEF) 161 __u32_field_def(24, DRBD_GENLA_F_MANDATORY, cong_fill, DRBD_CONG_FILL_DEF)
162 __u32_field_def(25, GENLA_F_MANDATORY, cong_extents, DRBD_CONG_EXTENTS_DEF) 162 __u32_field_def(25, DRBD_GENLA_F_MANDATORY, cong_extents, DRBD_CONG_EXTENTS_DEF)
163 __flg_field_def(26, GENLA_F_MANDATORY, two_primaries, DRBD_ALLOW_TWO_PRIMARIES_DEF) 163 __flg_field_def(26, DRBD_GENLA_F_MANDATORY, two_primaries, DRBD_ALLOW_TWO_PRIMARIES_DEF)
164 __flg_field(27, GENLA_F_MANDATORY | GENLA_F_INVARIANT, discard_my_data) 164 __flg_field(27, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, discard_my_data)
165 __flg_field_def(28, GENLA_F_MANDATORY, tcp_cork, DRBD_TCP_CORK_DEF) 165 __flg_field_def(28, DRBD_GENLA_F_MANDATORY, tcp_cork, DRBD_TCP_CORK_DEF)
166 __flg_field_def(29, GENLA_F_MANDATORY, always_asbp, DRBD_ALWAYS_ASBP_DEF) 166 __flg_field_def(29, DRBD_GENLA_F_MANDATORY, always_asbp, DRBD_ALWAYS_ASBP_DEF)
167 __flg_field(30, GENLA_F_MANDATORY | GENLA_F_INVARIANT, dry_run) 167 __flg_field(30, DRBD_GENLA_F_MANDATORY | DRBD_F_INVARIANT, dry_run)
168 __flg_field_def(31, GENLA_F_MANDATORY, use_rle, DRBD_USE_RLE_DEF) 168 __flg_field_def(31, DRBD_GENLA_F_MANDATORY, use_rle, DRBD_USE_RLE_DEF)
169) 169)
170 170
171GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms, 171GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms,
172 __flg_field(1, GENLA_F_MANDATORY, assume_uptodate) 172 __flg_field(1, DRBD_GENLA_F_MANDATORY, assume_uptodate)
173) 173)
174 174
175GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms, 175GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms,
176 __u64_field(1, GENLA_F_MANDATORY, resize_size) 176 __u64_field(1, DRBD_GENLA_F_MANDATORY, resize_size)
177 __flg_field(2, GENLA_F_MANDATORY, resize_force) 177 __flg_field(2, DRBD_GENLA_F_MANDATORY, resize_force)
178 __flg_field(3, GENLA_F_MANDATORY, no_resync) 178 __flg_field(3, DRBD_GENLA_F_MANDATORY, no_resync)
179) 179)
180 180
181GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info, 181GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info,
182 /* the reason of the broadcast, 182 /* the reason of the broadcast,
183 * if this is an event triggered broadcast. */ 183 * if this is an event triggered broadcast. */
184 __u32_field(1, GENLA_F_MANDATORY, sib_reason) 184 __u32_field(1, DRBD_GENLA_F_MANDATORY, sib_reason)
185 __u32_field(2, GENLA_F_REQUIRED, current_state) 185 __u32_field(2, DRBD_F_REQUIRED, current_state)
186 __u64_field(3, GENLA_F_MANDATORY, capacity) 186 __u64_field(3, DRBD_GENLA_F_MANDATORY, capacity)
187 __u64_field(4, GENLA_F_MANDATORY, ed_uuid) 187 __u64_field(4, DRBD_GENLA_F_MANDATORY, ed_uuid)
188 188
189 /* These are for broadcast from after state change work. 189 /* These are for broadcast from after state change work.
190 * prev_state and new_state are from the moment the state change took 190 * prev_state and new_state are from the moment the state change took
191 * place, new_state is not neccessarily the same as current_state, 191 * place, new_state is not neccessarily the same as current_state,
192 * there may have been more state changes since. Which will be 192 * there may have been more state changes since. Which will be
193 * broadcasted soon, in their respective after state change work. */ 193 * broadcasted soon, in their respective after state change work. */
194 __u32_field(5, GENLA_F_MANDATORY, prev_state) 194 __u32_field(5, DRBD_GENLA_F_MANDATORY, prev_state)
195 __u32_field(6, GENLA_F_MANDATORY, new_state) 195 __u32_field(6, DRBD_GENLA_F_MANDATORY, new_state)
196 196
197 /* if we have a local disk: */ 197 /* if we have a local disk: */
198 __bin_field(7, GENLA_F_MANDATORY, uuids, (UI_SIZE*sizeof(__u64))) 198 __bin_field(7, DRBD_GENLA_F_MANDATORY, uuids, (UI_SIZE*sizeof(__u64)))
199 __u32_field(8, GENLA_F_MANDATORY, disk_flags) 199 __u32_field(8, DRBD_GENLA_F_MANDATORY, disk_flags)
200 __u64_field(9, GENLA_F_MANDATORY, bits_total) 200 __u64_field(9, DRBD_GENLA_F_MANDATORY, bits_total)
201 __u64_field(10, GENLA_F_MANDATORY, bits_oos) 201 __u64_field(10, DRBD_GENLA_F_MANDATORY, bits_oos)
202 /* and in case resync or online verify is active */ 202 /* and in case resync or online verify is active */
203 __u64_field(11, GENLA_F_MANDATORY, bits_rs_total) 203 __u64_field(11, DRBD_GENLA_F_MANDATORY, bits_rs_total)
204 __u64_field(12, GENLA_F_MANDATORY, bits_rs_failed) 204 __u64_field(12, DRBD_GENLA_F_MANDATORY, bits_rs_failed)
205 205
206 /* for pre and post notifications of helper execution */ 206 /* for pre and post notifications of helper execution */
207 __str_field(13, GENLA_F_MANDATORY, helper, 32) 207 __str_field(13, DRBD_GENLA_F_MANDATORY, helper, 32)
208 __u32_field(14, GENLA_F_MANDATORY, helper_exit_code) 208 __u32_field(14, DRBD_GENLA_F_MANDATORY, helper_exit_code)
209) 209)
210 210
211GENL_struct(DRBD_NLA_START_OV_PARMS, 9, start_ov_parms, 211GENL_struct(DRBD_NLA_START_OV_PARMS, 9, start_ov_parms,
212 __u64_field(1, GENLA_F_MANDATORY, ov_start_sector) 212 __u64_field(1, DRBD_GENLA_F_MANDATORY, ov_start_sector)
213) 213)
214 214
215GENL_struct(DRBD_NLA_NEW_C_UUID_PARMS, 10, new_c_uuid_parms, 215GENL_struct(DRBD_NLA_NEW_C_UUID_PARMS, 10, new_c_uuid_parms,
216 __flg_field(1, GENLA_F_MANDATORY, clear_bm) 216 __flg_field(1, DRBD_GENLA_F_MANDATORY, clear_bm)
217) 217)
218 218
219GENL_struct(DRBD_NLA_TIMEOUT_PARMS, 11, timeout_parms, 219GENL_struct(DRBD_NLA_TIMEOUT_PARMS, 11, timeout_parms,
220 __u32_field(1, GENLA_F_REQUIRED, timeout_type) 220 __u32_field(1, DRBD_F_REQUIRED, timeout_type)
221) 221)
222 222
223GENL_struct(DRBD_NLA_DISCONNECT_PARMS, 12, disconnect_parms, 223GENL_struct(DRBD_NLA_DISCONNECT_PARMS, 12, disconnect_parms,
224 __flg_field(1, GENLA_F_MANDATORY, force_disconnect) 224 __flg_field(1, DRBD_GENLA_F_MANDATORY, force_disconnect)
225) 225)
226 226
227/* 227/*
@@ -232,11 +232,11 @@ GENL_mc_group(events)
232 /* kernel -> userspace announcement of changes */ 232 /* kernel -> userspace announcement of changes */
233GENL_notification( 233GENL_notification(
234 DRBD_EVENT, 1, events, 234 DRBD_EVENT, 1, events,
235 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 235 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
236 GENL_tla_expected(DRBD_NLA_STATE_INFO, GENLA_F_REQUIRED) 236 GENL_tla_expected(DRBD_NLA_STATE_INFO, DRBD_F_REQUIRED)
237 GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_MANDATORY) 237 GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_GENLA_F_MANDATORY)
238 GENL_tla_expected(DRBD_NLA_DISK_CONF, GENLA_F_MANDATORY) 238 GENL_tla_expected(DRBD_NLA_DISK_CONF, DRBD_GENLA_F_MANDATORY)
239 GENL_tla_expected(DRBD_NLA_SYNCER_CONF, GENLA_F_MANDATORY) 239 GENL_tla_expected(DRBD_NLA_SYNCER_CONF, DRBD_GENLA_F_MANDATORY)
240) 240)
241 241
242 /* query kernel for specific or all info */ 242 /* query kernel for specific or all info */
@@ -250,116 +250,116 @@ GENL_op(
250 ), 250 ),
251 /* To select the object .doit. 251 /* To select the object .doit.
252 * Or a subset of objects in .dumpit. */ 252 * Or a subset of objects in .dumpit. */
253 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_MANDATORY) 253 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_GENLA_F_MANDATORY)
254) 254)
255 255
256#if 0 256#if 0
257 /* TO BE DONE */ 257 /* TO BE DONE */
258 /* create or destroy resources, aka replication groups */ 258 /* create or destroy resources, aka replication groups */
259GENL_op(DRBD_ADM_CREATE_RESOURCE, 3, GENL_doit(drbd_adm_create_resource), 259GENL_op(DRBD_ADM_CREATE_RESOURCE, 3, GENL_doit(drbd_adm_create_resource),
260 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 260 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
261GENL_op(DRBD_ADM_DELETE_RESOURCE, 4, GENL_doit(drbd_adm_delete_resource), 261GENL_op(DRBD_ADM_DELETE_RESOURCE, 4, GENL_doit(drbd_adm_delete_resource),
262 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 262 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
263#endif 263#endif
264 264
265 /* add DRBD minor devices as volumes to resources */ 265 /* add DRBD minor devices as volumes to resources */
266GENL_op(DRBD_ADM_ADD_MINOR, 5, GENL_doit(drbd_adm_add_minor), 266GENL_op(DRBD_ADM_ADD_MINOR, 5, GENL_doit(drbd_adm_add_minor),
267 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 267 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
268GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_delete_minor), 268GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_delete_minor),
269 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 269 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
270 270
271 /* add or delete replication links to resources */ 271 /* add or delete replication links to resources */
272GENL_op(DRBD_ADM_ADD_LINK, 7, GENL_doit(drbd_adm_create_connection), 272GENL_op(DRBD_ADM_ADD_LINK, 7, GENL_doit(drbd_adm_create_connection),
273 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 273 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
274GENL_op(DRBD_ADM_DEL_LINK, 8, GENL_doit(drbd_adm_delete_connection), 274GENL_op(DRBD_ADM_DEL_LINK, 8, GENL_doit(drbd_adm_delete_connection),
275 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 275 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
276 276
277GENL_op(DRBD_ADM_RESOURCE_OPTS, 9, 277GENL_op(DRBD_ADM_RESOURCE_OPTS, 9,
278 GENL_doit(drbd_adm_resource_opts), 278 GENL_doit(drbd_adm_resource_opts),
279 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 279 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
280 GENL_tla_expected(DRBD_NLA_RESOURCE_OPTS, GENLA_F_MANDATORY) 280 GENL_tla_expected(DRBD_NLA_RESOURCE_OPTS, DRBD_GENLA_F_MANDATORY)
281) 281)
282 282
283GENL_op( 283GENL_op(
284 DRBD_ADM_CONNECT, 10, 284 DRBD_ADM_CONNECT, 10,
285 GENL_doit(drbd_adm_connect), 285 GENL_doit(drbd_adm_connect),
286 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 286 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
287 GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_REQUIRED) 287 GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_F_REQUIRED)
288) 288)
289 289
290GENL_op( 290GENL_op(
291 DRBD_ADM_CHG_NET_OPTS, 29, 291 DRBD_ADM_CHG_NET_OPTS, 29,
292 GENL_doit(drbd_adm_net_opts), 292 GENL_doit(drbd_adm_net_opts),
293 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 293 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
294 GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_REQUIRED) 294 GENL_tla_expected(DRBD_NLA_NET_CONF, DRBD_F_REQUIRED)
295) 295)
296 296
297GENL_op(DRBD_ADM_DISCONNECT, 11, GENL_doit(drbd_adm_disconnect), 297GENL_op(DRBD_ADM_DISCONNECT, 11, GENL_doit(drbd_adm_disconnect),
298 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 298 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
299 299
300GENL_op(DRBD_ADM_ATTACH, 12, 300GENL_op(DRBD_ADM_ATTACH, 12,
301 GENL_doit(drbd_adm_attach), 301 GENL_doit(drbd_adm_attach),
302 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 302 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
303 GENL_tla_expected(DRBD_NLA_DISK_CONF, GENLA_F_REQUIRED) 303 GENL_tla_expected(DRBD_NLA_DISK_CONF, DRBD_F_REQUIRED)
304) 304)
305 305
306GENL_op(DRBD_ADM_CHG_DISK_OPTS, 28, 306GENL_op(DRBD_ADM_CHG_DISK_OPTS, 28,
307 GENL_doit(drbd_adm_disk_opts), 307 GENL_doit(drbd_adm_disk_opts),
308 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 308 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
309 GENL_tla_expected(DRBD_NLA_DISK_OPTS, GENLA_F_REQUIRED) 309 GENL_tla_expected(DRBD_NLA_DISK_OPTS, DRBD_F_REQUIRED)
310) 310)
311 311
312GENL_op( 312GENL_op(
313 DRBD_ADM_RESIZE, 13, 313 DRBD_ADM_RESIZE, 13,
314 GENL_doit(drbd_adm_resize), 314 GENL_doit(drbd_adm_resize),
315 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 315 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
316 GENL_tla_expected(DRBD_NLA_RESIZE_PARMS, GENLA_F_MANDATORY) 316 GENL_tla_expected(DRBD_NLA_RESIZE_PARMS, DRBD_GENLA_F_MANDATORY)
317) 317)
318 318
319GENL_op( 319GENL_op(
320 DRBD_ADM_PRIMARY, 14, 320 DRBD_ADM_PRIMARY, 14,
321 GENL_doit(drbd_adm_set_role), 321 GENL_doit(drbd_adm_set_role),
322 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 322 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
323 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, GENLA_F_REQUIRED) 323 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, DRBD_F_REQUIRED)
324) 324)
325 325
326GENL_op( 326GENL_op(
327 DRBD_ADM_SECONDARY, 15, 327 DRBD_ADM_SECONDARY, 15,
328 GENL_doit(drbd_adm_set_role), 328 GENL_doit(drbd_adm_set_role),
329 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 329 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
330 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, GENLA_F_REQUIRED) 330 GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, DRBD_F_REQUIRED)
331) 331)
332 332
333GENL_op( 333GENL_op(
334 DRBD_ADM_NEW_C_UUID, 16, 334 DRBD_ADM_NEW_C_UUID, 16,
335 GENL_doit(drbd_adm_new_c_uuid), 335 GENL_doit(drbd_adm_new_c_uuid),
336 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) 336 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED)
337 GENL_tla_expected(DRBD_NLA_NEW_C_UUID_PARMS, GENLA_F_MANDATORY) 337 GENL_tla_expected(DRBD_NLA_NEW_C_UUID_PARMS, DRBD_GENLA_F_MANDATORY)
338) 338)
339 339
340GENL_op( 340GENL_op(
341 DRBD_ADM_START_OV, 17, 341 DRBD_ADM_START_OV, 17,
342 GENL_doit(drbd_adm_start_ov), 342 GENL_doit(drbd_adm_start_ov),
343 GENL_tla_expected(DRBD_NLA_START_OV_PARMS, GENLA_F_MANDATORY) 343 GENL_tla_expected(DRBD_NLA_START_OV_PARMS, DRBD_GENLA_F_MANDATORY)
344) 344)
345 345
346GENL_op(DRBD_ADM_DETACH, 18, GENL_doit(drbd_adm_detach), 346GENL_op(DRBD_ADM_DETACH, 18, GENL_doit(drbd_adm_detach),
347 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 347 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
348GENL_op(DRBD_ADM_INVALIDATE, 19, GENL_doit(drbd_adm_invalidate), 348GENL_op(DRBD_ADM_INVALIDATE, 19, GENL_doit(drbd_adm_invalidate),
349 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 349 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
350GENL_op(DRBD_ADM_INVAL_PEER, 20, GENL_doit(drbd_adm_invalidate_peer), 350GENL_op(DRBD_ADM_INVAL_PEER, 20, GENL_doit(drbd_adm_invalidate_peer),
351 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 351 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
352GENL_op(DRBD_ADM_PAUSE_SYNC, 21, GENL_doit(drbd_adm_pause_sync), 352GENL_op(DRBD_ADM_PAUSE_SYNC, 21, GENL_doit(drbd_adm_pause_sync),
353 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 353 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
354GENL_op(DRBD_ADM_RESUME_SYNC, 22, GENL_doit(drbd_adm_resume_sync), 354GENL_op(DRBD_ADM_RESUME_SYNC, 22, GENL_doit(drbd_adm_resume_sync),
355 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 355 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
356GENL_op(DRBD_ADM_SUSPEND_IO, 23, GENL_doit(drbd_adm_suspend_io), 356GENL_op(DRBD_ADM_SUSPEND_IO, 23, GENL_doit(drbd_adm_suspend_io),
357 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 357 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
358GENL_op(DRBD_ADM_RESUME_IO, 24, GENL_doit(drbd_adm_resume_io), 358GENL_op(DRBD_ADM_RESUME_IO, 24, GENL_doit(drbd_adm_resume_io),
359 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 359 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
360GENL_op(DRBD_ADM_OUTDATE, 25, GENL_doit(drbd_adm_outdate), 360GENL_op(DRBD_ADM_OUTDATE, 25, GENL_doit(drbd_adm_outdate),
361 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 361 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
362GENL_op(DRBD_ADM_GET_TIMEOUT_TYPE, 26, GENL_doit(drbd_adm_get_timeout_type), 362GENL_op(DRBD_ADM_GET_TIMEOUT_TYPE, 26, GENL_doit(drbd_adm_get_timeout_type),
363 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 363 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
364GENL_op(DRBD_ADM_DOWN, 27, GENL_doit(drbd_adm_down), 364GENL_op(DRBD_ADM_DOWN, 27, GENL_doit(drbd_adm_down),
365 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) 365 GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
index 2ae16126c6a4..58edd403a3ff 100644
--- a/include/linux/genl_magic_func.h
+++ b/include/linux/genl_magic_func.h
@@ -4,53 +4,6 @@
4#include <linux/genl_magic_struct.h> 4#include <linux/genl_magic_struct.h>
5 5
6/* 6/*
7 * Extension of genl attribute validation policies {{{1
8 * {{{2
9 */
10
11/**
12 * nla_is_required - return true if this attribute is required
13 * @nla: netlink attribute
14 */
15static inline int nla_is_required(const struct nlattr *nla)
16{
17 return nla->nla_type & GENLA_F_REQUIRED;
18}
19
20/**
21 * nla_is_mandatory - return true if understanding this attribute is mandatory
22 * @nla: netlink attribute
23 * Note: REQUIRED attributes are implicitly MANDATORY as well
24 */
25static inline int nla_is_mandatory(const struct nlattr *nla)
26{
27 return nla->nla_type & (GENLA_F_MANDATORY | GENLA_F_REQUIRED);
28}
29
30/* Functionality to be integrated into nla_parse(), and validate_nla(),
31 * respectively.
32 *
33 * Enforcing the "mandatory" bit is done here,
34 * by rejecting unknown mandatory attributes.
35 *
36 * Part of enforcing the "required" flag would mean to embed it into
37 * nla_policy.type, and extending validate_nla(), which currently does
38 * BUG_ON(pt->type > NLA_TYPE_MAX); we have to work on existing kernels,
39 * so we cannot do that. Thats why enforcing "required" is done in the
40 * generated assignment functions below. */
41static int nla_check_unknown(int maxtype, struct nlattr *head, int len)
42{
43 struct nlattr *nla;
44 int rem;
45 nla_for_each_attr(nla, head, len, rem) {
46 __u16 type = nla_type(nla);
47 if (type > maxtype && nla_is_mandatory(nla))
48 return -EOPNOTSUPP;
49 }
50 return 0;
51}
52
53/*
54 * Magic: declare tla policy {{{1 7 * Magic: declare tla policy {{{1
55 * Magic: declare nested policies 8 * Magic: declare nested policies
56 * {{{2 9 * {{{2
@@ -80,13 +33,13 @@ static struct nla_policy s_name ## _nl_policy[] __read_mostly = \
80#undef __field 33#undef __field
81#define __field(attr_nr, attr_flag, name, nla_type, _type, __get, \ 34#define __field(attr_nr, attr_flag, name, nla_type, _type, __get, \
82 __put, __is_signed) \ 35 __put, __is_signed) \
83 [__nla_type(attr_nr)] = { .type = nla_type }, 36 [attr_nr] = { .type = nla_type },
84 37
85#undef __array 38#undef __array
86#define __array(attr_nr, attr_flag, name, nla_type, _type, maxlen, \ 39#define __array(attr_nr, attr_flag, name, nla_type, _type, maxlen, \
87 __get, __put, __is_signed) \ 40 __get, __put, __is_signed) \
88 [__nla_type(attr_nr)] = { .type = nla_type, \ 41 [attr_nr] = { .type = nla_type, \
89 .len = maxlen - (nla_type == NLA_NUL_STRING) }, 42 .len = maxlen - (nla_type == NLA_NUL_STRING) },
90 43
91#include GENL_MAGIC_INCLUDE_FILE 44#include GENL_MAGIC_INCLUDE_FILE
92 45
@@ -189,6 +142,43 @@ static struct nlattr *nested_attr_tb[128];
189#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) 142#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
190#endif 143#endif
191 144
145static inline int drbd_nla_check_mandatory(int maxtype, struct nlattr *nla)
146{
147 struct nlattr *head = nla_data(nla);
148 int len = nla_len(nla);
149 int rem;
150
151 /*
152 * validate_nla (called from nla_parse_nested) ignores attributes
153 * beyond maxtype, and does not understand the DRBD_GENLA_F_MANDATORY flag.
154 * In order to have it validate attributes with the DRBD_GENLA_F_MANDATORY
155 * flag set also, check and remove that flag before calling
156 * nla_parse_nested.
157 */
158
159 nla_for_each_attr(nla, head, len, rem) {
160 if (nla->nla_type & DRBD_GENLA_F_MANDATORY) {
161 if (nla_type(nla) > maxtype)
162 return -EOPNOTSUPP;
163 nla->nla_type &= ~DRBD_GENLA_F_MANDATORY;
164 }
165 }
166 return 0;
167}
168
169static inline int drbd_nla_parse_nested(struct nlattr *tb[], int maxtype,
170 struct nlattr *nla,
171 const struct nla_policy *policy)
172{
173 int err;
174
175 err = drbd_nla_check_mandatory(maxtype, nla);
176 if (!err)
177 err = nla_parse_nested(tb, maxtype, nla, policy);
178
179 return err;
180}
181
192#undef GENL_struct 182#undef GENL_struct
193#define GENL_struct(tag_name, tag_number, s_name, s_fields) \ 183#define GENL_struct(tag_name, tag_number, s_name, s_fields) \
194/* *_from_attrs functions are static, but potentially unused */ \ 184/* *_from_attrs functions are static, but potentially unused */ \
@@ -204,12 +194,9 @@ static int __ ## s_name ## _from_attrs(struct s_name *s, \
204 if (!tla) \ 194 if (!tla) \
205 return -ENOMSG; \ 195 return -ENOMSG; \
206 DPRINT_TLA(#s_name, "<=-", #tag_name); \ 196 DPRINT_TLA(#s_name, "<=-", #tag_name); \
207 err = nla_parse_nested(ntb, maxtype, tla, s_name ## _nl_policy); \ 197 err = drbd_nla_parse_nested(ntb, maxtype, tla, s_name ## _nl_policy); \
208 if (err) \ 198 if (err) \
209 return err; \ 199 return err; \
210 err = nla_check_unknown(maxtype, nla_data(tla), nla_len(tla)); \
211 if (err) \
212 return err; \
213 \ 200 \
214 s_fields \ 201 s_fields \
215 return 0; \ 202 return 0; \
@@ -226,17 +213,17 @@ static int s_name ## _from_attrs_for_change(struct s_name *s, \
226} __attribute__((unused)) \ 213} __attribute__((unused)) \
227 214
228#define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) \ 215#define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) \
229 nla = ntb[__nla_type(attr_nr)]; \ 216 nla = ntb[attr_nr]; \
230 if (nla) { \ 217 if (nla) { \
231 if (exclude_invariants && ((attr_flag) & GENLA_F_INVARIANT)) { \ 218 if (exclude_invariants && ((attr_flag) & DRBD_F_INVARIANT)) { \
232 pr_info("<< must not change invariant attr: %s\n", #name); \ 219 pr_info("<< must not change invariant attr: %s\n", #name); \
233 return -EEXIST; \ 220 return -EEXIST; \
234 } \ 221 } \
235 assignment; \ 222 assignment; \
236 } else if (exclude_invariants && ((attr_flag) & GENLA_F_INVARIANT)) { \ 223 } else if (exclude_invariants && ((attr_flag) & DRBD_F_INVARIANT)) { \
237 /* attribute missing from payload, */ \ 224 /* attribute missing from payload, */ \
238 /* which was expected */ \ 225 /* which was expected */ \
239 } else if ((attr_flag) & GENLA_F_REQUIRED) { \ 226 } else if ((attr_flag) & DRBD_F_REQUIRED) { \
240 pr_info("<< missing attr: %s\n", #name); \ 227 pr_info("<< missing attr: %s\n", #name); \
241 return -ENOMSG; \ 228 return -ENOMSG; \
242 } 229 }
@@ -415,7 +402,7 @@ static inline int s_name ## _to_unpriv_skb(struct sk_buff *skb, \
415#undef __field 402#undef __field
416#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ 403#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
417 __is_signed) \ 404 __is_signed) \
418 if (!exclude_sensitive || !((attr_flag) & GENLA_F_SENSITIVE)) { \ 405 if (!exclude_sensitive || !((attr_flag) & DRBD_F_SENSITIVE)) { \
419 DPRINT_FIELD(">>", nla_type, name, s, NULL); \ 406 DPRINT_FIELD(">>", nla_type, name, s, NULL); \
420 __put(skb, attr_nr, s->name); \ 407 __put(skb, attr_nr, s->name); \
421 } 408 }
@@ -423,7 +410,7 @@ static inline int s_name ## _to_unpriv_skb(struct sk_buff *skb, \
423#undef __array 410#undef __array
424#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ 411#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
425 __get, __put, __is_signed) \ 412 __get, __put, __is_signed) \
426 if (!exclude_sensitive || !((attr_flag) & GENLA_F_SENSITIVE)) { \ 413 if (!exclude_sensitive || !((attr_flag) & DRBD_F_SENSITIVE)) { \
427 DPRINT_ARRAY(">>",nla_type, name, s, NULL); \ 414 DPRINT_ARRAY(">>",nla_type, name, s, NULL); \
428 __put(skb, attr_nr, min_t(int, maxlen, \ 415 __put(skb, attr_nr, min_t(int, maxlen, \
429 s->name ## _len + (nla_type == NLA_NUL_STRING)),\ 416 s->name ## _len + (nla_type == NLA_NUL_STRING)),\
diff --git a/include/linux/genl_magic_struct.h b/include/linux/genl_magic_struct.h
index f3c3425ac30f..1d0bd79e27b3 100644
--- a/include/linux/genl_magic_struct.h
+++ b/include/linux/genl_magic_struct.h
@@ -26,50 +26,34 @@ extern void CONCAT_(GENL_MAGIC_FAMILY, _genl_unregister)(void);
26 * Extension of genl attribute validation policies {{{2 26 * Extension of genl attribute validation policies {{{2
27 */ 27 */
28 28
29/** 29/*
30 * GENLA_F_FLAGS - policy type flags to ease compatible ABI evolvement 30 * @DRBD_GENLA_F_MANDATORY: By default, netlink ignores attributes it does not
31 * 31 * know about. This flag can be set in nlattr->nla_type to indicate that this
32 * @GENLA_F_REQUIRED: attribute has to be present, or message is considered invalid. 32 * attribute must not be ignored.
33 * Adding new REQUIRED attributes breaks ABI compatibility, so don't do that.
34 * 33 *
35 * @GENLA_F_MANDATORY: if present, receiver _must_ understand it. 34 * We check and remove this flag in drbd_nla_check_mandatory() before
36 * Without this, unknown attributes (> maxtype) are _silently_ ignored 35 * validating the attribute types and lengths via nla_parse_nested().
37 * by validate_nla(). 36 */
37#define DRBD_GENLA_F_MANDATORY (1 << 14)
38
39/*
40 * Flags specific to drbd and not visible at the netlink layer, used in
41 * <struct>_from_attrs and <struct>_to_skb:
38 * 42 *
39 * To be used for API extensions, so older kernel can reject requests for not 43 * @DRBD_F_REQUIRED: Attribute is required; a request without this attribute is
40 * yet implemented features, if newer userland tries to use them even though 44 * invalid.
41 * the genl_family version clearly indicates they are not available.
42 * 45 *
43 * NOTE: These flags overload 46 * @DRBD_F_SENSITIVE: Attribute includes sensitive information and must not be
44 * NLA_F_NESTED (1 << 15) 47 * included in unpriviledged get requests or broadcasts.
45 * NLA_F_NET_BYTEORDER (1 << 14)
46 * from linux/netlink.h, which are not useful for validate_nla():
47 * NET_BYTEORDER is not used anywhere, and NESTED would be specified by setting
48 * .type = NLA_NESTED in the appropriate policy.
49 * 48 *
50 * See also: nla_type() 49 * @DRBD_F_INVARIANT: Attribute is set when an object is initially created, but
50 * cannot subsequently be changed.
51 */ 51 */
52enum { 52#define DRBD_F_REQUIRED (1 << 0)
53 GENLA_F_MANDATORY = 1 << 14, 53#define DRBD_F_SENSITIVE (1 << 1)
54 GENLA_F_REQUIRED = 1 << 15, 54#define DRBD_F_INVARIANT (1 << 2)
55
56 /* Below will not be present in the __u16 .nla_type, but can be
57 * triggered on in <struct>_to_skb resp. <struct>_from_attrs */
58
59 /* To exclude "sensitive" information from broadcasts, or on
60 * unpriviledged get requests. This is useful because genetlink
61 * multicast groups can be listened in on by anyone. */
62 GENLA_F_SENSITIVE = 1 << 16,
63
64 /* INVARIAN options cannot be changed at runtime.
65 * Useful to share an attribute policy and struct definition,
66 * between some "create" and "change" commands,
67 * but disallow certain fields to be changed online.
68 */
69 GENLA_F_INVARIANT = 1 << 17,
70};
71 55
72#define __nla_type(x) ((__u16)((__u16)(x) & (__u16)NLA_TYPE_MASK)) 56#define __nla_type(x) ((__u16)((x) & NLA_TYPE_MASK & ~DRBD_GENLA_F_MANDATORY))
73 57
74/* }}}1 58/* }}}1
75 * MAGIC 59 * MAGIC
@@ -170,12 +154,12 @@ enum { \
170#undef __field 154#undef __field
171#define __field(attr_nr, attr_flag, name, nla_type, type, \ 155#define __field(attr_nr, attr_flag, name, nla_type, type, \
172 __get, __put, __is_signed) \ 156 __get, __put, __is_signed) \
173 T_ ## name = (__u16)(attr_nr | attr_flag), 157 T_ ## name = (__u16)(attr_nr | ((attr_flag) & DRBD_GENLA_F_MANDATORY)),
174 158
175#undef __array 159#undef __array
176#define __array(attr_nr, attr_flag, name, nla_type, type, \ 160#define __array(attr_nr, attr_flag, name, nla_type, type, \
177 maxlen, __get, __put, __is_signed) \ 161 maxlen, __get, __put, __is_signed) \
178 T_ ## name = (__u16)(attr_nr | attr_flag), 162 T_ ## name = (__u16)(attr_nr | ((attr_flag) & DRBD_GENLA_F_MANDATORY)),
179 163
180#include GENL_MAGIC_INCLUDE_FILE 164#include GENL_MAGIC_INCLUDE_FILE
181 165