net: devlink: don't ignore errors during dumpit
Subsystems (2)
PATCH 1/1 net: devlink: don't ignore errors during dumpit
From: Jiri Pirko <[email protected]>
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.
--- net/core/devlink.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
net/core/devlink.c +24 -6
@@ -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; }
Signature · 1 line
2.21.0
Quoted 9 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Currently, some dumpit function may end-up with error which is not
-EMSGSIZEand 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 <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Thanks Jiri
Andrew
Quoted 9 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Currently, some dumpit function may end-up with error which is not
-EMSGSIZEand 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 <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
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..
From: Jiri Pirko <[email protected]>
Date: Fri, 4 Oct 2019 11:50:12 +0200
Quoted 9 lines
From: Jiri Pirko <[email protected]>
Currently, some dumpit function may end-up with error which is not
-EMSGSIZEand 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 <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Applied.