aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Jones <tom.jones@klarasystems.com>2023-09-25 18:33:45 +0000
committerMateusz Piotrowski <0mp@FreeBSD.org>2023-11-09 20:54:28 +0000
commit14105aae555cc22554d87ab041ee736c086f5ef1 (patch)
treee18782d32a121fd0381326f513aebb6d1da18c27
parent6e5b1ff71e01bd48172483cb6df921f84300ea3a (diff)
downloadsrc-14105aae555cc22554d87ab041ee736c086f5ef1.tar.gz
src-14105aae555cc22554d87ab041ee736c086f5ef1.zip
nlm: Fix error messages for failed remote rpcbind contact
In case of a remote rpcbind connection timeout, the NFS kernel lock manager emits an error message along the lines of: NLM: failed to contact remote rpcbind, stat = 5, port = 28416 In the Bugzilla PR, Garrett Wollman identified the following problems with that error message: - The error is in decimal, which can only be deciphered by reading the source code. - The port number is byte-swapped. - The error message does not identify the client the NLM is trying to communicate with. Fix the shortcomings of the current error message by: - Printing out the port number correctly. - Mentioning the remote client. The low-level decimal error remains an outstanding issue though. It seems like the error strings describing the error codes live outside of the kernel code currently. PR: 244698 Reported by: wollman Approved by: allanjude Sponsored by: National Bureau of Economic Research Sponsored by: Klara, Inc. Co-authored-by: Mateusz Piotrowski <0mp@FreeBSD.org>
-rw-r--r--sys/nlm/nlm_prot_impl.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c
index a5b917b07f8b..216c4ac82b53 100644
--- a/sys/nlm/nlm_prot_impl.c
+++ b/sys/nlm/nlm_prot_impl.c
@@ -343,6 +343,12 @@ nlm_get_rpc(struct sockaddr *sa, rpcprog_t prog, rpcvers_t vers)
bool_t tryagain = FALSE;
struct portmap mapping;
u_short port = 0;
+ struct sockaddr_in *sin4;
+ char namebuf[INET_ADDRSTRLEN];
+#ifdef INET6
+ struct sockaddr_in6 *sin6;
+ char namebuf6[INET6_ADDRSTRLEN];
+#endif
/*
* First we need to contact the remote RPCBIND service to find
@@ -489,8 +495,26 @@ again:
}
/* Otherwise, bad news. */
- NLM_ERR("NLM: failed to contact remote rpcbind, "
- "stat = %d, port = %d\n", (int) stat, port);
+ switch (ss.ss_family) {
+ case AF_INET:
+ sin4 = (struct sockaddr_in *)&ss;
+ inet_ntop(ss.ss_family, &sin4->sin_addr,
+ namebuf, sizeof namebuf);
+ NLM_ERR("NLM: failed to contact remote rpcbind, "
+ "stat = %d, host = %s, port = %d\n",
+ (int) stat, namebuf, htons(port));
+ break;
+#ifdef INET6
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *)&ss;
+ inet_ntop(ss.ss_family, &sin6->sin6_addr,
+ namebuf6, sizeof namebuf6);
+ NLM_ERR("NLM: failed to contact remote rpcbind, "
+ "stat = %d, host = %s, port = %d\n",
+ (int) stat, namebuf6, htons(port));
+ break;
+#endif
+ }
CLNT_DESTROY(rpcb);
return (NULL);
}