[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230720121829.566974-7-jiri@resnulli.us>
Date: Thu, 20 Jul 2023 14:18:24 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: netdev@...r.kernel.org
Cc: kuba@...nel.org,
pabeni@...hat.com,
davem@...emloft.net,
edumazet@...gle.com,
moshe@...dia.com,
saeedm@...dia.com,
idosch@...dia.com,
petrm@...dia.com
Subject: [patch net-next v2 06/11] devlink: convert param get command to split ops
From: Jiri Pirko <jiri@...dia.com>
Do the conversion of param get command to split ops. Introduce
devlink_nl_pre_doit_simple() helper to indicate just devlink handle
attributes parsing and use it as pre_doit() callback.
Signed-off-by: Jiri Pirko <jiri@...dia.com>
---
net/devlink/devl_internal.h | 4 +++-
net/devlink/leftover.c | 13 +++----------
net/devlink/netlink.c | 24 ++++++++++++++++++++++++
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index 948b112c1328..5ba3f066b3b2 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -116,7 +116,7 @@ struct devlink_cmd {
struct netlink_callback *cb);
};
-extern const struct genl_small_ops devlink_nl_ops[54];
+extern const struct genl_small_ops devlink_nl_ops[53];
struct devlink *
devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs);
@@ -211,6 +211,8 @@ int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb, struct genl_info *inf
int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_get_doit(struct sk_buff *skb,
struct genl_info *info);
+int devlink_nl_cmd_param_get_doit(struct sk_buff *skb,
+ struct genl_info *info);
int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
index 262f3e49e87b..8729dd740171 100644
--- a/net/devlink/leftover.c
+++ b/net/devlink/leftover.c
@@ -4295,8 +4295,8 @@ devlink_param_get_from_info(struct xarray *params, struct genl_info *info)
return devlink_param_find_by_name(params, param_name);
}
-static int devlink_nl_cmd_param_get_doit(struct sk_buff *skb,
- struct genl_info *info)
+int devlink_nl_cmd_param_get_doit(struct sk_buff *skb,
+ struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_param_item *param_item;
@@ -6301,7 +6301,7 @@ static int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
return devlink_trap_policer_set(devlink, policer_item, info);
}
-const struct genl_small_ops devlink_nl_ops[54] = {
+const struct genl_small_ops devlink_nl_ops[53] = {
{
.cmd = DEVLINK_CMD_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -6489,13 +6489,6 @@ const struct genl_small_ops devlink_nl_ops[54] = {
.doit = devlink_nl_cmd_reload,
.flags = GENL_ADMIN_PERM,
},
- {
- .cmd = DEVLINK_CMD_PARAM_GET,
- .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .doit = devlink_nl_cmd_param_get_doit,
- .dumpit = devlink_nl_instance_iter_dumpit,
- /* can be retrieved by unprivileged users */
- },
{
.cmd = DEVLINK_CMD_PARAM_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
index 794370e4d04a..bd128584e8c8 100644
--- a/net/devlink/netlink.c
+++ b/net/devlink/netlink.c
@@ -147,6 +147,12 @@ static int devlink_nl_pre_doit(const struct genl_split_ops *ops,
return __devlink_nl_pre_doit(skb, info, ops->internal_flags);
}
+static int devlink_nl_pre_doit_simple(const struct genl_split_ops *ops,
+ struct sk_buff *skb, struct genl_info *info)
+{
+ return __devlink_nl_pre_doit(skb, info, 0);
+}
+
static int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info)
{
@@ -245,6 +251,24 @@ static const struct genl_split_ops devlink_nl_split_ops[] = {
.maxattr = DEVLINK_ATTR_MAX,
.policy = devlink_nl_policy,
},
+ {
+ .cmd = DEVLINK_CMD_PARAM_GET,
+ .pre_doit = devlink_nl_pre_doit_simple,
+ .doit = devlink_nl_cmd_param_get_doit,
+ .post_doit = devlink_nl_post_doit,
+ .flags = GENL_CMD_CAP_DO,
+ .validate = GENL_DONT_VALIDATE_STRICT,
+ .maxattr = DEVLINK_ATTR_MAX,
+ .policy = devlink_nl_policy,
+ },
+ {
+ .cmd = DEVLINK_CMD_PARAM_GET,
+ .dumpit = devlink_nl_instance_iter_dumpit,
+ .flags = GENL_CMD_CAP_DUMP,
+ .validate = GENL_DONT_VALIDATE_DUMP,
+ .maxattr = DEVLINK_ATTR_MAX,
+ .policy = devlink_nl_policy,
+ },
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_GET,
.pre_doit = devlink_nl_pre_doit_port_optional,
--
2.41.0
Powered by blists - more mailing lists