diff options
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/host.c | 78 |
1 files changed, 61 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 | ||
43 | static 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 | |||
149 | out: | 188 | out: |
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 | ||