aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc/clnt.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sunrpc/clnt.h')
-rw-r--r--include/linux/sunrpc/clnt.h157
1 files changed, 154 insertions, 3 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 37881f1a0bd7..8ed9642a5a76 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -9,6 +9,10 @@
9#ifndef _LINUX_SUNRPC_CLNT_H 9#ifndef _LINUX_SUNRPC_CLNT_H
10#define _LINUX_SUNRPC_CLNT_H 10#define _LINUX_SUNRPC_CLNT_H
11 11
12#include <linux/socket.h>
13#include <linux/in.h>
14#include <linux/in6.h>
15
12#include <linux/sunrpc/msg_prot.h> 16#include <linux/sunrpc/msg_prot.h>
13#include <linux/sunrpc/sched.h> 17#include <linux/sunrpc/sched.h>
14#include <linux/sunrpc/xprt.h> 18#include <linux/sunrpc/xprt.h>
@@ -17,6 +21,8 @@
17#include <linux/sunrpc/xdr.h> 21#include <linux/sunrpc/xdr.h>
18#include <linux/sunrpc/timer.h> 22#include <linux/sunrpc/timer.h>
19#include <asm/signal.h> 23#include <asm/signal.h>
24#include <linux/path.h>
25#include <net/ipv6.h>
20 26
21struct rpc_inode; 27struct rpc_inode;
22 28
@@ -50,9 +56,7 @@ struct rpc_clnt {
50 56
51 int cl_nodelen; /* nodename length */ 57 int cl_nodelen; /* nodename length */
52 char cl_nodename[UNX_MAXNODENAME]; 58 char cl_nodename[UNX_MAXNODENAME];
53 char cl_pathname[30];/* Path in rpc_pipe_fs */ 59 struct path cl_path;
54 struct vfsmount * cl_vfsmnt;
55 struct dentry * cl_dentry; /* inode */
56 struct rpc_clnt * cl_parent; /* Points to parent of clones */ 60 struct rpc_clnt * cl_parent; /* Points to parent of clones */
57 struct rpc_rtt cl_rtt_default; 61 struct rpc_rtt cl_rtt_default;
58 struct rpc_timeout cl_timeout_default; 62 struct rpc_timeout cl_timeout_default;
@@ -110,6 +114,7 @@ struct rpc_create_args {
110 rpc_authflavor_t authflavor; 114 rpc_authflavor_t authflavor;
111 unsigned long flags; 115 unsigned long flags;
112 char *client_name; 116 char *client_name;
117 struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */
113}; 118};
114 119
115/* Values for "flags" field */ 120/* Values for "flags" field */
@@ -151,5 +156,151 @@ void rpc_force_rebind(struct rpc_clnt *);
151size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); 156size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
152const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); 157const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
153 158
159size_t rpc_ntop(const struct sockaddr *, char *, const size_t);
160size_t rpc_pton(const char *, const size_t,
161 struct sockaddr *, const size_t);
162char * rpc_sockaddr2uaddr(const struct sockaddr *);
163size_t rpc_uaddr2sockaddr(const char *, const size_t,
164 struct sockaddr *, const size_t);
165
166static inline unsigned short rpc_get_port(const struct sockaddr *sap)
167{
168 switch (sap->sa_family) {
169 case AF_INET:
170 return ntohs(((struct sockaddr_in *)sap)->sin_port);
171 case AF_INET6:
172 return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
173 }
174 return 0;
175}
176
177static inline void rpc_set_port(struct sockaddr *sap,
178 const unsigned short port)
179{
180 switch (sap->sa_family) {
181 case AF_INET:
182 ((struct sockaddr_in *)sap)->sin_port = htons(port);
183 break;
184 case AF_INET6:
185 ((struct sockaddr_in6 *)sap)->sin6_port = htons(port);
186 break;
187 }
188}
189
190#define IPV6_SCOPE_DELIMITER '%'
191#define IPV6_SCOPE_ID_LEN sizeof("%nnnnnnnnnn")
192
193static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
194 const struct sockaddr *sap2)
195{
196 const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1;
197 const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2;
198
199 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
200}
201
202static inline bool __rpc_copy_addr4(struct sockaddr *dst,
203 const struct sockaddr *src)
204{
205 const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
206 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
207
208 dsin->sin_family = ssin->sin_family;
209 dsin->sin_addr.s_addr = ssin->sin_addr.s_addr;
210 return true;
211}
212
213#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
214static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
215 const struct sockaddr *sap2)
216{
217 const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
218 const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
219 return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
220}
221
222static inline bool __rpc_copy_addr6(struct sockaddr *dst,
223 const struct sockaddr *src)
224{
225 const struct sockaddr_in6 *ssin6 = (const struct sockaddr_in6 *) src;
226 struct sockaddr_in6 *dsin6 = (struct sockaddr_in6 *) dst;
227
228 dsin6->sin6_family = ssin6->sin6_family;
229 ipv6_addr_copy(&dsin6->sin6_addr, &ssin6->sin6_addr);
230 return true;
231}
232#else /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */
233static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
234 const struct sockaddr *sap2)
235{
236 return false;
237}
238
239static inline bool __rpc_copy_addr6(struct sockaddr *dst,
240 const struct sockaddr *src)
241{
242 return false;
243}
244#endif /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */
245
246/**
247 * rpc_cmp_addr - compare the address portion of two sockaddrs.
248 * @sap1: first sockaddr
249 * @sap2: second sockaddr
250 *
251 * Just compares the family and address portion. Ignores port, scope, etc.
252 * Returns true if the addrs are equal, false if they aren't.
253 */
254static inline bool rpc_cmp_addr(const struct sockaddr *sap1,
255 const struct sockaddr *sap2)
256{
257 if (sap1->sa_family == sap2->sa_family) {
258 switch (sap1->sa_family) {
259 case AF_INET:
260 return __rpc_cmp_addr4(sap1, sap2);
261 case AF_INET6:
262 return __rpc_cmp_addr6(sap1, sap2);
263 }
264 }
265 return false;
266}
267
268/**
269 * rpc_copy_addr - copy the address portion of one sockaddr to another
270 * @dst: destination sockaddr
271 * @src: source sockaddr
272 *
273 * Just copies the address portion and family. Ignores port, scope, etc.
274 * Caller is responsible for making certain that dst is large enough to hold
275 * the address in src. Returns true if address family is supported. Returns
276 * false otherwise.
277 */
278static inline bool rpc_copy_addr(struct sockaddr *dst,
279 const struct sockaddr *src)
280{
281 switch (src->sa_family) {
282 case AF_INET:
283 return __rpc_copy_addr4(dst, src);
284 case AF_INET6:
285 return __rpc_copy_addr6(dst, src);
286 }
287 return false;
288}
289
290/**
291 * rpc_get_scope_id - return scopeid for a given sockaddr
292 * @sa: sockaddr to get scopeid from
293 *
294 * Returns the value of the sin6_scope_id for AF_INET6 addrs, or 0 if
295 * not an AF_INET6 address.
296 */
297static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
298{
299 if (sa->sa_family != AF_INET6)
300 return 0;
301
302 return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
303}
304
154#endif /* __KERNEL__ */ 305#endif /* __KERNEL__ */
155#endif /* _LINUX_SUNRPC_CLNT_H */ 306#endif /* _LINUX_SUNRPC_CLNT_H */