netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ethtool] ethtool: do_sset return correct value on fail
@ 2020-12-13 14:25 Tariq Toukan
  2020-12-14  8:35 ` Michal Kubecek
  0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2020-12-13 14:25 UTC (permalink / raw)
  To: John W . Linville; +Cc: netdev, Roy Novich, Tariq Toukan

From: Roy Novich <royno@nvidia.com>

The return value for do_sset was constant and returned 0.
This value is misleading when returned on operation failure.
Changed return value to the correct function err status.

Fixes: 32c8037055f5 ("Initial import of ethtool version 3 + a few patches.")
Signed-off-by: Roy Novich <royno@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ethtool.c b/ethtool.c
index 1d9067e774af..5cc875c64591 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3287,7 +3287,7 @@ static int do_sset(struct cmd_context *ctx)
 		}
 	}
 
-	return 0;
+	return err;
 }
 
 static int do_gregs(struct cmd_context *ctx)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ethtool] ethtool: do_sset return correct value on fail
  2020-12-13 14:25 [PATCH ethtool] ethtool: do_sset return correct value on fail Tariq Toukan
@ 2020-12-14  8:35 ` Michal Kubecek
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Kubecek @ 2020-12-14  8:35 UTC (permalink / raw)
  To: Tariq Toukan; +Cc: John W. Linville, netdev, Roy Novich

On Sun, Dec 13, 2020 at 04:25:03PM +0200, Tariq Toukan wrote:
> From: Roy Novich <royno@nvidia.com>
> 
> The return value for do_sset was constant and returned 0.
> This value is misleading when returned on operation failure.
> Changed return value to the correct function err status.
> 
> Fixes: 32c8037055f5 ("Initial import of ethtool version 3 + a few patches.")
> Signed-off-by: Roy Novich <royno@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
>  ethtool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ethtool.c b/ethtool.c
> index 1d9067e774af..5cc875c64591 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -3287,7 +3287,7 @@ static int do_sset(struct cmd_context *ctx)
>  		}
>  	}
>  
> -	return 0;
> +	return err;
>  }
>  
>  static int do_gregs(struct cmd_context *ctx)

I'm afraid it's not as easy as this. The problem with -s/--set
subcommand is that its parameters are in fact implemented by three
separate requests (for ioctl, four requests for netlink). Each of them
may fail or succeed independently of others. Currently do_sset() always
returns 0 which is indeed unfortunate but it's not clear what should we
return if some requests fail and some succeed.

With your patch, do_sset() would always return the result of last
request it sent to kernel which is inconsistent; consider e.g.

  ethtool -s eth0 mdix on wol g

If the ETHTOOL_SLINKSETTINGS request setting MDI-X succeeds and
ETHTOOL_SWOL setting WoL fails, the result would be a failure. But if
setting MDI-X fails and setting WoL succeeds, do_sset() would report
success.

So if we really want to change the behaviour after so many years, it
should be consistent: either return non-zero exit code if any request
fails or if all fail. (Personally, I would prefer the latter.) And we
should probably modify nl_sset() to behave the same way as it currently
bails out on first failed request.

Michal

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-14  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-13 14:25 [PATCH ethtool] ethtool: do_sset return correct value on fail Tariq Toukan
2020-12-14  8:35 ` Michal Kubecek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).