linkstate: report the number of hard link flaps
Subsystems (2)
Jakub Kicinski
maintainerPATCH 1/1 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 <[email protected]>
--- netlink/settings.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
netlink/settings.c +19 -8
@@ -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;
Signature · 1 line
2.38.1
This patch was applied to ethtool/ethtool.git (next) by Michal Kubecek <[email protected]>:
Hello:
This patch was applied to ethtool/ethtool.git (next) by Michal Kubecek <[email protected]>:
Quoted 8 lines · On Tue, 29 Nov 2022 17:37:36 -0800 you wrote:
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 <[email protected]>--- netlink/settings.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
Here is the summary with links:
- [ethtool-next] linkstate: report the number of hard link flaps
https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=c179c6e997eb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html