diff options
-rw-r--r-- | fs/lockd/clntlock.c | 2 | ||||
-rw-r--r-- | fs/lockd/host.c | 4 | ||||
-rw-r--r-- | fs/lockd/mon.c | 2 | ||||
-rw-r--r-- | fs/lockd/svcsubs.c | 2 | ||||
-rw-r--r-- | include/linux/lockd/lockd.h | 43 | ||||
-rw-r--r-- | include/linux/sunrpc/clnt.h | 48 |
6 files changed, 53 insertions, 48 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 1f3b0fc0d351..fc9032dc8862 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c | |||
@@ -166,7 +166,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock) | |||
166 | */ | 166 | */ |
167 | if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid) | 167 | if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid) |
168 | continue; | 168 | continue; |
169 | if (!nlm_cmp_addr(nlm_addr(block->b_host), addr)) | 169 | if (!rpc_cmp_addr(nlm_addr(block->b_host), addr)) |
170 | continue; | 170 | continue; |
171 | if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0) | 171 | if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0) |
172 | continue; | 172 | continue; |
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 7cb076ac6b45..4600c2037b8b 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
@@ -111,7 +111,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) | |||
111 | */ | 111 | */ |
112 | chain = &nlm_hosts[nlm_hash_address(ni->sap)]; | 112 | chain = &nlm_hosts[nlm_hash_address(ni->sap)]; |
113 | hlist_for_each_entry(host, pos, chain, h_hash) { | 113 | hlist_for_each_entry(host, pos, chain, h_hash) { |
114 | if (!nlm_cmp_addr(nlm_addr(host), ni->sap)) | 114 | if (!rpc_cmp_addr(nlm_addr(host), ni->sap)) |
115 | continue; | 115 | continue; |
116 | 116 | ||
117 | /* See if we have an NSM handle for this client */ | 117 | /* See if we have an NSM handle for this client */ |
@@ -125,7 +125,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) | |||
125 | if (host->h_server != ni->server) | 125 | if (host->h_server != ni->server) |
126 | continue; | 126 | continue; |
127 | if (ni->server && | 127 | if (ni->server && |
128 | !nlm_cmp_addr(nlm_srcaddr(host), ni->src_sap)) | 128 | !rpc_cmp_addr(nlm_srcaddr(host), ni->src_sap)) |
129 | continue; | 129 | continue; |
130 | 130 | ||
131 | /* Move to head of hash chain. */ | 131 | /* Move to head of hash chain. */ |
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 30c933188dd7..f956651d0f65 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c | |||
@@ -209,7 +209,7 @@ static struct nsm_handle *nsm_lookup_addr(const struct sockaddr *sap) | |||
209 | struct nsm_handle *nsm; | 209 | struct nsm_handle *nsm; |
210 | 210 | ||
211 | list_for_each_entry(nsm, &nsm_handles, sm_link) | 211 | list_for_each_entry(nsm, &nsm_handles, sm_link) |
212 | if (nlm_cmp_addr(nsm_addr(nsm), sap)) | 212 | if (rpc_cmp_addr(nsm_addr(nsm), sap)) |
213 | return nsm; | 213 | return nsm; |
214 | return NULL; | 214 | return NULL; |
215 | } | 215 | } |
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index 9e4d6aab611b..ad478da7ca63 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c | |||
@@ -417,7 +417,7 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb); | |||
417 | static int | 417 | static int |
418 | nlmsvc_match_ip(void *datap, struct nlm_host *host) | 418 | nlmsvc_match_ip(void *datap, struct nlm_host *host) |
419 | { | 419 | { |
420 | return nlm_cmp_addr(nlm_srcaddr(host), datap); | 420 | return rpc_cmp_addr(nlm_srcaddr(host), datap); |
421 | } | 421 | } |
422 | 422 | ||
423 | /** | 423 | /** |
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index c325b187966b..e7a251a988c0 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
@@ -338,49 +338,6 @@ static inline int nlm_privileged_requester(const struct svc_rqst *rqstp) | |||
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | static inline int __nlm_cmp_addr4(const struct sockaddr *sap1, | ||
342 | const struct sockaddr *sap2) | ||
343 | { | ||
344 | const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1; | ||
345 | const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2; | ||
346 | return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; | ||
347 | } | ||
348 | |||
349 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
350 | static inline int __nlm_cmp_addr6(const struct sockaddr *sap1, | ||
351 | const struct sockaddr *sap2) | ||
352 | { | ||
353 | const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1; | ||
354 | const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2; | ||
355 | return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr); | ||
356 | } | ||
357 | #else /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */ | ||
358 | static inline int __nlm_cmp_addr6(const struct sockaddr *sap1, | ||
359 | const struct sockaddr *sap2) | ||
360 | { | ||
361 | return 0; | ||
362 | } | ||
363 | #endif /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */ | ||
364 | |||
365 | /* | ||
366 | * Compare two host addresses | ||
367 | * | ||
368 | * Return TRUE if the addresses are the same; otherwise FALSE. | ||
369 | */ | ||
370 | static inline int nlm_cmp_addr(const struct sockaddr *sap1, | ||
371 | const struct sockaddr *sap2) | ||
372 | { | ||
373 | if (sap1->sa_family == sap2->sa_family) { | ||
374 | switch (sap1->sa_family) { | ||
375 | case AF_INET: | ||
376 | return __nlm_cmp_addr4(sap1, sap2); | ||
377 | case AF_INET6: | ||
378 | return __nlm_cmp_addr6(sap1, sap2); | ||
379 | } | ||
380 | } | ||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | /* | 341 | /* |
385 | * Compare two NLM locks. | 342 | * Compare two NLM locks. |
386 | * When the second lock is of type F_UNLCK, this acts like a wildcard. | 343 | * When the second lock is of type F_UNLCK, this acts like a wildcard. |
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index ab3f6e90caa5..b17df361be82 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/sunrpc/timer.h> | 22 | #include <linux/sunrpc/timer.h> |
23 | #include <asm/signal.h> | 23 | #include <asm/signal.h> |
24 | #include <linux/path.h> | 24 | #include <linux/path.h> |
25 | #include <net/ipv6.h> | ||
25 | 26 | ||
26 | struct rpc_inode; | 27 | struct rpc_inode; |
27 | 28 | ||
@@ -188,5 +189,52 @@ static inline void rpc_set_port(struct sockaddr *sap, | |||
188 | #define IPV6_SCOPE_DELIMITER '%' | 189 | #define IPV6_SCOPE_DELIMITER '%' |
189 | #define IPV6_SCOPE_ID_LEN sizeof("%nnnnnnnnnn") | 190 | #define IPV6_SCOPE_ID_LEN sizeof("%nnnnnnnnnn") |
190 | 191 | ||
192 | static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1, | ||
193 | const struct sockaddr *sap2) | ||
194 | { | ||
195 | const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1; | ||
196 | const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2; | ||
197 | |||
198 | return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; | ||
199 | } | ||
200 | |||
201 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
202 | static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, | ||
203 | const struct sockaddr *sap2) | ||
204 | { | ||
205 | const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1; | ||
206 | const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2; | ||
207 | return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr); | ||
208 | } | ||
209 | #else /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */ | ||
210 | static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, | ||
211 | const struct sockaddr *sap2) | ||
212 | { | ||
213 | return false; | ||
214 | } | ||
215 | #endif /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */ | ||
216 | |||
217 | /** | ||
218 | * rpc_cmp_addr - compare the address portion of two sockaddrs. | ||
219 | * @sap1: first sockaddr | ||
220 | * @sap2: second sockaddr | ||
221 | * | ||
222 | * Just compares the family and address portion. Ignores port, scope, etc. | ||
223 | * Returns true if the addrs are equal, false if they aren't. | ||
224 | */ | ||
225 | static inline bool rpc_cmp_addr(const struct sockaddr *sap1, | ||
226 | const struct sockaddr *sap2) | ||
227 | { | ||
228 | if (sap1->sa_family == sap2->sa_family) { | ||
229 | switch (sap1->sa_family) { | ||
230 | case AF_INET: | ||
231 | return __rpc_cmp_addr4(sap1, sap2); | ||
232 | case AF_INET6: | ||
233 | return __rpc_cmp_addr6(sap1, sap2); | ||
234 | } | ||
235 | } | ||
236 | return false; | ||
237 | } | ||
238 | |||
191 | #endif /* __KERNEL__ */ | 239 | #endif /* __KERNEL__ */ |
192 | #endif /* _LINUX_SUNRPC_CLNT_H */ | 240 | #endif /* _LINUX_SUNRPC_CLNT_H */ |