[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230720121829.566974-8-jiri@resnulli.us>
Date: Thu, 20 Jul 2023 14:18:25 +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 07/11] devlink: convert trap get command to split ops
From: Jiri Pirko <jiri@...dia.com>
Do the conversion of trap get command to split ops.
Signed-off-by: Jiri Pirko <jiri@...dia.com>
---
net/devlink/devl_internal.h | 3 ++-
net/devlink/leftover.c | 11 ++---------
net/devlink/netlink.c | 16 ++++++++++++++++
3 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index 5ba3f066b3b2..dc655d5797a8 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[53];
+extern const struct genl_small_ops devlink_nl_ops[52];
struct devlink *
devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs);
@@ -227,3 +227,4 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info);
+int devlink_nl_cmd_trap_get_doit(struct sk_buff *skb, struct genl_info *info);
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
index 8729dd740171..3dbba1906ee6 100644
--- a/net/devlink/leftover.c
+++ b/net/devlink/leftover.c
@@ -5655,8 +5655,7 @@ static int devlink_nl_trap_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
-static int devlink_nl_cmd_trap_get_doit(struct sk_buff *skb,
- struct genl_info *info)
+int devlink_nl_cmd_trap_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
@@ -6301,7 +6300,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[53] = {
+const struct genl_small_ops devlink_nl_ops[52] = {
{
.cmd = DEVLINK_CMD_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -6591,12 +6590,6 @@ const struct genl_small_ops devlink_nl_ops[53] = {
.doit = devlink_nl_cmd_flash_update,
.flags = GENL_ADMIN_PERM,
},
- {
- .cmd = DEVLINK_CMD_TRAP_GET,
- .doit = devlink_nl_cmd_trap_get_doit,
- .dumpit = devlink_nl_instance_iter_dumpit,
- /* can be retrieved by unprivileged users */
- },
{
.cmd = DEVLINK_CMD_TRAP_SET,
.doit = devlink_nl_cmd_trap_set_doit,
diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
index bd128584e8c8..cabebff6e7a7 100644
--- a/net/devlink/netlink.c
+++ b/net/devlink/netlink.c
@@ -287,6 +287,22 @@ static const struct genl_split_ops devlink_nl_split_ops[] = {
.maxattr = DEVLINK_ATTR_MAX,
.policy = devlink_nl_policy,
},
+ {
+ .cmd = DEVLINK_CMD_TRAP_GET,
+ .pre_doit = devlink_nl_pre_doit_simple,
+ .doit = devlink_nl_cmd_trap_get_doit,
+ .post_doit = devlink_nl_post_doit,
+ .flags = GENL_CMD_CAP_DO,
+ .maxattr = DEVLINK_ATTR_MAX,
+ .policy = devlink_nl_policy,
+ },
+ {
+ .cmd = DEVLINK_CMD_TRAP_GET,
+ .dumpit = devlink_nl_instance_iter_dumpit,
+ .flags = GENL_CMD_CAP_DUMP,
+ .maxattr = DEVLINK_ATTR_MAX,
+ .policy = devlink_nl_policy,
+ },
};
struct genl_family devlink_nl_family __ro_after_init = {
--
2.41.0
Powered by blists - more mailing lists