aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/genl_magic_struct.h
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2011-05-19 17:39:28 +0200
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-08 16:55:55 +0100
commit5f9359201b5cf1d94fe0e0c47fcba38cfc921863 (patch)
tree3d2e41a9590bb0e77a50d4b0ea4b8ad4706f566e /include/linux/genl_magic_struct.h
parentdrbd: Remove unused GENLA_F_MAY_IGNORE flag (diff)
downloadlinux-dev-5f9359201b5cf1d94fe0e0c47fcba38cfc921863.tar.xz
linux-dev-5f9359201b5cf1d94fe0e0c47fcba38cfc921863.zip
drbd: Make drbd's use of netlink attribute flags less confusing
Make it more clear in the flag names which flags are internal to drbd, and which are not. The check for mandatory attributes is the only extension visible at the netlink layer. Attributes with this flag set would look like unknown attributes to some kernel versions. The netlink layer would ignore them and also skip consistency checks on the attribute type and legth. To avoid this, we check for mandatory attributes first, remove the mandatory flag, and then process the attributes normally. 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.h64
1 files changed, 24 insertions, 40 deletions
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);
* Extension of genl attribute validation policies {{{2
*/
-/**
- * GENLA_F_FLAGS - policy type flags to ease compatible ABI evolvement
- *
- * @GENLA_F_REQUIRED: attribute has to be present, or message is considered invalid.
- * Adding new REQUIRED attributes breaks ABI compatibility, so don't do that.
+/*
+ * @DRBD_GENLA_F_MANDATORY: By default, netlink ignores attributes it does not
+ * know about. This flag can be set in nlattr->nla_type to indicate that this
+ * attribute must not be ignored.
*
- * @GENLA_F_MANDATORY: if present, receiver _must_ understand it.
- * Without this, unknown attributes (> maxtype) are _silently_ ignored
- * by validate_nla().
+ * We check and remove this flag in drbd_nla_check_mandatory() before
+ * validating the attribute types and lengths via nla_parse_nested().
+ */
+#define DRBD_GENLA_F_MANDATORY (1 << 14)
+
+/*
+ * Flags specific to drbd and not visible at the netlink layer, used in
+ * <struct>_from_attrs and <struct>_to_skb:
*
- * To be used for API extensions, so older kernel can reject requests for not
- * yet implemented features, if newer userland tries to use them even though
- * the genl_family version clearly indicates they are not available.
+ * @DRBD_F_REQUIRED: Attribute is required; a request without this attribute is
+ * invalid.
*
- * NOTE: These flags overload
- * NLA_F_NESTED (1 << 15)
- * NLA_F_NET_BYTEORDER (1 << 14)
- * from linux/netlink.h, which are not useful for validate_nla():
- * NET_BYTEORDER is not used anywhere, and NESTED would be specified by setting
- * .type = NLA_NESTED in the appropriate policy.
+ * @DRBD_F_SENSITIVE: Attribute includes sensitive information and must not be
+ * included in unpriviledged get requests or broadcasts.
*
- * See also: nla_type()
+ * @DRBD_F_INVARIANT: Attribute is set when an object is initially created, but
+ * cannot subsequently be changed.
*/
-enum {
- GENLA_F_MANDATORY = 1 << 14,
- GENLA_F_REQUIRED = 1 << 15,
-
- /* Below will not be present in the __u16 .nla_type, but can be
- * triggered on in <struct>_to_skb resp. <struct>_from_attrs */
-
- /* To exclude "sensitive" information from broadcasts, or on
- * unpriviledged get requests. This is useful because genetlink
- * multicast groups can be listened in on by anyone. */
- GENLA_F_SENSITIVE = 1 << 16,
-
- /* INVARIAN options cannot be changed at runtime.
- * Useful to share an attribute policy and struct definition,
- * between some "create" and "change" commands,
- * but disallow certain fields to be changed online.
- */
- GENLA_F_INVARIANT = 1 << 17,
-};
+#define DRBD_F_REQUIRED (1 << 0)
+#define DRBD_F_SENSITIVE (1 << 1)
+#define DRBD_F_INVARIANT (1 << 2)
-#define __nla_type(x) ((__u16)((__u16)(x) & (__u16)NLA_TYPE_MASK))
+#define __nla_type(x) ((__u16)((x) & NLA_TYPE_MASK & ~DRBD_GENLA_F_MANDATORY))
/* }}}1
* MAGIC
@@ -170,12 +154,12 @@ enum { \
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, \
__get, __put, __is_signed) \
- T_ ## name = (__u16)(attr_nr | attr_flag),
+ T_ ## name = (__u16)(attr_nr | ((attr_flag) & DRBD_GENLA_F_MANDATORY)),
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, \
maxlen, __get, __put, __is_signed) \
- T_ ## name = (__u16)(attr_nr | attr_flag),
+ T_ ## name = (__u16)(attr_nr | ((attr_flag) & DRBD_GENLA_F_MANDATORY)),
#include GENL_MAGIC_INCLUDE_FILE