aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMi Jinlong <mijinlong@cn.fujitsu.com>2011-08-30 05:18:41 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-09-14 08:21:48 -0400
commit849a1cf13d4394d398d91752166e92e9ecd64f8d (patch)
tree475c08721cb327b924035144f771dd2d85eda0cd /fs
parent11fcee0293a6d9f0973e04f8b3fb6cd15a55bcce (diff)
SUNRPC: Replace svc_addr_u by sockaddr_storage
For IPv6 local address, lockd can not callback to client for missing scope id when binding address at inet6_bind: 324 if (addr_type & IPV6_ADDR_LINKLOCAL) { 325 if (addr_len >= sizeof(struct sockaddr_in6) && 326 addr->sin6_scope_id) { 327 /* Override any existing binding, if another one 328 * is supplied by user. 329 */ 330 sk->sk_bound_dev_if = addr->sin6_scope_id; 331 } 332 333 /* Binding to link-local address requires an interface */ 334 if (!sk->sk_bound_dev_if) { 335 err = -EINVAL; 336 goto out_unlock; 337 } Replacing svc_addr_u by sockaddr_storage, let rqstp->rq_daddr contains more info besides address. Reviewed-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/host.c25
-rw-r--r--fs/nfsd/nfs4state.c16
2 files changed, 3 insertions, 38 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;