[lustre-devel] [PATCH 42/50] lnet: Check LNET_NID_IS_ANY in LNET_NID_NET

James Simmons jsimmons at infradead.org
Sun Mar 20 06:30:56 PDT 2022

From: Chris Horn <chris.horn at hpe.com>

If LNET_NID_NET is passed the wildcard NID (LNET_ANY_NID) then we
should return the wildcard net (LNET_NET_ANY). This also allows NULL
to be used as an argument to LNET_NID_NET.

Fixes: 6935d7108f ("lnet: Change lnet_send() to take large-addr nids")
WC-bug-id: https://jira.whamcloud.com/browse/LU-15478
Signed-off-by: Chris Horn <chris.horn at hpe.com>
Reviewed-on: https://review.whamcloud.com/46292
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Serguei Smirnov <ssmirnov at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
 include/uapi/linux/lnet/lnet-types.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/lnet/lnet-types.h b/include/uapi/linux/lnet/lnet-types.h
index eacc401..c5fca5c 100644
--- a/include/uapi/linux/lnet/lnet-types.h
+++ b/include/uapi/linux/lnet/lnet-types.h
@@ -125,7 +125,10 @@ static inline int nid_is_nid4(const struct lnet_nid *nid)
 static inline __u32 LNET_NID_NET(const struct lnet_nid *nid)
-	return LNET_MKNET(nid->nid_type, __be16_to_cpu(nid->nid_num));
+	if (LNET_NID_IS_ANY(nid))
+		return LNET_NET_ANY;
+	else
+		return LNET_MKNET(nid->nid_type, __be16_to_cpu(nid->nid_num));
 static inline void lnet_nid4_to_nid(lnet_nid_t nid4, struct lnet_nid *nid)

More information about the lustre-devel mailing list