From 7aba5126752c5734eae7de5363ad914aecd064d4 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Thu, 29 May 2025 18:36:16 +0000 Subject: [PATCH] LU-19072 lnet: don't crash if ni_status is NULL When reading LNet tunables, ni_status can be NULL. This triggers an LASSERT() rather than gracefully handling it. Instead, don't crash. Remove the LASSERT(). lnet_ni_get_status_locked() already handles a NULL ni_status. While it's questionable whether ni_status == NULL should be LNET_NI_STATUS_UP or LNET_NI_STATUS_DOWN, it definitely should not crash. Also, use lnet_ni_get_status() instead of lnet_ni_get_status_locked(). Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: I1d8ba9b5f6478d2a915ac6c7f33c22d1742c43d0 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59482 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Max Wang Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-lnet.h | 12 ++++++++++++ lnet/lnet/lnet_debugfs.c | 5 +---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 1838c3d..d723bc2 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -258,6 +258,18 @@ lnet_ni_set_status(struct lnet_ni *ni, __u32 status) return update; } +static inline unsigned int +lnet_ni_get_status(struct lnet_ni *ni) +{ + unsigned int status; + + lnet_ni_lock(ni); + status = lnet_ni_get_status_locked(ni); + lnet_ni_unlock(ni); + + return status; +} + static inline void lnet_md_wait_handling(struct lnet_libmd *md, int cpt) { wait_queue_head_t *wq = __var_waitqueue(md); diff --git a/lnet/lnet/lnet_debugfs.c b/lnet/lnet/lnet_debugfs.c index 5403d27..29a78cd 100644 --- a/lnet/lnet/lnet_debugfs.c +++ b/lnet/lnet/lnet_debugfs.c @@ -741,11 +741,8 @@ proc_lnet_nis(const struct ctl_table *table, int write, if (the_lnet.ln_routing) last_alive = now - ni->ni_net->net_last_alive; - lnet_ni_lock(ni); - LASSERT(ni->ni_status != NULL); - stat = (lnet_ni_get_status_locked(ni) == + stat = (lnet_ni_get_status(ni) == LNET_NI_STATUS_UP) ? "up" : "down"; - lnet_ni_unlock(ni); /* @lo forever alive */ if (ni->ni_net->net_lnd->lnd_type == LOLND) { -- 1.8.3.1