diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-08-14 23:47:19 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-08-16 00:01:03 +0200 |
commit | 5c670a010de46687ed27553602d8131ce4d7a9fb (patch) | |
tree | 21e6b86bf8601507147e8a28c50d89bcfffc9419 /net/netlink | |
parent | genetlink: use attrs from struct genl_info (diff) | |
download | linux-5c670a010de46687ed27553602d8131ce4d7a9fb.tar.xz linux-5c670a010de46687ed27553602d8131ce4d7a9fb.zip |
genetlink: add a family pointer to struct genl_info
Having family in struct genl_info is quite useful. It cuts
down the number of arguments which need to be passed to
helpers which already take struct genl_info.
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20230814214723.2924989-7-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/genetlink.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index d47879d5a74c..8315d31b53db 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -844,8 +844,8 @@ static int genl_start(struct netlink_callback *cb) genl_family_rcv_msg_attrs_free(attrs); return -ENOMEM; } - info->family = ctx->family; info->op = *ops; + info->info.family = ctx->family; info->info.snd_seq = cb->nlh->nlmsg_seq; info->info.snd_portid = NETLINK_CB(cb->skb).portid; info->info.nlhdr = cb->nlh; @@ -872,11 +872,12 @@ static int genl_start(struct netlink_callback *cb) static int genl_dumpit(struct sk_buff *skb, struct netlink_callback *cb) { - struct genl_dumpit_info *info = cb->data; - const struct genl_split_ops *ops = &info->op; + struct genl_dumpit_info *dump_info = cb->data; + const struct genl_split_ops *ops = &dump_info->op; + struct genl_info *info = &dump_info->info; int rc; - info->info.extack = cb->extack; + info->extack = cb->extack; genl_op_lock(info->family); rc = ops->dumpit(skb, cb); @@ -886,19 +887,20 @@ static int genl_dumpit(struct sk_buff *skb, struct netlink_callback *cb) static int genl_done(struct netlink_callback *cb) { - struct genl_dumpit_info *info = cb->data; - const struct genl_split_ops *ops = &info->op; + struct genl_dumpit_info *dump_info = cb->data; + const struct genl_split_ops *ops = &dump_info->op; + struct genl_info *info = &dump_info->info; int rc = 0; - info->info.extack = cb->extack; + info->extack = cb->extack; if (ops->done) { genl_op_lock(info->family); rc = ops->done(cb); genl_op_unlock(info->family); } - genl_family_rcv_msg_attrs_free(info->info.attrs); - genl_dumpit_info_free(info); + genl_family_rcv_msg_attrs_free(info->attrs); + genl_dumpit_info_free(dump_info); return rc; } @@ -952,6 +954,7 @@ static int genl_family_rcv_msg_doit(const struct genl_family *family, info.snd_seq = nlh->nlmsg_seq; info.snd_portid = NETLINK_CB(skb).portid; + info.family = family; info.nlhdr = nlh; info.genlhdr = nlmsg_data(nlh); info.attrs = attrbuf; |