[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230105040531.353563-13-kuba@kernel.org>
Date: Wed, 4 Jan 2023 20:05:28 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
jacob.e.keller@...el.com, jiri@...nulli.us,
Jakub Kicinski <kuba@...nel.org>, Jiri Pirko <jiri@...dia.com>
Subject: [PATCH net-next v2 12/15] devlink: restart dump based on devlink instance ids (function)
Use xarray id for cases of sub-objects which are iterated in
a function.
Reviewed-by: Jiri Pirko <jiri@...dia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
net/devlink/leftover.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
index 358cdfbb1393..091f8814185d 100644
--- a/net/devlink/leftover.c
+++ b/net/devlink/leftover.c
@@ -2547,12 +2547,12 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink *devlink;
- struct devlink_sb *devlink_sb;
- unsigned long index;
- int idx = 0;
int err = 0;
- devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
+ devlink_dump_for_each_instance_get(msg, state, devlink) {
+ struct devlink_sb *devlink_sb;
+ int idx = 0;
+
if (!devlink->ops->sb_pool_get)
goto retry;
@@ -2567,6 +2567,7 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
} else if (err) {
devl_unlock(devlink);
devlink_put(devlink);
+ state->idx = idx;
goto out;
}
}
@@ -2578,7 +2579,6 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
if (err != -EMSGSIZE)
return err;
- state->idx = idx;
return msg->len;
}
@@ -2762,12 +2762,12 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink *devlink;
- struct devlink_sb *devlink_sb;
- unsigned long index;
- int idx = 0;
int err = 0;
- devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
+ devlink_dump_for_each_instance_get(msg, state, devlink) {
+ struct devlink_sb *devlink_sb;
+ int idx = 0;
+
if (!devlink->ops->sb_port_pool_get)
goto retry;
@@ -2782,6 +2782,7 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
} else if (err) {
devl_unlock(devlink);
devlink_put(devlink);
+ state->idx = idx;
goto out;
}
}
@@ -2793,7 +2794,6 @@ static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
if (err != -EMSGSIZE)
return err;
- state->idx = idx;
return msg->len;
}
@@ -3005,12 +3005,12 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink *devlink;
- struct devlink_sb *devlink_sb;
- unsigned long index;
- int idx = 0;
int err = 0;
- devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
+ devlink_dump_for_each_instance_get(msg, state, devlink) {
+ struct devlink_sb *devlink_sb;
+ int idx = 0;
+
if (!devlink->ops->sb_tc_pool_bind_get)
goto retry;
@@ -3025,6 +3025,7 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
} else if (err) {
devl_unlock(devlink);
devlink_put(devlink);
+ state->idx = idx;
goto out;
}
}
@@ -3036,7 +3037,6 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
if (err != -EMSGSIZE)
return err;
- state->idx = idx;
return msg->len;
}
@@ -6085,19 +6085,20 @@ static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg,
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink *devlink;
- unsigned long index;
- int idx = 0;
int err = 0;
- devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
+ devlink_dump_for_each_instance_get(msg, state, devlink) {
+ int idx = 0;
+
err = devlink_nl_cmd_region_get_devlink_dumpit(msg, cb, devlink,
&idx, state->idx);
devlink_put(devlink);
- if (err)
+ if (err) {
+ state->idx = idx;
goto out;
+ }
}
out:
- state->idx = idx;
return msg->len;
}
--
2.38.1
Powered by blists - more mailing lists