aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/lockd/lockd.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/lockd/lockd.h')
-rw-r--r--include/linux/lockd/lockd.h72
1 files changed, 46 insertions, 26 deletions
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index b56d5aa9b194..aa6fe7026de7 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -43,12 +43,13 @@ 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,
51 h_server : 1, /* server side, not client side */ 51 h_server : 1, /* server side, not client side */
52 h_noresvport : 1,
52 h_inuse : 1; 53 h_inuse : 1;
53 wait_queue_head_t h_gracewait; /* wait while reclaiming */ 54 wait_queue_head_t h_gracewait; /* wait while reclaiming */
54 struct rw_semaphore h_rwsem; /* Reboot recovery lock */ 55 struct rw_semaphore h_rwsem; /* Reboot recovery lock */
@@ -63,21 +64,29 @@ struct nlm_host {
63 spinlock_t h_lock; 64 spinlock_t h_lock;
64 struct list_head h_granted; /* Locks in GRANTED state */ 65 struct list_head h_granted; /* Locks in GRANTED state */
65 struct list_head h_reclaim; /* Locks in RECLAIM state */ 66 struct list_head h_reclaim; /* Locks in RECLAIM state */
66 struct nsm_handle * h_nsmhandle; /* NSM status handle */ 67 struct nsm_handle *h_nsmhandle; /* NSM status handle */
67 68 char *h_addrbuf; /* address eyecatcher */
68 char h_addrbuf[48], /* address eyecatchers */
69 h_srcaddrbuf[48];
70}; 69};
71 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
72struct nsm_handle { 79struct nsm_handle {
73 struct list_head sm_link; 80 struct list_head sm_link;
74 atomic_t sm_count; 81 atomic_t sm_count;
75 char * sm_name; 82 char *sm_mon_name;
83 char *sm_name;
76 struct sockaddr_storage sm_addr; 84 struct sockaddr_storage sm_addr;
77 size_t sm_addrlen; 85 size_t sm_addrlen;
78 unsigned int sm_monitored : 1, 86 unsigned int sm_monitored : 1,
79 sm_sticky : 1; /* don't unmonitor */ 87 sm_sticky : 1; /* don't unmonitor */
80 char sm_addrbuf[48]; /* address eyecatcher */ 88 struct nsm_private sm_priv;
89 char sm_addrbuf[NSM_ADDRBUF];
81}; 90};
82 91
83/* 92/*
@@ -103,16 +112,6 @@ static inline struct sockaddr *nlm_srcaddr(const struct nlm_host *host)
103 return (struct sockaddr *)&host->h_srcaddr; 112 return (struct sockaddr *)&host->h_srcaddr;
104} 113}
105 114
106static inline struct sockaddr_in *nsm_addr_in(const struct nsm_handle *handle)
107{
108 return (struct sockaddr_in *)&handle->sm_addr;
109}
110
111static inline struct sockaddr *nsm_addr(const struct nsm_handle *handle)
112{
113 return (struct sockaddr *)&handle->sm_addr;
114}
115
116/* 115/*
117 * Map an fl_owner_t into a unique 32-bit "pid" 116 * Map an fl_owner_t into a unique 32-bit "pid"
118 */ 117 */
@@ -196,6 +195,7 @@ extern struct svc_procedure nlmsvc_procedures4[];
196extern int nlmsvc_grace_period; 195extern int nlmsvc_grace_period;
197extern unsigned long nlmsvc_timeout; 196extern unsigned long nlmsvc_timeout;
198extern int nsm_use_hostnames; 197extern int nsm_use_hostnames;
198extern int nsm_local_state;
199 199
200/* 200/*
201 * Lockd client functions 201 * Lockd client functions
@@ -220,7 +220,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
220 const size_t salen, 220 const size_t salen,
221 const unsigned short protocol, 221 const unsigned short protocol,
222 const u32 version, 222 const u32 version,
223 const char *hostname); 223 const char *hostname,
224 int noresvport);
224struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, 225struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
225 const char *hostname, 226 const char *hostname,
226 const size_t hostname_len); 227 const size_t hostname_len);
@@ -229,10 +230,20 @@ void nlm_rebind_host(struct nlm_host *);
229struct nlm_host * nlm_get_host(struct nlm_host *); 230struct nlm_host * nlm_get_host(struct nlm_host *);
230void nlm_release_host(struct nlm_host *); 231void nlm_release_host(struct nlm_host *);
231void nlm_shutdown_hosts(void); 232void nlm_shutdown_hosts(void);
232extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, 233void nlm_host_rebooted(const struct nlm_reboot *);
233 unsigned int, u32); 234
234void nsm_release(struct nsm_handle *); 235/*
236 * Host monitoring
237 */
238int nsm_monitor(const struct nlm_host *host);
239void nsm_unmonitor(const struct nlm_host *host);
235 240
241struct nsm_handle *nsm_get_handle(const struct sockaddr *sap,
242 const size_t salen,
243 const char *hostname,
244 const size_t hostname_len);
245struct nsm_handle *nsm_reboot_lookup(const struct nlm_reboot *info);
246void nsm_release(struct nsm_handle *nsm);
236 247
237/* 248/*
238 * This is used in garbage collection and resource reclaim 249 * This is used in garbage collection and resource reclaim
@@ -280,16 +291,25 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
280static inline int __nlm_privileged_request4(const struct sockaddr *sap) 291static inline int __nlm_privileged_request4(const struct sockaddr *sap)
281{ 292{
282 const struct sockaddr_in *sin = (struct sockaddr_in *)sap; 293 const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
283 return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) && 294
284 (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);
285} 299}
286 300
287#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 301#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
288static inline int __nlm_privileged_request6(const struct sockaddr *sap) 302static inline int __nlm_privileged_request6(const struct sockaddr *sap)
289{ 303{
290 const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; 304 const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
291 return (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK) && 305
292 (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;
293} 313}
294#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ 314#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
295static inline int __nlm_privileged_request6(const struct sockaddr *sap) 315static inline int __nlm_privileged_request6(const struct sockaddr *sap)