From patchwork Sat Aug 20 10:24:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mi Jinlong X-Patchwork-Id: 1082562 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7KAKVaE026628 for ; Sat, 20 Aug 2011 10:20:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752616Ab1HTKU0 (ORCPT ); Sat, 20 Aug 2011 06:20:26 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:60306 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751761Ab1HTKU0 (ORCPT ); Sat, 20 Aug 2011 06:20:26 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 98D8F170044; Sat, 20 Aug 2011 18:20:22 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p7KAKMdd008486; Sat, 20 Aug 2011 18:20:22 +0800 Received: from [127.0.0.1] ([10.167.225.24]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011082018191013-63602 ; Sat, 20 Aug 2011 18:19:10 +0800 Message-ID: <4E4F8B5D.6060404@cn.fujitsu.com> Date: Sat, 20 Aug 2011 18:24:29 +0800 From: Mi Jinlong User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: NFS CC: "J. Bruce Fields" , Trond Myklebust , Chuck Lever Subject: [PATCH] sunrpc: Add scope id to svc_addr_u for IPv6 LINKLOCAL address X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-20 18:19:10, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-20 18:19:10, Serialize complete at 2011-08-20 18:19:10 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 20 Aug 2011 10:20:31 +0000 (UTC) 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 } This patch adds scope id to svc_addr_u for IPv6 address, and copy scope from xprt->xpt_local to rqstp->rq_daddr for use. With this patch, lockd can callback to client success. Signed-off-by: Mi Jinlong --- fs/lockd/host.c | 3 ++- fs/nfsd/nfs4state.c | 7 ++++++- include/linux/sunrpc/svc.h | 12 ++++++++++-- net/sunrpc/svc_xprt.c | 5 ++++- net/sunrpc/svcsock.c | 4 ++-- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/fs/lockd/host.c b/fs/lockd/host.c index b7c99bf..1fff87a 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -346,7 +346,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, src_sap = (struct sockaddr *)&sin; break; case AF_INET6: - ipv6_addr_copy(&sin6.sin6_addr, &rqstp->rq_daddr.addr6); + ipv6_addr_copy(&sin6.sin6_addr, &rqstp->rq_daddr.addr6.sin6_addr); + sin6.sin6_scope_id = rqstp->rq_daddr.addr6.sin6_scope_id; src_sap = (struct sockaddr *)&sin6; break; default: diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3787ec1..1169411 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1182,7 +1182,7 @@ static void rpc_svcaddr2sockaddr(struct sockaddr *sa, unsigned short family, uni return; case AF_INET6: ((struct sockaddr_in6 *)sa)->sin6_family = AF_INET6; - ((struct sockaddr_in6 *)sa)->sin6_addr = svcaddr->addr6; + ((struct sockaddr_in6 *)sa)->sin6_addr = svcaddr->addr6.sin6_addr; return; } } @@ -1219,6 +1219,11 @@ gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, struct svc_r conn->cb_prog = se->se_callback_prog; conn->cb_ident = se->se_callback_ident; rpc_svcaddr2sockaddr((struct sockaddr *)&conn->cb_saddr, expected_family, &rqstp->rq_daddr); + + if (conn->cb_saddr.ss_family == AF_INET6) + ((struct sockaddr_in6 *)&conn->cb_saddr)->sin6_scope_id = + rqstp->rq_daddr.addr6.sin6_scope_id; + return; out_err: conn->cb_addr.ss_family = AF_UNSPEC; diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 223588a..cd611b5 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -212,9 +212,17 @@ static inline void svc_putu32(struct kvec *iov, __be32 val) iov->iov_len += sizeof(__be32); } +/* + * Add scope id for LINKLOCAL address + */ +struct in6_addr_scopeid{ + struct in6_addr sin6_addr; + __u32 sin6_scope_id; +}; + union svc_addr_u { - struct in_addr addr; - struct in6_addr addr6; + struct in_addr addr; + struct in6_addr_scopeid addr6; }; /* diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index bd31208..8aada49 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -269,7 +269,10 @@ void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt) rqstp->rq_daddr.addr = ((struct sockaddr_in *)sin)->sin_addr; break; case AF_INET6: - rqstp->rq_daddr.addr6 = ((struct sockaddr_in6 *)sin)->sin6_addr; + rqstp->rq_daddr.addr6.sin6_addr = + ((struct sockaddr_in6 *)sin)->sin6_addr; + rqstp->rq_daddr.addr6.sin6_scope_id = + ((struct sockaddr_in6 *)sin)->sin6_scope_id; break; } } diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 767d494..beb2575 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -155,7 +155,7 @@ static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh) cmh->cmsg_type = IPV6_PKTINFO; pki->ipi6_ifindex = 0; ipv6_addr_copy(&pki->ipi6_addr, - &rqstp->rq_daddr.addr6); + &rqstp->rq_daddr.addr6.sin6_addr); cmh->cmsg_len = CMSG_LEN(sizeof(*pki)); } break; @@ -513,7 +513,7 @@ static int svc_udp_get_dest_address6(struct svc_rqst *rqstp, struct in6_pktinfo *pki = CMSG_DATA(cmh); if (cmh->cmsg_type != IPV6_PKTINFO) return 0; - ipv6_addr_copy(&rqstp->rq_daddr.addr6, &pki->ipi6_addr); + ipv6_addr_copy(&rqstp->rq_daddr.addr6.sin6_addr, &pki->ipi6_addr); return 1; }