* [PATCH ethtool-next] linkstate: report the number of hard link flaps
@ 2022-11-30 1:37 Jakub Kicinski
2022-12-04 17:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2022-11-30 1:37 UTC (permalink / raw)
To: mkubecek; +Cc: netdev, Jakub Kicinski
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@kernel.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-04 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-30 1:37 [PATCH ethtool-next] linkstate: report the number of hard link flaps Jakub Kicinski
2022-12-04 17:10 ` patchwork-bot+netdevbpf
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).