diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-05-17 07:29:46 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:55:55 -0500 |
commit | 509100e6012db92f4af3796436b450447c6c8268 (patch) | |
tree | 161f5b29974425fac4fe3e865fbea438b91c2511 /include/linux/genl_magic_struct.h | |
parent | 309f0b70ab789bf85c5f5f32dbc466d42f024747 (diff) |
drbd: Output signed / unsigned netlink fields correctly
Note: All input values are still treated as signed; unsigned long long values
are still broken.
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_struct.h')
-rw-r--r-- | include/linux/genl_magic_struct.h | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/include/linux/genl_magic_struct.h b/include/linux/genl_magic_struct.h index 0fca21fd1af5..ba911da84d9f 100644 --- a/include/linux/genl_magic_struct.h +++ b/include/linux/genl_magic_struct.h | |||
@@ -87,28 +87,28 @@ enum { | |||
87 | /* possible field types */ | 87 | /* possible field types */ |
88 | #define __flg_field(attr_nr, attr_flag, name) \ | 88 | #define __flg_field(attr_nr, attr_flag, name) \ |
89 | __field(attr_nr, attr_flag, name, NLA_U8, char, \ | 89 | __field(attr_nr, attr_flag, name, NLA_U8, char, \ |
90 | nla_get_u8, NLA_PUT_U8) | 90 | nla_get_u8, NLA_PUT_U8, false) |
91 | #define __u8_field(attr_nr, attr_flag, name) \ | 91 | #define __u8_field(attr_nr, attr_flag, name) \ |
92 | __field(attr_nr, attr_flag, name, NLA_U8, unsigned char, \ | 92 | __field(attr_nr, attr_flag, name, NLA_U8, unsigned char, \ |
93 | nla_get_u8, NLA_PUT_U8) | 93 | nla_get_u8, NLA_PUT_U8, false) |
94 | #define __u16_field(attr_nr, attr_flag, name) \ | 94 | #define __u16_field(attr_nr, attr_flag, name) \ |
95 | __field(attr_nr, attr_flag, name, NLA_U16, __u16, \ | 95 | __field(attr_nr, attr_flag, name, NLA_U16, __u16, \ |
96 | nla_get_u16, NLA_PUT_U16) | 96 | nla_get_u16, NLA_PUT_U16, false) |
97 | #define __u32_field(attr_nr, attr_flag, name) \ | 97 | #define __u32_field(attr_nr, attr_flag, name) \ |
98 | __field(attr_nr, attr_flag, name, NLA_U32, __u32, \ | 98 | __field(attr_nr, attr_flag, name, NLA_U32, __u32, \ |
99 | nla_get_u32, NLA_PUT_U32) | 99 | nla_get_u32, NLA_PUT_U32, false) |
100 | #define __s32_field(attr_nr, attr_flag, name) \ | 100 | #define __s32_field(attr_nr, attr_flag, name) \ |
101 | __field(attr_nr, attr_flag, name, NLA_U32, __s32, \ | 101 | __field(attr_nr, attr_flag, name, NLA_U32, __s32, \ |
102 | nla_get_u32, NLA_PUT_U32) | 102 | nla_get_u32, NLA_PUT_U32, true) |
103 | #define __u64_field(attr_nr, attr_flag, name) \ | 103 | #define __u64_field(attr_nr, attr_flag, name) \ |
104 | __field(attr_nr, attr_flag, name, NLA_U64, __u64, \ | 104 | __field(attr_nr, attr_flag, name, NLA_U64, __u64, \ |
105 | nla_get_u64, NLA_PUT_U64) | 105 | nla_get_u64, NLA_PUT_U64, false) |
106 | #define __str_field(attr_nr, attr_flag, name, maxlen) \ | 106 | #define __str_field(attr_nr, attr_flag, name, maxlen) \ |
107 | __array(attr_nr, attr_flag, name, NLA_NUL_STRING, char, maxlen, \ | 107 | __array(attr_nr, attr_flag, name, NLA_NUL_STRING, char, maxlen, \ |
108 | nla_strlcpy, NLA_PUT) | 108 | nla_strlcpy, NLA_PUT, false) |
109 | #define __bin_field(attr_nr, attr_flag, name, maxlen) \ | 109 | #define __bin_field(attr_nr, attr_flag, name, maxlen) \ |
110 | __array(attr_nr, attr_flag, name, NLA_BINARY, char, maxlen, \ | 110 | __array(attr_nr, attr_flag, name, NLA_BINARY, char, maxlen, \ |
111 | nla_memcpy, NLA_PUT) | 111 | nla_memcpy, NLA_PUT, false) |
112 | 112 | ||
113 | /* fields with default values */ | 113 | /* fields with default values */ |
114 | #define __flg_field_def(attr_nr, attr_flag, name, default) \ | 114 | #define __flg_field_def(attr_nr, attr_flag, name, default) \ |
@@ -174,11 +174,13 @@ enum { \ | |||
174 | }; | 174 | }; |
175 | 175 | ||
176 | #undef __field | 176 | #undef __field |
177 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \ | 177 | #define __field(attr_nr, attr_flag, name, nla_type, type, \ |
178 | __get, __put, __is_signed) \ | ||
178 | T_ ## name = (__u16)(attr_nr | attr_flag), | 179 | T_ ## name = (__u16)(attr_nr | attr_flag), |
179 | 180 | ||
180 | #undef __array | 181 | #undef __array |
181 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put) \ | 182 | #define __array(attr_nr, attr_flag, name, nla_type, type, \ |
183 | maxlen, __get, __put, __is_signed) \ | ||
182 | T_ ## name = (__u16)(attr_nr | attr_flag), | 184 | T_ ## name = (__u16)(attr_nr | attr_flag), |
183 | 185 | ||
184 | #include GENL_MAGIC_INCLUDE_FILE | 186 | #include GENL_MAGIC_INCLUDE_FILE |
@@ -238,11 +240,13 @@ static inline void ct_assert_unique_ ## s_name ## _attributes(void) \ | |||
238 | } | 240 | } |
239 | 241 | ||
240 | #undef __field | 242 | #undef __field |
241 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \ | 243 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ |
244 | __is_signed) \ | ||
242 | case attr_nr: | 245 | case attr_nr: |
243 | 246 | ||
244 | #undef __array | 247 | #undef __array |
245 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put) \ | 248 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ |
249 | __get, __put, __is_signed) \ | ||
246 | case attr_nr: | 250 | case attr_nr: |
247 | 251 | ||
248 | #include GENL_MAGIC_INCLUDE_FILE | 252 | #include GENL_MAGIC_INCLUDE_FILE |
@@ -260,16 +264,36 @@ static inline void ct_assert_unique_ ## s_name ## _attributes(void) \ | |||
260 | struct s_name { s_fields }; | 264 | struct s_name { s_fields }; |
261 | 265 | ||
262 | #undef __field | 266 | #undef __field |
263 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put) \ | 267 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ |
268 | __is_signed) \ | ||
264 | type name; | 269 | type name; |
265 | 270 | ||
266 | #undef __array | 271 | #undef __array |
267 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, __get, __put) \ | 272 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ |
273 | __get, __put, __is_signed) \ | ||
268 | type name[maxlen]; \ | 274 | type name[maxlen]; \ |
269 | __u32 name ## _len; | 275 | __u32 name ## _len; |
270 | 276 | ||
271 | #include GENL_MAGIC_INCLUDE_FILE | 277 | #include GENL_MAGIC_INCLUDE_FILE |
272 | 278 | ||
279 | #undef GENL_struct | ||
280 | #define GENL_struct(tag_name, tag_number, s_name, s_fields) \ | ||
281 | enum { \ | ||
282 | s_fields \ | ||
283 | }; | ||
284 | |||
285 | #undef __field | ||
286 | #define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \ | ||
287 | is_signed) \ | ||
288 | F_ ## name ## _IS_SIGNED = is_signed, | ||
289 | |||
290 | #undef __array | ||
291 | #define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \ | ||
292 | __get, __put, is_signed) \ | ||
293 | F_ ## name ## _IS_SIGNED = is_signed, | ||
294 | |||
295 | #include GENL_MAGIC_INCLUDE_FILE | ||
296 | |||
273 | /* }}}1 */ | 297 | /* }}}1 */ |
274 | #endif /* GENL_MAGIC_STRUCT_H */ | 298 | #endif /* GENL_MAGIC_STRUCT_H */ |
275 | /* vim: set foldmethod=marker nofoldenable : */ | 299 | /* vim: set foldmethod=marker nofoldenable : */ |