diff mbox series

[net] devlink: Fix error handling in param and info_get dumpit cb

Message ID 1569490554-21238-1-git-send-email-vasundhara-v.volam@broadcom.com
State Changes Requested
Delegated to: David Miller
Headers show
Series [net] devlink: Fix error handling in param and info_get dumpit cb | expand

Commit Message

Vasundhara Volam Sept. 26, 2019, 9:35 a.m. UTC
If any of the param or info_get op returns error, dumpit cb is
skipping to dump remaining params or info_get ops for all the
drivers.

Instead skip only for the param/info_get op which returned error
and continue to dump remaining information, except if the return
code is EMSGSIZE.

Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
---
 net/core/devlink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Andrew Lunn Sept. 26, 2019, 12:27 p.m. UTC | #1
On Thu, Sep 26, 2019 at 03:05:54PM +0530, Vasundhara Volam wrote:
> If any of the param or info_get op returns error, dumpit cb is
> skipping to dump remaining params or info_get ops for all the
> drivers.
> 
> Instead skip only for the param/info_get op which returned error
> and continue to dump remaining information, except if the return
> code is EMSGSIZE.

Hi Vasundhara

How do we get to see something did fail? If it failed, it failed for a
reason, and we want to know.

What is your real use case here? What is failing, and why are you
O.K. to skip this failure?

     Andrew
Vasundhara Volam Sept. 27, 2019, 4:58 a.m. UTC | #2
On Thu, Sep 26, 2019 at 5:57 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Thu, Sep 26, 2019 at 03:05:54PM +0530, Vasundhara Volam wrote:
> > If any of the param or info_get op returns error, dumpit cb is
> > skipping to dump remaining params or info_get ops for all the
> > drivers.
> >
> > Instead skip only for the param/info_get op which returned error
> > and continue to dump remaining information, except if the return
> > code is EMSGSIZE.
>
> Hi Vasundhara
>
> How do we get to see something did fail? If it failed, it failed for a
> reason, and we want to know.
>
> What is your real use case here? What is failing, and why are you
> O.K. to skip this failure?
>
>      Andrew
Hi Andrew,

Thank you for looking into the patch.

If any of the devlink parameter is returning error like EINVAL, then
current code is not displaying any further parameters for all the other
devices as well.

In bnxt_en driver case, some of the parameters are not supported in
certain configurations like if the parameter is not part of the
NVM configuration, driver returns EINVAL error to the stack. And devlink is
skipping to display all the remaining parameters for that device and others
as well.

I am trying to fix to skip only the error parameter and display the remaining
parameters.

Thanks,
Vasundhara
Andrew Lunn Sept. 27, 2019, 12:31 p.m. UTC | #3
On Fri, Sep 27, 2019 at 10:28:36AM +0530, Vasundhara Volam wrote:
> On Thu, Sep 26, 2019 at 5:57 PM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > On Thu, Sep 26, 2019 at 03:05:54PM +0530, Vasundhara Volam wrote:
> > > If any of the param or info_get op returns error, dumpit cb is
> > > skipping to dump remaining params or info_get ops for all the
> > > drivers.
> > >
> > > Instead skip only for the param/info_get op which returned error
> > > and continue to dump remaining information, except if the return
> > > code is EMSGSIZE.
> >
> > Hi Vasundhara
> >
> > How do we get to see something did fail? If it failed, it failed for a
> > reason, and we want to know.
> >
> > What is your real use case here? What is failing, and why are you
> > O.K. to skip this failure?
> >
> >      Andrew
> Hi Andrew,
> 
> Thank you for looking into the patch.
> 
> If any of the devlink parameter is returning error like EINVAL, then
> current code is not displaying any further parameters for all the other
> devices as well.
> 
> In bnxt_en driver case, some of the parameters are not supported in
> certain configurations like if the parameter is not part of the
> NVM configuration, driver returns EINVAL error to the stack. And devlink is
> skipping to display all the remaining parameters for that device and others
> as well.
> 
> I am trying to fix to skip only the error parameter and display the remaining
> parameters.

Hi Vasundhara

Thanks for explaining your use case. It sounds sensible. But i would
narrow this down.

Make the driver return EOPNOTSUP, not EINVAL. And then in dump, only
skip EOPNOTSUP. Any other errors cause the error to be returned, so we
get to see them.

   Andrew
Jiri Pirko Sept. 27, 2019, 1:08 p.m. UTC | #4
Fri, Sep 27, 2019 at 02:31:29PM CEST, andrew@lunn.ch wrote:
>On Fri, Sep 27, 2019 at 10:28:36AM +0530, Vasundhara Volam wrote:
>> On Thu, Sep 26, 2019 at 5:57 PM Andrew Lunn <andrew@lunn.ch> wrote:
>> >
>> > On Thu, Sep 26, 2019 at 03:05:54PM +0530, Vasundhara Volam wrote:
>> > > If any of the param or info_get op returns error, dumpit cb is
>> > > skipping to dump remaining params or info_get ops for all the
>> > > drivers.
>> > >
>> > > Instead skip only for the param/info_get op which returned error
>> > > and continue to dump remaining information, except if the return
>> > > code is EMSGSIZE.
>> >
>> > Hi Vasundhara
>> >
>> > How do we get to see something did fail? If it failed, it failed for a
>> > reason, and we want to know.
>> >
>> > What is your real use case here? What is failing, and why are you
>> > O.K. to skip this failure?
>> >
>> >      Andrew
>> Hi Andrew,
>> 
>> Thank you for looking into the patch.
>> 
>> If any of the devlink parameter is returning error like EINVAL, then
>> current code is not displaying any further parameters for all the other
>> devices as well.
>> 
>> In bnxt_en driver case, some of the parameters are not supported in
>> certain configurations like if the parameter is not part of the
>> NVM configuration, driver returns EINVAL error to the stack. And devlink is
>> skipping to display all the remaining parameters for that device and others
>> as well.
>> 
>> I am trying to fix to skip only the error parameter and display the remaining
>> parameters.
>
>Hi Vasundhara
>
>Thanks for explaining your use case. It sounds sensible. But i would
>narrow this down.
>
>Make the driver return EOPNOTSUP, not EINVAL. And then in dump, only
>skip EOPNOTSUP. Any other errors cause the error to be returned, so we
>get to see them.

Agreed, that would be more reasonable.

>
>   Andrew
Vasundhara Volam Sept. 27, 2019, 1:37 p.m. UTC | #5
On Fri, Sep 27, 2019 at 6:01 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Fri, Sep 27, 2019 at 10:28:36AM +0530, Vasundhara Volam wrote:
> > On Thu, Sep 26, 2019 at 5:57 PM Andrew Lunn <andrew@lunn.ch> wrote:
> > >
> > > On Thu, Sep 26, 2019 at 03:05:54PM +0530, Vasundhara Volam wrote:
> > > > If any of the param or info_get op returns error, dumpit cb is
> > > > skipping to dump remaining params or info_get ops for all the
> > > > drivers.
> > > >
> > > > Instead skip only for the param/info_get op which returned error
> > > > and continue to dump remaining information, except if the return
> > > > code is EMSGSIZE.
> > >
> > > Hi Vasundhara
> > >
> > > How do we get to see something did fail? If it failed, it failed for a
> > > reason, and we want to know.
> > >
> > > What is your real use case here? What is failing, and why are you
> > > O.K. to skip this failure?
> > >
> > >      Andrew
> > Hi Andrew,
> >
> > Thank you for looking into the patch.
> >
> > If any of the devlink parameter is returning error like EINVAL, then
> > current code is not displaying any further parameters for all the other
> > devices as well.
> >
> > In bnxt_en driver case, some of the parameters are not supported in
> > certain configurations like if the parameter is not part of the
> > NVM configuration, driver returns EINVAL error to the stack. And devlink is
> > skipping to display all the remaining parameters for that device and others
> > as well.
> >
> > I am trying to fix to skip only the error parameter and display the remaining
> > parameters.
>
> Hi Vasundhara
>
> Thanks for explaining your use case. It sounds sensible. But i would
> narrow this down.
>
> Make the driver return EOPNOTSUP, not EINVAL. And then in dump, only
> skip EOPNOTSUP. Any other errors cause the error to be returned, so we
> get to see them.
Thank you Andrew, I will modify the patch and resubmit.
>
>    Andrew
diff mbox series

Patch

diff --git a/net/core/devlink.c b/net/core/devlink.c
index e48680e..a1dd1b8 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -3172,7 +3172,7 @@  static int devlink_nl_cmd_param_get_dumpit(struct sk_buff *msg,
 						    NETLINK_CB(cb->skb).portid,
 						    cb->nlh->nlmsg_seq,
 						    NLM_F_MULTI);
-			if (err) {
+			if (err == -EMSGSIZE) {
 				mutex_unlock(&devlink->lock);
 				goto out;
 			}
@@ -3432,7 +3432,7 @@  static int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
 						NETLINK_CB(cb->skb).portid,
 						cb->nlh->nlmsg_seq,
 						NLM_F_MULTI);
-				if (err) {
+				if (err == -EMSGSIZE) {
 					mutex_unlock(&devlink->lock);
 					goto out;
 				}
@@ -4088,7 +4088,7 @@  static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
 					   cb->nlh->nlmsg_seq, NLM_F_MULTI,
 					   cb->extack);
 		mutex_unlock(&devlink->lock);
-		if (err)
+		if (err == -EMSGSIZE)
 			break;
 		idx++;
 	}