aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-08-27 16:57:23 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-09-29 18:13:38 -0400
commit1b333c54a15a746ff6b04a684b0845a66daacef2 (patch)
treed0a09595e34db6b176fbe5f59b60f0c45ee7cd85
parentc2526f42711d93f3455f92a82b5e586880fc44be (diff)
lockd: address-family independent printable addresses
Knowing which source address is used for communicating with remote NLM services can be helpful for debugging configuration problems on hosts with multiple addresses. Keep the dprintk debugging here, but adapt it so it displays AF_INET6 addresses properly. There are also a couple of dprintk clean-ups as well. At some point we will aggregate the helpers that display presentation format addresses into a single set of shared helpers. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--fs/lockd/host.c78
-rw-r--r--include/linux/lockd/lockd.h4
2 files changed, 65 insertions, 17 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index cb26e3d952a2..e5dcfa57e099 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -11,12 +11,14 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/in.h> 13#include <linux/in.h>
14#include <linux/in6.h>
14#include <linux/sunrpc/clnt.h> 15#include <linux/sunrpc/clnt.h>
15#include <linux/sunrpc/svc.h> 16#include <linux/sunrpc/svc.h>
16#include <linux/lockd/lockd.h> 17#include <linux/lockd/lockd.h>
17#include <linux/lockd/sm_inter.h> 18#include <linux/lockd/sm_inter.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
19 20
21#include <net/ipv6.h>
20 22
21#define NLMDBG_FACILITY NLMDBG_HOSTCACHE 23#define NLMDBG_FACILITY NLMDBG_HOSTCACHE
22#define NLM_HOST_NRHASH 32 24#define NLM_HOST_NRHASH 32
@@ -38,6 +40,32 @@ static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
38 const char *hostname, 40 const char *hostname,
39 unsigned int hostname_len); 41 unsigned int hostname_len);
40 42
43static void nlm_display_address(const struct sockaddr *sap,
44 char *buf, const size_t len)
45{
46 const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
47 const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
48
49 switch (sap->sa_family) {
50 case AF_UNSPEC:
51 snprintf(buf, len, "unspecified");
52 break;
53 case AF_INET:
54 snprintf(buf, len, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr));
55 break;
56 case AF_INET6:
57 if (ipv6_addr_v4mapped(&sin6->sin6_addr))
58 snprintf(buf, len, NIPQUAD_FMT,
59 NIPQUAD(sin6->sin6_addr.s6_addr32[3]));
60 else
61 snprintf(buf, len, NIP6_FMT, NIP6(sin6->sin6_addr));
62 break;
63 default:
64 snprintf(buf, len, "unsupported address family");
65 break;
66 }
67}
68
41/* 69/*
42 * Common host lookup routine for server & client 70 * Common host lookup routine for server & client
43 */ 71 */
@@ -54,14 +82,10 @@ static struct nlm_host *nlm_lookup_host(int server,
54 struct nsm_handle *nsm = NULL; 82 struct nsm_handle *nsm = NULL;
55 int hash; 83 int hash;
56 84
57 dprintk("lockd: nlm_lookup_host("NIPQUAD_FMT"->"NIPQUAD_FMT 85 dprintk("lockd: nlm_lookup_host(proto=%d, vers=%u,"
58 ", p=%d, v=%u, my role=%s, name=%.*s)\n", 86 " my role is %s, hostname=%.*s)\n",
59 NIPQUAD(ssin->sin_addr.s_addr), 87 proto, version, server ? "server" : "client",
60 NIPQUAD(sin->sin_addr.s_addr), proto, version, 88 hostname_len, hostname ? hostname : "<none>");
61 server? "server" : "client",
62 hostname_len,
63 hostname? hostname : "<none>");
64
65 89
66 hash = NLM_ADDRHASH(sin->sin_addr.s_addr); 90 hash = NLM_ADDRHASH(sin->sin_addr.s_addr);
67 91
@@ -101,6 +125,8 @@ static struct nlm_host *nlm_lookup_host(int server,
101 hlist_add_head(&host->h_hash, chain); 125 hlist_add_head(&host->h_hash, chain);
102 126
103 nlm_get_host(host); 127 nlm_get_host(host);
128 dprintk("lockd: nlm_lookup_host found host %s (%s)\n",
129 host->h_name, host->h_addrbuf);
104 goto out; 130 goto out;
105 } 131 }
106 132
@@ -113,13 +139,17 @@ static struct nlm_host *nlm_lookup_host(int server,
113 else { 139 else {
114 host = NULL; 140 host = NULL;
115 nsm = nsm_find(sin, hostname, hostname_len); 141 nsm = nsm_find(sin, hostname, hostname_len);
116 if (!nsm) 142 if (!nsm) {
143 dprintk("lockd: nlm_lookup_host failed; "
144 "no nsm handle\n");
117 goto out; 145 goto out;
146 }
118 } 147 }
119 148
120 host = kzalloc(sizeof(*host), GFP_KERNEL); 149 host = kzalloc(sizeof(*host), GFP_KERNEL);
121 if (!host) { 150 if (!host) {
122 nsm_release(nsm); 151 nsm_release(nsm);
152 dprintk("lockd: nlm_lookup_host failed; no memory\n");
123 goto out; 153 goto out;
124 } 154 }
125 host->h_name = nsm->sm_name; 155 host->h_name = nsm->sm_name;
@@ -146,6 +176,15 @@ static struct nlm_host *nlm_lookup_host(int server,
146 INIT_LIST_HEAD(&host->h_reclaim); 176 INIT_LIST_HEAD(&host->h_reclaim);
147 177
148 nrhosts++; 178 nrhosts++;
179
180 nlm_display_address((struct sockaddr *)&host->h_addr,
181 host->h_addrbuf, sizeof(host->h_addrbuf));
182 nlm_display_address((struct sockaddr *)&host->h_saddr,
183 host->h_saddrbuf, sizeof(host->h_saddrbuf));
184
185 dprintk("lockd: nlm_lookup_host created host %s\n",
186 host->h_name);
187
149out: 188out:
150 mutex_unlock(&nlm_host_mutex); 189 mutex_unlock(&nlm_host_mutex);
151 return host; 190 return host;
@@ -210,9 +249,8 @@ nlm_bind_host(struct nlm_host *host)
210{ 249{
211 struct rpc_clnt *clnt; 250 struct rpc_clnt *clnt;
212 251
213 dprintk("lockd: nlm_bind_host("NIPQUAD_FMT"->"NIPQUAD_FMT")\n", 252 dprintk("lockd: nlm_bind_host %s (%s), my addr=%s\n",
214 NIPQUAD(host->h_saddr.sin_addr), 253 host->h_name, host->h_addrbuf, host->h_saddrbuf);
215 NIPQUAD(host->h_addr.sin_addr));
216 254
217 /* Lock host handle */ 255 /* Lock host handle */
218 mutex_lock(&host->h_mutex); 256 mutex_lock(&host->h_mutex);
@@ -224,7 +262,7 @@ nlm_bind_host(struct nlm_host *host)
224 if (time_after_eq(jiffies, host->h_nextrebind)) { 262 if (time_after_eq(jiffies, host->h_nextrebind)) {
225 rpc_force_rebind(clnt); 263 rpc_force_rebind(clnt);
226 host->h_nextrebind = jiffies + NLM_HOST_REBIND; 264 host->h_nextrebind = jiffies + NLM_HOST_REBIND;
227 dprintk("lockd: next rebind in %ld jiffies\n", 265 dprintk("lockd: next rebind in %lu jiffies\n",
228 host->h_nextrebind - jiffies); 266 host->h_nextrebind - jiffies);
229 } 267 }
230 } else { 268 } else {
@@ -327,12 +365,16 @@ void nlm_host_rebooted(const struct sockaddr_in *sin,
327 struct nsm_handle *nsm; 365 struct nsm_handle *nsm;
328 struct nlm_host *host; 366 struct nlm_host *host;
329 367
330 dprintk("lockd: nlm_host_rebooted(%s, %u.%u.%u.%u)\n",
331 hostname, NIPQUAD(sin->sin_addr));
332
333 /* Find the NSM handle for this peer */ 368 /* Find the NSM handle for this peer */
334 if (!(nsm = __nsm_find(sin, hostname, hostname_len, 0))) 369 nsm = __nsm_find(sin, hostname, hostname_len, 0);
370 if (nsm == NULL) {
371 dprintk("lockd: never saw rebooted peer '%.*s' before\n",
372 hostname_len, hostname);
335 return; 373 return;
374 }
375
376 dprintk("lockd: nlm_host_rebooted(%.*s, %s)\n",
377 hostname_len, hostname, nsm->sm_addrbuf);
336 378
337 /* When reclaiming locks on this peer, make sure that 379 /* When reclaiming locks on this peer, make sure that
338 * we set up a new notification */ 380 * we set up a new notification */
@@ -516,6 +558,8 @@ retry:
516 nsm->sm_name = (char *) (nsm + 1); 558 nsm->sm_name = (char *) (nsm + 1);
517 memcpy(nsm->sm_name, hostname, hostname_len); 559 memcpy(nsm->sm_name, hostname, hostname_len);
518 nsm->sm_name[hostname_len] = '\0'; 560 nsm->sm_name[hostname_len] = '\0';
561 nlm_display_address((struct sockaddr *)&nsm->sm_addr,
562 nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
519 atomic_set(&nsm->sm_count, 1); 563 atomic_set(&nsm->sm_count, 1);
520 goto retry; 564 goto retry;
521 565
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index dbb87ab282e8..0691efbd0b34 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -61,6 +61,9 @@ struct nlm_host {
61 struct list_head h_granted; /* Locks in GRANTED state */ 61 struct list_head h_granted; /* Locks in GRANTED state */
62 struct list_head h_reclaim; /* Locks in RECLAIM state */ 62 struct list_head h_reclaim; /* Locks in RECLAIM state */
63 struct nsm_handle * h_nsmhandle; /* NSM status handle */ 63 struct nsm_handle * h_nsmhandle; /* NSM status handle */
64
65 char h_addrbuf[48], /* address eyecatchers */
66 h_saddrbuf[48];
64}; 67};
65 68
66struct nsm_handle { 69struct nsm_handle {
@@ -70,6 +73,7 @@ struct nsm_handle {
70 struct sockaddr_in sm_addr; 73 struct sockaddr_in sm_addr;
71 unsigned int sm_monitored : 1, 74 unsigned int sm_monitored : 1,
72 sm_sticky : 1; /* don't unmonitor */ 75 sm_sticky : 1; /* don't unmonitor */
76 char sm_addrbuf[48]; /* address eyecatcher */
73}; 77};
74 78
75/* 79/*