summaryrefslogtreecommitdiff
path: root/net/devlink/netlink.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2023-08-28 08:16:46 +0200
committerJakub Kicinski <kuba@kernel.org>2023-08-28 08:02:22 -0700
commit2475ed158c478c624d8fbc8d639d344a960c1ad8 (patch)
tree85fe5422675e67b44cd0f8ee469968045d5438c3 /net/devlink/netlink.c
parent2b4d8bb0888930b4a26cd46ec067753228877488 (diff)
devlink: move and rename devlink_dpipe_send_and_alloc_skb() helper
Since both dpipe and resource code is using this helper, in preparation for code split to separate files, move devlink_dpipe_send_and_alloc_skb() helper into netlink.c. Rename it on the way. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Link: https://lore.kernel.org/r/20230828061657.300667-5-jiri@resnulli.us Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/devlink/netlink.c')
-rw-r--r--net/devlink/netlink.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
index 72a5005a64cd..5f57afd31dea 100644
--- a/net/devlink/netlink.c
+++ b/net/devlink/netlink.c
@@ -82,6 +82,21 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_REGION_DIRECT] = { .type = NLA_FLAG },
};
+int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info)
+{
+ int err;
+
+ if (*msg) {
+ err = genlmsg_reply(*msg, info);
+ if (err)
+ return err;
+ }
+ *msg = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!*msg)
+ return -ENOMEM;
+ return 0;
+}
+
struct devlink *
devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs)
{