diff options
| -rw-r--r-- | fs/lockd/host.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 3c4dc33c1bea..5876b0e4c0be 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
| @@ -40,12 +40,13 @@ static struct nsm_handle *nsm_find(const struct sockaddr *sap, | |||
| 40 | 40 | ||
| 41 | struct nlm_lookup_host_info { | 41 | struct nlm_lookup_host_info { |
| 42 | const int server; /* search for server|client */ | 42 | const int server; /* search for server|client */ |
| 43 | const struct sockaddr_in *sin; /* address to search for */ | 43 | const struct sockaddr *sap; /* address to search for */ |
| 44 | const size_t salen; /* it's length */ | ||
| 44 | const unsigned short protocol; /* transport to search for*/ | 45 | const unsigned short protocol; /* transport to search for*/ |
| 45 | const u32 version; /* NLM version to search for */ | 46 | const u32 version; /* NLM version to search for */ |
| 46 | const char *hostname; /* remote's hostname */ | 47 | const char *hostname; /* remote's hostname */ |
| 47 | const size_t hostname_len; /* it's length */ | 48 | const size_t hostname_len; /* it's length */ |
| 48 | const struct sockaddr_in *src_sin; /* our address (optional) */ | 49 | const struct sockaddr *src_sap; /* our address (optional) */ |
| 49 | const size_t src_len; /* it's length */ | 50 | const size_t src_len; /* it's length */ |
| 50 | }; | 51 | }; |
| 51 | 52 | ||
| @@ -151,9 +152,9 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) | |||
| 151 | * different NLM rpc_clients into one single nlm_host object. | 152 | * different NLM rpc_clients into one single nlm_host object. |
| 152 | * This would allow us to have one nlm_host per address. | 153 | * This would allow us to have one nlm_host per address. |
| 153 | */ | 154 | */ |
| 154 | chain = &nlm_hosts[nlm_hash_address((struct sockaddr *)ni->sin)]; | 155 | chain = &nlm_hosts[nlm_hash_address(ni->sap)]; |
| 155 | hlist_for_each_entry(host, pos, chain, h_hash) { | 156 | hlist_for_each_entry(host, pos, chain, h_hash) { |
| 156 | if (!nlm_cmp_addr(nlm_addr(host), (struct sockaddr *)ni->sin)) | 157 | if (!nlm_cmp_addr(nlm_addr(host), ni->sap)) |
| 157 | continue; | 158 | continue; |
| 158 | 159 | ||
| 159 | /* See if we have an NSM handle for this client */ | 160 | /* See if we have an NSM handle for this client */ |
| @@ -166,8 +167,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) | |||
| 166 | continue; | 167 | continue; |
| 167 | if (host->h_server != ni->server) | 168 | if (host->h_server != ni->server) |
| 168 | continue; | 169 | continue; |
| 169 | if (!nlm_cmp_addr(nlm_srcaddr(host), | 170 | if (!nlm_cmp_addr(nlm_srcaddr(host), ni->src_sap)) |
| 170 | (struct sockaddr *)ni->src_sin)) | ||
| 171 | continue; | 171 | continue; |
| 172 | 172 | ||
| 173 | /* Move to head of hash chain. */ | 173 | /* Move to head of hash chain. */ |
| @@ -188,8 +188,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) | |||
| 188 | atomic_inc(&nsm->sm_count); | 188 | atomic_inc(&nsm->sm_count); |
| 189 | else { | 189 | else { |
| 190 | host = NULL; | 190 | host = NULL; |
| 191 | nsm = nsm_find((struct sockaddr *)ni->sin, | 191 | nsm = nsm_find(ni->sap, ni->salen, |
| 192 | sizeof(struct sockaddr_in), | ||
| 193 | ni->hostname, ni->hostname_len, 1); | 192 | ni->hostname, ni->hostname_len, 1); |
| 194 | if (!nsm) { | 193 | if (!nsm) { |
| 195 | dprintk("lockd: nlm_lookup_host failed; " | 194 | dprintk("lockd: nlm_lookup_host failed; " |
| @@ -205,10 +204,10 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) | |||
| 205 | goto out; | 204 | goto out; |
| 206 | } | 205 | } |
| 207 | host->h_name = nsm->sm_name; | 206 | host->h_name = nsm->sm_name; |
| 208 | memcpy(nlm_addr(host), ni->sin, sizeof(struct sockaddr_in)); | 207 | memcpy(nlm_addr(host), ni->sap, ni->salen); |
| 209 | host->h_addrlen = sizeof(struct sockaddr_in); | 208 | host->h_addrlen = ni->salen; |
| 210 | nlm_clear_port(nlm_addr(host)); | 209 | nlm_clear_port(nlm_addr(host)); |
| 211 | memcpy(nlm_srcaddr(host), ni->src_sin, sizeof(struct sockaddr_in)); | 210 | memcpy(nlm_srcaddr(host), ni->src_sap, ni->src_len); |
| 212 | host->h_version = ni->version; | 211 | host->h_version = ni->version; |
| 213 | host->h_proto = ni->protocol; | 212 | host->h_proto = ni->protocol; |
| 214 | host->h_rpcclnt = NULL; | 213 | host->h_rpcclnt = NULL; |
| @@ -273,17 +272,19 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin, | |||
| 273 | const char *hostname, | 272 | const char *hostname, |
| 274 | unsigned int hostname_len) | 273 | unsigned int hostname_len) |
| 275 | { | 274 | { |
| 276 | const struct sockaddr_in source = { | 275 | const struct sockaddr source = { |
| 277 | .sin_family = AF_UNSPEC, | 276 | .sa_family = AF_UNSPEC, |
| 278 | }; | 277 | }; |
| 279 | struct nlm_lookup_host_info ni = { | 278 | struct nlm_lookup_host_info ni = { |
| 280 | .server = 0, | 279 | .server = 0, |
| 281 | .sin = sin, | 280 | .sap = (struct sockaddr *)sin, |
| 281 | .salen = sizeof(*sin), | ||
| 282 | .protocol = proto, | 282 | .protocol = proto, |
| 283 | .version = version, | 283 | .version = version, |
| 284 | .hostname = hostname, | 284 | .hostname = hostname, |
| 285 | .hostname_len = hostname_len, | 285 | .hostname_len = hostname_len, |
| 286 | .src_sin = &source, | 286 | .src_sap = &source, |
| 287 | .src_len = sizeof(source), | ||
| 287 | }; | 288 | }; |
| 288 | 289 | ||
| 289 | dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__, | 290 | dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__, |
| @@ -306,12 +307,14 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp, | |||
| 306 | }; | 307 | }; |
| 307 | struct nlm_lookup_host_info ni = { | 308 | struct nlm_lookup_host_info ni = { |
| 308 | .server = 1, | 309 | .server = 1, |
| 309 | .sin = svc_addr_in(rqstp), | 310 | .sap = svc_addr(rqstp), |
| 311 | .salen = rqstp->rq_addrlen, | ||
| 310 | .protocol = rqstp->rq_prot, | 312 | .protocol = rqstp->rq_prot, |
| 311 | .version = rqstp->rq_vers, | 313 | .version = rqstp->rq_vers, |
| 312 | .hostname = hostname, | 314 | .hostname = hostname, |
| 313 | .hostname_len = hostname_len, | 315 | .hostname_len = hostname_len, |
| 314 | .src_sin = &source, | 316 | .src_sap = (struct sockaddr *)&source, |
| 317 | .src_len = sizeof(source), | ||
| 315 | }; | 318 | }; |
| 316 | 319 | ||
| 317 | dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__, | 320 | dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__, |
