Whamcloud - gitweb
LU-19072 lnet: don't crash if ni_status is NULL 82/59482/2
authorTimothy Day <timday@amazon.com>
Thu, 29 May 2025 18:36:16 +0000 (18:36 +0000)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Jun 2025 06:37:03 +0000 (06:37 +0000)
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 <timday@amazon.com>
Change-Id: I1d8ba9b5f6478d2a915ac6c7f33c22d1742c43d0
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59482
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Max Wang <wamax@amazon.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-lnet.h
lnet/lnet/lnet_debugfs.c

index 1838c3d..d723bc2 100644 (file)
@@ -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);
index 5403d27..29a78cd 100644 (file)
@@ -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) {