For the function lnet_get_ni_stats() the im_idx assumes the idx
is relative to all NIs. With lnet_net_show_dump() the idx we
use is realtive to our own NI list so it doesn't always match
the idx lnet_get_ni_stats() expects. This can lead to the wrong
stats being collected when a net_id is set. The only reason we
need an idx for lnet_get_ni_stats() is so the NI can be located
but we already know the NI. Just call lnet_usr_translate_stats()
directly instead of using lnet_get_ni_stats() to figure out the
NI to call lnet_user_translate_stats() internally with.
Test-Parameters: trivial testlist=sanity-lnet
Fixes:
8f8f6e2f36e ("LU-10003 lnet: use Netlink to support old and new NI APIs.")
Change-Id: Ie39e65146c21d976f9a7655eead8c46e9293ee27
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57885
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
if (gnlh->version < 2)
goto skip_msg_stats;
- msg_stats.im_idx = idx - 1;
- rc = lnet_get_ni_stats(&msg_stats);
- if (rc < 0) {
- NL_SET_ERR_MSG(extack,
- "failed to get msg stats");
- genlmsg_cancel(msg, hdr);
- GOTO(net_unlock, rc = -ENOMEM);
- }
-
+ lnet_usr_translate_stats(&msg_stats, &ni->ni_stats);
send_stats = nla_nest_start(msg, LNET_NET_LOCAL_NI_ATTR_SEND_STATS);
send_attr = nla_nest_start(msg, 0);
nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,