GENL_DONT_VALIDATE_DUMP_STRICT = BIT(2),
};
+/**
+ * struct genl_info - info that is available during dumpit op call
+ * @ops: generic netlink ops - for internal genl code usage
+ */
+struct genl_dumpit_info {
+ const struct genl_ops *ops;
+};
+
+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
}
EXPORT_SYMBOL(genlmsg_put);
+static struct genl_dumpit_info *genl_dumpit_info_alloc(void)
+{
+ return kmalloc(sizeof(struct genl_dumpit_info), GFP_KERNEL);
+}
+
+static void genl_dumpit_info_free(const struct genl_dumpit_info *info)
+{
+ kfree(info);
+}
+
static int genl_lock_start(struct netlink_callback *cb)
{
- /* our ops are always const - netlink API doesn't propagate that */
- const struct genl_ops *ops = cb->data;
+ const struct genl_ops *ops = genl_dumpit_info(cb)->ops;
int rc = 0;
if (ops->start) {
static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
- /* our ops are always const - netlink API doesn't propagate that */
- const struct genl_ops *ops = cb->data;
+ const struct genl_ops *ops = genl_dumpit_info(cb)->ops;
int rc;
genl_lock();
static int genl_lock_done(struct netlink_callback *cb)
{
- /* our ops are always const - netlink API doesn't propagate that */
- const struct genl_ops *ops = cb->data;
+ const struct genl_dumpit_info *info = genl_dumpit_info(cb);
+ const struct genl_ops *ops = info->ops;
int rc = 0;
if (ops->done) {
rc = ops->done(cb);
genl_unlock();
}
+ genl_dumpit_info_free(info);
+ return rc;
+}
+
+static int genl_parallel_done(struct netlink_callback *cb)
+{
+ const struct genl_dumpit_info *info = genl_dumpit_info(cb);
+ const struct genl_ops *ops = info->ops;
+ int rc = 0;
+
+ if (ops->done)
+ rc = ops->done(cb);
+ genl_dumpit_info_free(info);
return rc;
}
const struct genl_ops *ops,
int hdrlen, struct net *net)
{
+ struct genl_dumpit_info *info;
int err;
if (!ops->dumpit)
}
}
+ /* Allocate dumpit info. It is going to be freed by done() callback. */
+ info = genl_dumpit_info_alloc();
+ if (!info)
+ return -ENOMEM;
+
+ info->ops = ops;
+
if (!family->parallel_ops) {
struct netlink_dump_control c = {
.module = family->module,
- /* we have const, but the netlink API doesn't */
- .data = (void *)ops,
+ .data = info,
.start = genl_lock_start,
.dump = genl_lock_dumpit,
.done = genl_lock_done,
} else {
struct netlink_dump_control c = {
.module = family->module,
+ .data = info,
.start = ops->start,
.dump = ops->dumpit,
- .done = ops->done,
+ .done = genl_parallel_done,
};
err = __netlink_dump_start(net->genl_sock, skb, nlh, &c);