lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221130013736.90875-1-kuba@kernel.org>
Date:   Tue, 29 Nov 2022 17:37:36 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     mkubecek@...e.cz
Cc:     netdev@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH ethtool-next] linkstate: report the number of hard link flaps

Print the recently added link down event statistics when
present. We need to query the netlink policy to know if
the stats are supported.

Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
 netlink/settings.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/netlink/settings.c b/netlink/settings.c
index ea86e365383b..14ad0b46e102 100644
--- a/netlink/settings.c
+++ b/netlink/settings.c
@@ -5,6 +5,7 @@
  */
 
 #include <errno.h>
+#include <inttypes.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -772,6 +773,13 @@ int linkstate_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		}
 	}
 
+	if (tb[ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT]) {
+		uint32_t val;
+
+		val = mnl_attr_get_u32(tb[ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT]);
+		printf("\tLink Down Events: %u\n", val);
+	}
+
 	return MNL_CB_OK;
 }
 
@@ -882,12 +890,16 @@ int debug_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 	return MNL_CB_OK;
 }
 
-static int gset_request(struct nl_socket *nlsk, uint8_t msg_type,
+static int gset_request(struct nl_context *nlctx, uint8_t msg_type,
 			uint16_t hdr_attr, mnl_cb_t cb)
 {
+	struct nl_socket *nlsk = nlctx->ethnl_socket;
+	u32 flags;
 	int ret;
 
-	ret = nlsock_prep_get_request(nlsk, msg_type, hdr_attr, 0);
+	flags = get_stats_flag(nlctx, msg_type, hdr_attr);
+
+	ret = nlsock_prep_get_request(nlsk, msg_type, hdr_attr, flags);
 	if (ret < 0)
 		return ret;
 	return nlsock_send_get_request(nlsk, cb);
@@ -896,7 +908,6 @@ static int gset_request(struct nl_socket *nlsk, uint8_t msg_type,
 int nl_gset(struct cmd_context *ctx)
 {
 	struct nl_context *nlctx = ctx->nlctx;
-	struct nl_socket *nlsk = nlctx->ethnl_socket;
 	int ret;
 
 	if (netlink_cmd_check(ctx, ETHTOOL_MSG_LINKMODES_GET, true) ||
@@ -908,27 +919,27 @@ int nl_gset(struct cmd_context *ctx)
 
 	nlctx->suppress_nlerr = 1;
 
-	ret = gset_request(nlsk, ETHTOOL_MSG_LINKMODES_GET,
+	ret = gset_request(nlctx, ETHTOOL_MSG_LINKMODES_GET,
 			   ETHTOOL_A_LINKMODES_HEADER, linkmodes_reply_cb);
 	if (ret == -ENODEV)
 		return ret;
 
-	ret = gset_request(nlsk, ETHTOOL_MSG_LINKINFO_GET,
+	ret = gset_request(nlctx, ETHTOOL_MSG_LINKINFO_GET,
 			   ETHTOOL_A_LINKINFO_HEADER, linkinfo_reply_cb);
 	if (ret == -ENODEV)
 		return ret;
 
-	ret = gset_request(nlsk, ETHTOOL_MSG_WOL_GET, ETHTOOL_A_WOL_HEADER,
+	ret = gset_request(nlctx, ETHTOOL_MSG_WOL_GET, ETHTOOL_A_WOL_HEADER,
 			   wol_reply_cb);
 	if (ret == -ENODEV)
 		return ret;
 
-	ret = gset_request(nlsk, ETHTOOL_MSG_DEBUG_GET, ETHTOOL_A_DEBUG_HEADER,
+	ret = gset_request(nlctx, ETHTOOL_MSG_DEBUG_GET, ETHTOOL_A_DEBUG_HEADER,
 			   debug_reply_cb);
 	if (ret == -ENODEV)
 		return ret;
 
-	ret = gset_request(nlsk, ETHTOOL_MSG_LINKSTATE_GET,
+	ret = gset_request(nlctx, ETHTOOL_MSG_LINKSTATE_GET,
 			   ETHTOOL_A_LINKSTATE_HEADER, linkstate_reply_cb);
 	if (ret == -ENODEV)
 		return ret;
-- 
2.38.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ