aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/lockd/host.c25
-rw-r--r--fs/nfsd/nfs4state.c16
-rw-r--r--include/linux/sunrpc/svc.h30
-rw-r--r--net/sunrpc/svc_xprt.c13
-rw-r--r--net/sunrpc/svcsock.c23
5 files changed, 43 insertions, 64 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index b7c99bfb3da6..6f29836ec0cb 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -316,14 +316,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
316 struct hlist_node *pos; 316 struct hlist_node *pos;
317 struct nlm_host *host = NULL; 317 struct nlm_host *host = NULL;
318 struct nsm_handle *nsm = NULL; 318 struct nsm_handle *nsm = NULL;
319 struct sockaddr_in sin = { 319 struct sockaddr *src_sap = svc_daddr(rqstp);
320 .sin_family = AF_INET, 320 size_t src_len = rqstp->rq_daddrlen;
321 };
322 struct sockaddr_in6 sin6 = {
323 .sin6_family = AF_INET6,
324 };
325 struct sockaddr *src_sap;
326 size_t src_len = rqstp->rq_addrlen;
327 struct nlm_lookup_host_info ni = { 321 struct nlm_lookup_host_info ni = {
328 .server = 1, 322 .server = 1,
329 .sap = svc_addr(rqstp), 323 .sap = svc_addr(rqstp),
@@ -340,21 +334,6 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
340 334
341 mutex_lock(&nlm_host_mutex); 335 mutex_lock(&nlm_host_mutex);
342 336
343 switch (ni.sap->sa_family) {
344 case AF_INET:
345 sin.sin_addr.s_addr = rqstp->rq_daddr.addr.s_addr;
346 src_sap = (struct sockaddr *)&sin;
347 break;
348 case AF_INET6:
349 ipv6_addr_copy(&sin6.sin6_addr, &rqstp->rq_daddr.addr6);
350 src_sap = (struct sockaddr *)&sin6;
351 break;
352 default:
353 dprintk("lockd: %s failed; unrecognized address family\n",
354 __func__);
355 goto out;
356 }
357
358 if (time_after_eq(jiffies, next_gc)) 337 if (time_after_eq(jiffies, next_gc))
359 nlm_gc_hosts(); 338 nlm_gc_hosts();
360 339
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 0cd346477f29..e7f83bd9b4a8 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1257,20 +1257,6 @@ find_unconfirmed_client_by_str(const char *dname, unsigned int hashval)
1257 return NULL; 1257 return NULL;
1258} 1258}
1259 1259
1260static void rpc_svcaddr2sockaddr(struct sockaddr *sa, unsigned short family, union svc_addr_u *svcaddr)
1261{
1262 switch (family) {
1263 case AF_INET:
1264 ((struct sockaddr_in *)sa)->sin_family = AF_INET;
1265 ((struct sockaddr_in *)sa)->sin_addr = svcaddr->addr;
1266 return;
1267 case AF_INET6:
1268 ((struct sockaddr_in6 *)sa)->sin6_family = AF_INET6;
1269 ((struct sockaddr_in6 *)sa)->sin6_addr = svcaddr->addr6;
1270 return;
1271 }
1272}
1273
1274static void 1260static void
1275gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, struct svc_rqst *rqstp) 1261gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, struct svc_rqst *rqstp)
1276{ 1262{
@@ -1302,7 +1288,7 @@ gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, struct svc_r
1302 1288
1303 conn->cb_prog = se->se_callback_prog; 1289 conn->cb_prog = se->se_callback_prog;
1304 conn->cb_ident = se->se_callback_ident; 1290 conn->cb_ident = se->se_callback_ident;
1305 rpc_svcaddr2sockaddr((struct sockaddr *)&conn->cb_saddr, expected_family, &rqstp->rq_daddr); 1291 memcpy(&conn->cb_saddr, &rqstp->rq_daddr, rqstp->rq_daddrlen);
1306 return; 1292 return;
1307out_err: 1293out_err:
1308 conn->cb_addr.ss_family = AF_UNSPEC; 1294 conn->cb_addr.ss_family = AF_UNSPEC;
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index a78a51e93373..d8d5d93071b3 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -212,11 +212,6 @@ static inline void svc_putu32(struct kvec *iov, __be32 val)
212 iov->iov_len += sizeof(__be32); 212 iov->iov_len += sizeof(__be32);
213} 213}
214 214
215union svc_addr_u {
216 struct in_addr addr;
217 struct in6_addr addr6;
218};
219
220/* 215/*
221 * The context of a single thread, including the request currently being 216 * The context of a single thread, including the request currently being
222 * processed. 217 * processed.
@@ -225,8 +220,12 @@ struct svc_rqst {
225 struct list_head rq_list; /* idle list */ 220 struct list_head rq_list; /* idle list */
226 struct list_head rq_all; /* all threads list */ 221 struct list_head rq_all; /* all threads list */
227 struct svc_xprt * rq_xprt; /* transport ptr */ 222 struct svc_xprt * rq_xprt; /* transport ptr */
223
228 struct sockaddr_storage rq_addr; /* peer address */ 224 struct sockaddr_storage rq_addr; /* peer address */
229 size_t rq_addrlen; 225 size_t rq_addrlen;
226 struct sockaddr_storage rq_daddr; /* dest addr of request
227 * - reply from here */
228 size_t rq_daddrlen;
230 229
231 struct svc_serv * rq_server; /* RPC service definition */ 230 struct svc_serv * rq_server; /* RPC service definition */
232 struct svc_pool * rq_pool; /* thread pool */ 231 struct svc_pool * rq_pool; /* thread pool */
@@ -255,9 +254,6 @@ struct svc_rqst {
255 unsigned short 254 unsigned short
256 rq_secure : 1; /* secure port */ 255 rq_secure : 1; /* secure port */
257 256
258 union svc_addr_u rq_daddr; /* dest addr of request
259 * - reply from here */
260
261 void * rq_argp; /* decoded arguments */ 257 void * rq_argp; /* decoded arguments */
262 void * rq_resp; /* xdr'd results */ 258 void * rq_resp; /* xdr'd results */
263 void * rq_auth_data; /* flavor-specific data */ 259 void * rq_auth_data; /* flavor-specific data */
@@ -300,6 +296,21 @@ static inline struct sockaddr *svc_addr(const struct svc_rqst *rqst)
300 return (struct sockaddr *) &rqst->rq_addr; 296 return (struct sockaddr *) &rqst->rq_addr;
301} 297}
302 298
299static inline struct sockaddr_in *svc_daddr_in(const struct svc_rqst *rqst)
300{
301 return (struct sockaddr_in *) &rqst->rq_daddr;
302}
303
304static inline struct sockaddr_in6 *svc_daddr_in6(const struct svc_rqst *rqst)
305{
306 return (struct sockaddr_in6 *) &rqst->rq_daddr;
307}
308
309static inline struct sockaddr *svc_daddr(const struct svc_rqst *rqst)
310{
311 return (struct sockaddr *) &rqst->rq_daddr;
312}
313
303/* 314/*
304 * Check buffer bounds after decoding arguments 315 * Check buffer bounds after decoding arguments
305 */ 316 */
@@ -340,7 +351,8 @@ struct svc_deferred_req {
340 struct svc_xprt *xprt; 351 struct svc_xprt *xprt;
341 struct sockaddr_storage addr; /* where reply must go */ 352 struct sockaddr_storage addr; /* where reply must go */
342 size_t addrlen; 353 size_t addrlen;
343 union svc_addr_u daddr; /* where reply must come from */ 354 struct sockaddr_storage daddr; /* where reply must come from */
355 size_t daddrlen;
344 struct cache_deferred_req handle; 356 struct cache_deferred_req handle;
345 size_t xprt_hlen; 357 size_t xprt_hlen;
346 int argslen; 358 int argslen;
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index bd31208bbb61..d86bb673e1f6 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -254,8 +254,6 @@ EXPORT_SYMBOL_GPL(svc_create_xprt);
254 */ 254 */
255void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt) 255void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt)
256{ 256{
257 struct sockaddr *sin;
258
259 memcpy(&rqstp->rq_addr, &xprt->xpt_remote, xprt->xpt_remotelen); 257 memcpy(&rqstp->rq_addr, &xprt->xpt_remote, xprt->xpt_remotelen);
260 rqstp->rq_addrlen = xprt->xpt_remotelen; 258 rqstp->rq_addrlen = xprt->xpt_remotelen;
261 259
@@ -263,15 +261,8 @@ void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt)
263 * Destination address in request is needed for binding the 261 * Destination address in request is needed for binding the
264 * source address in RPC replies/callbacks later. 262 * source address in RPC replies/callbacks later.
265 */ 263 */
266 sin = (struct sockaddr *)&xprt->xpt_local; 264 memcpy(&rqstp->rq_daddr, &xprt->xpt_local, xprt->xpt_locallen);
267 switch (sin->sa_family) { 265 rqstp->rq_daddrlen = xprt->xpt_locallen;
268 case AF_INET:
269 rqstp->rq_daddr.addr = ((struct sockaddr_in *)sin)->sin_addr;
270 break;
271 case AF_INET6:
272 rqstp->rq_daddr.addr6 = ((struct sockaddr_in6 *)sin)->sin6_addr;
273 break;
274 }
275} 266}
276EXPORT_SYMBOL_GPL(svc_xprt_copy_addrs); 267EXPORT_SYMBOL_GPL(svc_xprt_copy_addrs);
277 268
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 767d494de7a2..dfd686eb0b7f 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -143,19 +143,20 @@ static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh)
143 cmh->cmsg_level = SOL_IP; 143 cmh->cmsg_level = SOL_IP;
144 cmh->cmsg_type = IP_PKTINFO; 144 cmh->cmsg_type = IP_PKTINFO;
145 pki->ipi_ifindex = 0; 145 pki->ipi_ifindex = 0;
146 pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr; 146 pki->ipi_spec_dst.s_addr =
147 svc_daddr_in(rqstp)->sin_addr.s_addr;
147 cmh->cmsg_len = CMSG_LEN(sizeof(*pki)); 148 cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
148 } 149 }
149 break; 150 break;
150 151
151 case AF_INET6: { 152 case AF_INET6: {
152 struct in6_pktinfo *pki = CMSG_DATA(cmh); 153 struct in6_pktinfo *pki = CMSG_DATA(cmh);
154 struct sockaddr_in6 *daddr = svc_daddr_in6(rqstp);
153 155
154 cmh->cmsg_level = SOL_IPV6; 156 cmh->cmsg_level = SOL_IPV6;
155 cmh->cmsg_type = IPV6_PKTINFO; 157 cmh->cmsg_type = IPV6_PKTINFO;
156 pki->ipi6_ifindex = 0; 158 pki->ipi6_ifindex = daddr->sin6_scope_id;
157 ipv6_addr_copy(&pki->ipi6_addr, 159 ipv6_addr_copy(&pki->ipi6_addr, &daddr->sin6_addr);
158 &rqstp->rq_daddr.addr6);
159 cmh->cmsg_len = CMSG_LEN(sizeof(*pki)); 160 cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
160 } 161 }
161 break; 162 break;
@@ -498,9 +499,13 @@ static int svc_udp_get_dest_address4(struct svc_rqst *rqstp,
498 struct cmsghdr *cmh) 499 struct cmsghdr *cmh)
499{ 500{
500 struct in_pktinfo *pki = CMSG_DATA(cmh); 501 struct in_pktinfo *pki = CMSG_DATA(cmh);
502 struct sockaddr_in *daddr = svc_daddr_in(rqstp);
503
501 if (cmh->cmsg_type != IP_PKTINFO) 504 if (cmh->cmsg_type != IP_PKTINFO)
502 return 0; 505 return 0;
503 rqstp->rq_daddr.addr.s_addr = pki->ipi_spec_dst.s_addr; 506
507 daddr->sin_family = AF_INET;
508 daddr->sin_addr.s_addr = pki->ipi_spec_dst.s_addr;
504 return 1; 509 return 1;
505} 510}
506 511
@@ -511,9 +516,14 @@ static int svc_udp_get_dest_address6(struct svc_rqst *rqstp,
511 struct cmsghdr *cmh) 516 struct cmsghdr *cmh)
512{ 517{
513 struct in6_pktinfo *pki = CMSG_DATA(cmh); 518 struct in6_pktinfo *pki = CMSG_DATA(cmh);
519 struct sockaddr_in6 *daddr = svc_daddr_in6(rqstp);
520
514 if (cmh->cmsg_type != IPV6_PKTINFO) 521 if (cmh->cmsg_type != IPV6_PKTINFO)
515 return 0; 522 return 0;
516 ipv6_addr_copy(&rqstp->rq_daddr.addr6, &pki->ipi6_addr); 523
524 daddr->sin6_family = AF_INET6;
525 ipv6_addr_copy(&daddr->sin6_addr, &pki->ipi6_addr);
526 daddr->sin6_scope_id = pki->ipi6_ifindex;
517 return 1; 527 return 1;
518} 528}
519 529
@@ -614,6 +624,7 @@ static int svc_udp_recvfrom(struct svc_rqst *rqstp)
614 skb_free_datagram_locked(svsk->sk_sk, skb); 624 skb_free_datagram_locked(svsk->sk_sk, skb);
615 return 0; 625 return 0;
616 } 626 }
627 rqstp->rq_daddrlen = svc_addr_len(svc_daddr(rqstp));
617 628
618 if (skb_is_nonlinear(skb)) { 629 if (skb_is_nonlinear(skb)) {
619 /* we have to copy */ 630 /* we have to copy */