Skip to contentSkip to conversation

netlink: settings: Fix for wrong auto-negotiation state

PATCH Superseded Mohan Prasad J 2 participants 3 messages Oct 16, 2024 – Nov 4, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netlink: settings: Fix for wrong auto-negotiation state

Auto-negotiation state in json format showed the opposite state due to wrong comparison.
Fix for returning the correct auto-neg state implemented.

---
 netlink/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/settings.c +1 -1
index dbfb520..a454bfb 100644
@@ -546,7 +546,7 @@ int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 						(autoneg == AUTONEG_DISABLE) ? "off" : "on");
 		else
 			print_bool(PRINT_JSON, "auto-negotiation", NULL,
-				   autoneg == AUTONEG_DISABLE);
+				   (autoneg == AUTONEG_DISABLE) ? false : true);
 	}
 	if (tb[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG]) {
 		uint8_t val;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 14 lines · Mohan Prasad J

Auto-negotiation state in json format showed the opposite state due to wrong comparison.
Fix for returning the correct auto-neg state implemented.

---
 netlink/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/settings.c +0 -0
index dbfb520..a454bfb 100644

netlink/settings.c int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data) · line 552

Quoted 8 lines
netlink/settings.c +1 -1
@@ -546,7 +546,7 @@ int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 						(autoneg == AUTONEG_DISABLE) ? "off" : "on");
 		else
 			print_bool(PRINT_JSON, "auto-negotiation", NULL,
-				   autoneg == AUTONEG_DISABLE);
+				   (autoneg == AUTONEG_DISABLE) ? false : true);
 	}
 	if (tb[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG]) {
 		uint8_t val;

The fix looks correct but isn't

	(autoneg == AUTONEG_DISABLE) ? false : true

just a more complicated way to say

	autoneg != AUTONEG_DISABLE

(and harder to read)?

Michal

#2 lore raw

Hello Michal,

Thank you for the comments.

Quoted 29 lines · Mohan Prasad J

netlink/settings.c int linkmodes_reply_cb(const struct nlmsghdr

Quoted 14 lines

Auto-negotiation state in json format showed the opposite state due to wrong comparison.
Fix for returning the correct auto-neg state implemented.

---
 netlink/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/settings.c index renamed from netlink/settings.c +0 -0

dbfb520..a454bfb 100644

netlink/settings.c +0 -0
@@ -546,7 +546,7 @@ int linkmodes_reply_cb(const struct nlmsghdr

*nlhdr, void *data)

netlink/settings.c int linkmodes_reply_cb(const struct nlmsghdr · line 546

Quoted 1 line
netlink/settings.c +0 -0
 						(autoneg ==

AUTONEG_DISABLE) ? "off" : "on");

netlink/settings.c int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data)

Quoted 4 lines
netlink/settings.c +1 -1
 		else
 			print_bool(PRINT_JSON, "auto-negotiation", NULL,
-				   autoneg == AUTONEG_DISABLE);
+				   (autoneg == AUTONEG_DISABLE) ? false :

true);

netlink/settings.c int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data) · line 552

Quoted 3 lines
netlink/settings.c +0 -0
 	}
 	if (tb[ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG]) {
 		uint8_t val;

The fix looks correct but isn't

Quoted 7 lines
	(autoneg == AUTONEG_DISABLE) ? false : true

just a more complicated way to say

	autoneg != AUTONEG_DISABLE

(and harder to read)?

You are right. (autoneg != AUTONEG_DISABLE) would be more simpler and easy to read. I will update it in the next version.

Thanks,
Mohan Prasad J