summaryrefslogtreecommitdiff
path: root/net/netlink
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-08-15 00:47:17 +0300
committerJakub Kicinski <kuba@kernel.org>2023-08-16 00:54:44 +0300
commit9272af109fe65d1a13f28c5c13777b62d3e97e8c (patch)
treeedb1bbfc92c4f5314ca2fff9faa4e7a24ee3390d /net/netlink
parentbffcc6882a1bb2be8c9420184966f4c2c822078e (diff)
downloadlinux-9272af109fe65d1a13f28c5c13777b62d3e97e8c.tar.xz
genetlink: add struct genl_info to struct genl_dumpit_info
Netlink GET implementations must currently juggle struct genl_info and struct netlink_callback, depending on whether they were called from doit or dumpit. Add genl_info to the dump state and populate the fields. This way implementations can simply pass struct genl_info around. Reviewed-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20230814214723.2924989-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/netlink')
-rw-r--r--net/netlink/genetlink.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index f98f730bb245..82ad26970b9b 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -847,6 +847,14 @@ static int genl_start(struct netlink_callback *cb)
info->family = ctx->family;
info->op = *ops;
info->attrs = attrs;
+ info->info.snd_seq = cb->nlh->nlmsg_seq;
+ info->info.snd_portid = NETLINK_CB(cb->skb).portid;
+ info->info.nlhdr = cb->nlh;
+ info->info.genlhdr = nlmsg_data(cb->nlh);
+ info->info.attrs = attrs;
+ genl_info_net_set(&info->info, sock_net(cb->skb->sk));
+ info->info.extack = cb->extack;
+ memset(&info->info.user_ptr, 0, sizeof(info->info.user_ptr));
cb->data = info;
if (ops->start) {
@@ -865,10 +873,12 @@ static int genl_start(struct netlink_callback *cb)
static int genl_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
- const struct genl_dumpit_info *info = genl_dumpit_info(cb);
+ struct genl_dumpit_info *info = cb->data;
const struct genl_split_ops *ops = &info->op;
int rc;
+ info->info.extack = cb->extack;
+
genl_op_lock(info->family);
rc = ops->dumpit(skb, cb);
genl_op_unlock(info->family);
@@ -877,10 +887,12 @@ static int genl_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
static int genl_done(struct netlink_callback *cb)
{
- const struct genl_dumpit_info *info = genl_dumpit_info(cb);
+ struct genl_dumpit_info *info = cb->data;
const struct genl_split_ops *ops = &info->op;
int rc = 0;
+ info->info.extack = cb->extack;
+
if (ops->done) {
genl_op_lock(info->family);
rc = ops->done(cb);