diff mbox series

[ethtool,1/2] netlink: Fix the condition for displaying actual changes

Message ID 20200814131745.32215-2-maximmi@mellanox.com
State Accepted
Delegated to: Michal Kubecek
Headers show
Series ethtool-netlink compatibility fixes | expand

Commit Message

Maxim Mikityanskiy Aug. 14, 2020, 1:17 p.m. UTC
This comment in the code:

    /* result is not exactly as requested, show differences */

implies that the "Actual changes" output should be displayed only if the
result is not as requested, which matches the legacy ethtool behavior.
However, in fact, ethtool-netlink displays "actual changes" even when
the changes are expected (e.g., one bit was requested, and it was
changed as requested).

This commit fixes the condition above to make the behavior match the
description in the comment and the behavior of the legacy ethtool. The
new condition excludes the req_mask bits from active_mask to avoid
reacting on bit changes that we asked for. The new condition now
matches the ifs in the loop above that print "[requested on/off]" and
"[not requested]".

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
---
 netlink/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Kubecek Aug. 23, 2020, 3:55 p.m. UTC | #1
On Fri, Aug 14, 2020 at 04:17:44PM +0300, Maxim Mikityanskiy wrote:
> This comment in the code:
> 
>     /* result is not exactly as requested, show differences */
> 
> implies that the "Actual changes" output should be displayed only if the
> result is not as requested, which matches the legacy ethtool behavior.
> However, in fact, ethtool-netlink displays "actual changes" even when
> the changes are expected (e.g., one bit was requested, and it was
> changed as requested).
> 
> This commit fixes the condition above to make the behavior match the
> description in the comment and the behavior of the legacy ethtool. The
> new condition excludes the req_mask bits from active_mask to avoid
> reacting on bit changes that we asked for. The new condition now
> matches the ifs in the loop above that print "[requested on/off]" and
> "[not requested]".
> 
> Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>

Applied, thank you.

Michal

> ---
>  netlink/features.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/netlink/features.c b/netlink/features.c
> index 8b5b858..133529d 100644
> --- a/netlink/features.c
> +++ b/netlink/features.c
> @@ -413,7 +413,7 @@ static void show_feature_changes(struct nl_context *nlctx,
>  
>  	diff = false;
>  	for (i = 0; i < words; i++)
> -		if (wanted_mask[i] || active_mask[i])
> +		if (wanted_mask[i] || (active_mask[i] & ~sfctx->req_mask[i]))
>  			diff = true;
>  	if (!diff)
>  		return;
> -- 
> 2.21.0
>
diff mbox series

Patch

diff --git a/netlink/features.c b/netlink/features.c
index 8b5b858..133529d 100644
--- a/netlink/features.c
+++ b/netlink/features.c
@@ -413,7 +413,7 @@  static void show_feature_changes(struct nl_context *nlctx,
 
 	diff = false;
 	for (i = 0; i < words; i++)
-		if (wanted_mask[i] || active_mask[i])
+		if (wanted_mask[i] || (active_mask[i] & ~sfctx->req_mask[i]))
 			diff = true;
 	if (!diff)
 		return;