diff mbox series

[net-next] net: devlink: don't ignore errors during dumpit

Message ID 20191004095012.1287-1-jiri@resnulli.us
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] net: devlink: don't ignore errors during dumpit | expand

Commit Message

Jiri Pirko Oct. 4, 2019, 9:50 a.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Currently, some dumpit function may end-up with error which is not
-EMSGSIZE and this error is silently ignored. Use does not have clue
that something wrong happened. Instead of silent ignore, propagate
the error to user.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/core/devlink.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

Comments

Andrew Lunn Oct. 4, 2019, 1:21 p.m. UTC | #1
On Fri, Oct 04, 2019 at 11:50:12AM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Currently, some dumpit function may end-up with error which is not
> -EMSGSIZE and this error is silently ignored. Use does not have clue
> that something wrong happened. Instead of silent ignore, propagate
> the error to user.
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Thanks Jiri

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Jakub Kicinski Oct. 4, 2019, 9:28 p.m. UTC | #2
On Fri,  4 Oct 2019 11:50:12 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Currently, some dumpit function may end-up with error which is not
> -EMSGSIZE and this error is silently ignored. Use does not have clue
> that something wrong happened. Instead of silent ignore, propagate
> the error to user.
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

I'd personally err on the side of caution and add this non-EMSGSIZE
handling to all the *_dumpit() helpers, even those which can only get 
a size error today, but I guess it's not super likely the errors will
change for the more static objects..

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
David Miller Oct. 4, 2019, 10:15 p.m. UTC | #3
From: Jiri Pirko <jiri@resnulli.us>
Date: Fri,  4 Oct 2019 11:50:12 +0200

> From: Jiri Pirko <jiri@mellanox.com>
> 
> Currently, some dumpit function may end-up with error which is not
> -EMSGSIZE and this error is silently ignored. Use does not have clue
> that something wrong happened. Instead of silent ignore, propagate
> the error to user.
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Applied.
diff mbox series

Patch

diff --git a/net/core/devlink.c b/net/core/devlink.c
index e48680efe54a..b7edbd14518b 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1035,7 +1035,7 @@  static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
 	struct devlink_sb *devlink_sb;
 	int start = cb->args[0];
 	int idx = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&devlink_mutex);
 	list_for_each_entry(devlink, &devlink_list, list) {
@@ -1058,6 +1058,9 @@  static int devlink_nl_cmd_sb_pool_get_dumpit(struct sk_buff *msg,
 out:
 	mutex_unlock(&devlink_mutex);
 
+	if (err != -EMSGSIZE)
+		return err;
+
 	cb->args[0] = idx;
 	return msg->len;
 }
@@ -1233,7 +1236,7 @@  static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
 	struct devlink_sb *devlink_sb;
 	int start = cb->args[0];
 	int idx = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&devlink_mutex);
 	list_for_each_entry(devlink, &devlink_list, list) {
@@ -1256,6 +1259,9 @@  static int devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
 out:
 	mutex_unlock(&devlink_mutex);
 
+	if (err != -EMSGSIZE)
+		return err;
+
 	cb->args[0] = idx;
 	return msg->len;
 }
@@ -1460,7 +1466,7 @@  devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
 	struct devlink_sb *devlink_sb;
 	int start = cb->args[0];
 	int idx = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&devlink_mutex);
 	list_for_each_entry(devlink, &devlink_list, list) {
@@ -1485,6 +1491,9 @@  devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
 out:
 	mutex_unlock(&devlink_mutex);
 
+	if (err != -EMSGSIZE)
+		return err;
+
 	cb->args[0] = idx;
 	return msg->len;
 }
@@ -3155,7 +3164,7 @@  static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg,
 	struct devlink *devlink;
 	int start = cb->args[0];
 	int idx = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&devlink_mutex);
 	list_for_each_entry(devlink, &devlink_list, list) {
@@ -3183,6 +3192,9 @@  static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg,
 out:
 	mutex_unlock(&devlink_mutex);
 
+	if (err != -EMSGSIZE)
+		return err;
+
 	cb->args[0] = idx;
 	return msg->len;
 }
@@ -3411,7 +3423,7 @@  static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
 	struct devlink *devlink;
 	int start = cb->args[0];
 	int idx = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&devlink_mutex);
 	list_for_each_entry(devlink, &devlink_list, list) {
@@ -3444,6 +3456,9 @@  static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
 out:
 	mutex_unlock(&devlink_mutex);
 
+	if (err != -EMSGSIZE)
+		return err;
+
 	cb->args[0] = idx;
 	return msg->len;
 }
@@ -4066,7 +4081,7 @@  static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
 	struct devlink *devlink;
 	int start = cb->args[0];
 	int idx = 0;
-	int err;
+	int err = 0;
 
 	mutex_lock(&devlink_mutex);
 	list_for_each_entry(devlink, &devlink_list, list) {
@@ -4094,6 +4109,9 @@  static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
 	}
 	mutex_unlock(&devlink_mutex);
 
+	if (err != -EMSGSIZE)
+		return err;
+
 	cb->args[0] = idx;
 	return msg->len;
 }