netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Maxim Mikityanskiy <maximmi@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org
Subject: Re: [PATCH ethtool 2/2] netlink: Print and return an error when features weren't changed
Date: Sun, 23 Aug 2020 18:03:20 +0200	[thread overview]
Message-ID: <20200823160320.onkv4kqgye7u6b2c@lion.mk-sys.cz> (raw)
In-Reply-To: <20200814131745.32215-3-maximmi@mellanox.com>

[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]

On Fri, Aug 14, 2020 at 04:17:45PM +0300, Maxim Mikityanskiy wrote:
> The legacy ethtool prints an error message and returns 1 if no features
> were changed as requested. Port this behavior to ethtool-netlink.
> req_mask is compared to wanted_mask to detect if any feature was
> changed. If these masks are equal, it means that the kernel hasn't
> changed anything, and all bits got to wanted.
> 
> Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
> ---
>  netlink/features.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/netlink/features.c b/netlink/features.c
> index 133529d..4f63fa2 100644
> --- a/netlink/features.c
> +++ b/netlink/features.c
[...]
> @@ -471,8 +480,10 @@ int sfeatures_reply_cb(const struct nlmsghdr *nlhdr, void *data)
>  		return MNL_CB_OK;
>  	}
>  
> -	show_feature_changes(nlctx, tb);
> -	return MNL_CB_OK;
> +	if (show_feature_changes(nlctx, tb))
> +		return MNL_CB_OK;
> +	else
> +		return MNL_CB_ERROR;

I agree with the general change and the code aboved detecting the
condition but this kind of error is IMHO not so critical that it would
justify bailing out and completely ignoring the final NLMSG_ERROR with
kernel return code and possible extack (error/warning message).

I would rather suggest to set a flag (e.g. in sfctx) when "no requested
change performed" result is detected and leave displaying the error
message and setting the exit code after the whole message queue is
processed. What do you think?

Michal

>  }
>  
>  int nl_sfeatures(struct cmd_context *ctx)
> -- 
> 2.21.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2020-08-23 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14 13:17 [PATCH ethtool 0/2] ethtool-netlink compatibility fixes Maxim Mikityanskiy
2020-08-14 13:17 ` [PATCH ethtool 1/2] netlink: Fix the condition for displaying actual changes Maxim Mikityanskiy
2020-08-23 15:55   ` Michal Kubecek
2020-08-14 13:17 ` [PATCH ethtool 2/2] netlink: Print and return an error when features weren't changed Maxim Mikityanskiy
2020-08-23 16:03   ` Michal Kubecek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200823160320.onkv4kqgye7u6b2c@lion.mk-sys.cz \
    --to=mkubecek@suse.cz \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=maximmi@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).