diff options
Diffstat (limited to 'include/linux/lockd/lockd.h')
| -rw-r--r-- | include/linux/lockd/lockd.h | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 23da3fa69efa..aa6fe7026de7 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
| @@ -43,8 +43,8 @@ struct nlm_host { | |||
| 43 | struct sockaddr_storage h_addr; /* peer address */ | 43 | struct sockaddr_storage h_addr; /* peer address */ |
| 44 | size_t h_addrlen; | 44 | size_t h_addrlen; |
| 45 | struct sockaddr_storage h_srcaddr; /* our address (optional) */ | 45 | struct sockaddr_storage h_srcaddr; /* our address (optional) */ |
| 46 | struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */ | 46 | struct rpc_clnt *h_rpcclnt; /* RPC client to talk to peer */ |
| 47 | char * h_name; /* remote hostname */ | 47 | char *h_name; /* remote hostname */ |
| 48 | u32 h_version; /* interface version */ | 48 | u32 h_version; /* interface version */ |
| 49 | unsigned short h_proto; /* transport proto */ | 49 | unsigned short h_proto; /* transport proto */ |
| 50 | unsigned short h_reclaiming : 1, | 50 | unsigned short h_reclaiming : 1, |
| @@ -64,21 +64,29 @@ struct nlm_host { | |||
| 64 | spinlock_t h_lock; | 64 | spinlock_t h_lock; |
| 65 | struct list_head h_granted; /* Locks in GRANTED state */ | 65 | struct list_head h_granted; /* Locks in GRANTED state */ |
| 66 | struct list_head h_reclaim; /* Locks in RECLAIM state */ | 66 | struct list_head h_reclaim; /* Locks in RECLAIM state */ |
| 67 | struct nsm_handle * h_nsmhandle; /* NSM status handle */ | 67 | struct nsm_handle *h_nsmhandle; /* NSM status handle */ |
| 68 | 68 | char *h_addrbuf; /* address eyecatcher */ | |
| 69 | char h_addrbuf[48], /* address eyecatchers */ | ||
| 70 | h_srcaddrbuf[48]; | ||
| 71 | }; | 69 | }; |
| 72 | 70 | ||
| 71 | /* | ||
| 72 | * The largest string sm_addrbuf should hold is a full-size IPv6 address | ||
| 73 | * (no "::" anywhere) with a scope ID. The buffer size is computed to | ||
| 74 | * hold eight groups of colon-separated four-hex-digit numbers, a | ||
| 75 | * percent sign, a scope id (at most 32 bits, in decimal), and NUL. | ||
| 76 | */ | ||
| 77 | #define NSM_ADDRBUF ((8 * 4 + 7) + (1 + 10) + 1) | ||
| 78 | |||
| 73 | struct nsm_handle { | 79 | struct nsm_handle { |
| 74 | struct list_head sm_link; | 80 | struct list_head sm_link; |
| 75 | atomic_t sm_count; | 81 | atomic_t sm_count; |
| 76 | char * sm_name; | 82 | char *sm_mon_name; |
| 83 | char *sm_name; | ||
| 77 | struct sockaddr_storage sm_addr; | 84 | struct sockaddr_storage sm_addr; |
| 78 | size_t sm_addrlen; | 85 | size_t sm_addrlen; |
| 79 | unsigned int sm_monitored : 1, | 86 | unsigned int sm_monitored : 1, |
| 80 | sm_sticky : 1; /* don't unmonitor */ | 87 | sm_sticky : 1; /* don't unmonitor */ |
| 81 | char sm_addrbuf[48]; /* address eyecatcher */ | 88 | struct nsm_private sm_priv; |
| 89 | char sm_addrbuf[NSM_ADDRBUF]; | ||
| 82 | }; | 90 | }; |
| 83 | 91 | ||
| 84 | /* | 92 | /* |
| @@ -104,16 +112,6 @@ static inline struct sockaddr *nlm_srcaddr(const struct nlm_host *host) | |||
| 104 | return (struct sockaddr *)&host->h_srcaddr; | 112 | return (struct sockaddr *)&host->h_srcaddr; |
| 105 | } | 113 | } |
| 106 | 114 | ||
| 107 | static inline struct sockaddr_in *nsm_addr_in(const struct nsm_handle *handle) | ||
| 108 | { | ||
| 109 | return (struct sockaddr_in *)&handle->sm_addr; | ||
| 110 | } | ||
| 111 | |||
| 112 | static inline struct sockaddr *nsm_addr(const struct nsm_handle *handle) | ||
| 113 | { | ||
| 114 | return (struct sockaddr *)&handle->sm_addr; | ||
| 115 | } | ||
| 116 | |||
| 117 | /* | 115 | /* |
| 118 | * Map an fl_owner_t into a unique 32-bit "pid" | 116 | * Map an fl_owner_t into a unique 32-bit "pid" |
| 119 | */ | 117 | */ |
| @@ -197,6 +195,7 @@ extern struct svc_procedure nlmsvc_procedures4[]; | |||
| 197 | extern int nlmsvc_grace_period; | 195 | extern int nlmsvc_grace_period; |
| 198 | extern unsigned long nlmsvc_timeout; | 196 | extern unsigned long nlmsvc_timeout; |
| 199 | extern int nsm_use_hostnames; | 197 | extern int nsm_use_hostnames; |
| 198 | extern int nsm_local_state; | ||
| 200 | 199 | ||
| 201 | /* | 200 | /* |
| 202 | * Lockd client functions | 201 | * Lockd client functions |
| @@ -231,10 +230,20 @@ void nlm_rebind_host(struct nlm_host *); | |||
| 231 | struct nlm_host * nlm_get_host(struct nlm_host *); | 230 | struct nlm_host * nlm_get_host(struct nlm_host *); |
| 232 | void nlm_release_host(struct nlm_host *); | 231 | void nlm_release_host(struct nlm_host *); |
| 233 | void nlm_shutdown_hosts(void); | 232 | void nlm_shutdown_hosts(void); |
| 234 | extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, | 233 | void nlm_host_rebooted(const struct nlm_reboot *); |
| 235 | unsigned int, u32); | ||
| 236 | void nsm_release(struct nsm_handle *); | ||
| 237 | 234 | ||
| 235 | /* | ||
| 236 | * Host monitoring | ||
| 237 | */ | ||
| 238 | int nsm_monitor(const struct nlm_host *host); | ||
| 239 | void nsm_unmonitor(const struct nlm_host *host); | ||
| 240 | |||
| 241 | struct nsm_handle *nsm_get_handle(const struct sockaddr *sap, | ||
| 242 | const size_t salen, | ||
| 243 | const char *hostname, | ||
| 244 | const size_t hostname_len); | ||
| 245 | struct nsm_handle *nsm_reboot_lookup(const struct nlm_reboot *info); | ||
| 246 | void nsm_release(struct nsm_handle *nsm); | ||
| 238 | 247 | ||
| 239 | /* | 248 | /* |
| 240 | * This is used in garbage collection and resource reclaim | 249 | * This is used in garbage collection and resource reclaim |
| @@ -282,16 +291,25 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file) | |||
| 282 | static inline int __nlm_privileged_request4(const struct sockaddr *sap) | 291 | static inline int __nlm_privileged_request4(const struct sockaddr *sap) |
| 283 | { | 292 | { |
| 284 | const struct sockaddr_in *sin = (struct sockaddr_in *)sap; | 293 | const struct sockaddr_in *sin = (struct sockaddr_in *)sap; |
| 285 | return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) && | 294 | |
| 286 | (ntohs(sin->sin_port) < 1024); | 295 | if (ntohs(sin->sin_port) > 1023) |
| 296 | return 0; | ||
| 297 | |||
| 298 | return ipv4_is_loopback(sin->sin_addr.s_addr); | ||
| 287 | } | 299 | } |
| 288 | 300 | ||
| 289 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 301 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 290 | static inline int __nlm_privileged_request6(const struct sockaddr *sap) | 302 | static inline int __nlm_privileged_request6(const struct sockaddr *sap) |
| 291 | { | 303 | { |
| 292 | const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | 304 | const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; |
| 293 | return (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK) && | 305 | |
| 294 | (ntohs(sin6->sin6_port) < 1024); | 306 | if (ntohs(sin6->sin6_port) > 1023) |
| 307 | return 0; | ||
| 308 | |||
| 309 | if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED) | ||
| 310 | return ipv4_is_loopback(sin6->sin6_addr.s6_addr32[3]); | ||
| 311 | |||
| 312 | return ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK; | ||
| 295 | } | 313 | } |
| 296 | #else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ | 314 | #else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ |
| 297 | static inline int __nlm_privileged_request6(const struct sockaddr *sap) | 315 | static inline int __nlm_privileged_request6(const struct sockaddr *sap) |
