Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / include / net / genetlink.h
index 8899d74..e55ec15 100644 (file)
@@ -41,6 +41,8 @@ struct genl_info;
  *     (private)
  * @ops: the operations supported by this family
  * @n_ops: number of operations supported by this family
+ * @small_ops: the small-struct operations supported by this family
+ * @n_small_ops: number of small-struct operations supported by this family
  */
 struct genl_family {
        int                     id;             /* private */
@@ -48,8 +50,12 @@ struct genl_family {
        char                    name[GENL_NAMSIZ];
        unsigned int            version;
        unsigned int            maxattr;
-       bool                    netnsok;
-       bool                    parallel_ops;
+       unsigned int            mcgrp_offset;   /* private */
+       u8                      netnsok:1;
+       u8                      parallel_ops:1;
+       u8                      n_ops;
+       u8                      n_small_ops;
+       u8                      n_mcgrps;
        const struct nla_policy *policy;
        int                     (*pre_doit)(const struct genl_ops *ops,
                                            struct sk_buff *skb,
@@ -58,10 +64,8 @@ struct genl_family {
                                             struct sk_buff *skb,
                                             struct genl_info *info);
        const struct genl_ops * ops;
+       const struct genl_small_ops *small_ops;
        const struct genl_multicast_group *mcgrps;
-       unsigned int            n_ops;
-       unsigned int            n_mcgrps;
-       unsigned int            mcgrp_offset;   /* private */
        struct module           *module;
 };
 
@@ -101,14 +105,6 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net)
 
 #define GENL_SET_ERR_MSG(info, msg) NL_SET_ERR_MSG((info)->extack, msg)
 
-static inline int genl_err_attr(struct genl_info *info, int err,
-                               const struct nlattr *attr)
-{
-       info->extack->bad_attr = attr;
-
-       return err;
-}
-
 enum genl_validate_flags {
        GENL_DONT_VALIDATE_STRICT               = BIT(0),
        GENL_DONT_VALIDATE_DUMP                 = BIT(1),
@@ -116,28 +112,33 @@ enum genl_validate_flags {
 };
 
 /**
- * struct genl_info - info that is available during dumpit op call
- * @family: generic netlink family - for internal genl code usage
- * @ops: generic netlink ops - for internal genl code usage
- * @attrs: netlink attributes
+ * struct genl_small_ops - generic netlink operations (small version)
+ * @cmd: command identifier
+ * @internal_flags: flags used by the family
+ * @flags: flags
+ * @validate: validation flags from enum genl_validate_flags
+ * @doit: standard command callback
+ * @dumpit: callback for dumpers
+ *
+ * This is a cut-down version of struct genl_ops for users who don't need
+ * most of the ancillary infra and want to save space.
  */
-struct genl_dumpit_info {
-       const struct genl_family *family;
-       const struct genl_ops *ops;
-       struct nlattr **attrs;
+struct genl_small_ops {
+       int     (*doit)(struct sk_buff *skb, struct genl_info *info);
+       int     (*dumpit)(struct sk_buff *skb, struct netlink_callback *cb);
+       u8      cmd;
+       u8      internal_flags;
+       u8      flags;
+       u8      validate;
 };
 
-static inline const struct genl_dumpit_info *
-genl_dumpit_info(struct netlink_callback *cb)
-{
-       return cb->data;
-}
-
 /**
  * struct genl_ops - generic netlink operations
  * @cmd: command identifier
  * @internal_flags: flags used by the family
  * @flags: flags
+ * @maxattr: maximum number of attributes supported
+ * @policy: netlink policy (takes precedence over family policy)
  * @validate: validation flags from enum genl_validate_flags
  * @doit: standard command callback
  * @start: start callback for dumps
@@ -151,12 +152,32 @@ struct genl_ops {
        int                    (*dumpit)(struct sk_buff *skb,
                                         struct netlink_callback *cb);
        int                    (*done)(struct netlink_callback *cb);
+       const struct nla_policy *policy;
+       unsigned int            maxattr;
        u8                      cmd;
        u8                      internal_flags;
        u8                      flags;
        u8                      validate;
 };
 
+/**
+ * struct genl_info - info that is available during dumpit op call
+ * @family: generic netlink family - for internal genl code usage
+ * @ops: generic netlink ops - for internal genl code usage
+ * @attrs: netlink attributes
+ */
+struct genl_dumpit_info {
+       const struct genl_family *family;
+       struct genl_ops op;
+       struct nlattr **attrs;
+};
+
+static inline const struct genl_dumpit_info *
+genl_dumpit_info(struct netlink_callback *cb)
+{
+       return cb->data;
+}
+
 int genl_register_family(struct genl_family *family);
 int genl_unregister_family(const struct genl_family *family);
 void genl_notify(const struct genl_family *family, struct sk_buff *skb,