linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: bfields@fieldses.org, steved@redhat.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 06/17] SUNRPC: Set IPV6ONLY flag on PF_INET6 RPC listenersockets
Date: Tue, 31 Mar 2009 08:19:20 -0400	[thread overview]
Message-ID: <1238501960.31172.1.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <1238452665.23512.13.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>

On Mon, 2009-03-30 at 18:37 -0400, Trond Myklebust wrote:
> I'm testing a fix right now...

Here is the patch that was tested. With it applied, I see the listeners
come up correctly, and locking appears to work as expected.

Cheers
  Trond

--------------------------------------------------------------------
>From e13a5357ab5961844e64ec4ade6e4e13bfc33355 Mon Sep 17 00:00:00 2001
From: Trond Myklebust <Trond.Myklebust@netapp.com>
Date: Mon, 30 Mar 2009 18:59:17 -0400
Subject: [PATCH] SUNRPC: Ensure IPV6_V6ONLY is set on the socket before binding to a port

Also ensure that we use the protocol family instead of the address
family when calling sock_create_kern().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 net/sunrpc/svcsock.c |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index ac6cd65..9d50423 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1110,7 +1110,6 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
 	struct svc_sock	*svsk;
 	struct sock	*inet;
 	int		pmap_register = !(flags & SVC_SOCK_ANONYMOUS);
-	int		val;
 
 	dprintk("svc: svc_setup_socket %p\n", sock);
 	if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {
@@ -1143,16 +1142,6 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
 	else
 		svc_tcp_init(svsk, serv);
 
-	/*
-	 * If this is a PF_INET6 listener, we want to avoid
-	 * getting requests from IPv4 remotes.  Those should
-	 * be shunted to a PF_INET listener via rpcbind.
-	 */
-	val = 1;
-	if (inet->sk_family == PF_INET6)
-		kernel_setsockopt(sock, SOL_IPV6, IPV6_V6ONLY,
-					(char *)&val, sizeof(val));
-
 	dprintk("svc: svc_setup_socket created %p (inet %p)\n",
 				svsk, svsk->sk_sk);
 
@@ -1220,6 +1209,8 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
 	struct sockaddr_storage addr;
 	struct sockaddr *newsin = (struct sockaddr *)&addr;
 	int		newlen;
+	int		family;
+	int		val;
 	RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
 
 	dprintk("svc: svc_create_socket(%s, %d, %s)\n",
@@ -1231,14 +1222,35 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
 				"sockets supported\n");
 		return ERR_PTR(-EINVAL);
 	}
+
 	type = (protocol == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM;
+	switch (sin->sa_family) {
+	case AF_INET6:
+		family = PF_INET6;
+		break;
+	case AF_INET:
+		family = PF_INET;
+		break;
+	default:
+		return ERR_PTR(-EINVAL);
+	}
 
-	error = sock_create_kern(sin->sa_family, type, protocol, &sock);
+	error = sock_create_kern(family, type, protocol, &sock);
 	if (error < 0)
 		return ERR_PTR(error);
 
 	svc_reclassify_socket(sock);
 
+	/*
+	 * If this is an PF_INET6 listener, we want to avoid
+	 * getting requests from IPv4 remotes.  Those should
+	 * be shunted to a PF_INET listener via rpcbind.
+	 */
+	val = 1;
+	if (family == PF_INET6)
+		kernel_setsockopt(sock, SOL_IPV6, IPV6_V6ONLY,
+					(char *)&val, sizeof(val));
+
 	if (type == SOCK_STREAM)
 		sock->sk->sk_reuse = 1;		/* allow address reuse */
 	error = kernel_bind(sock, sin, len);
-- 
1.6.0.4



-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com

  parent reply	other threads:[~2009-03-31 12:20 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 22:32 [PATCH 00/17] Proposed fix for blacklisted ipv6.ko Chuck Lever
     [not found] ` <20090303220539.2933.15015.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-03 22:32   ` [PATCH 01/17] SUNRPC: Pass a family argument to svc_register() Chuck Lever
2009-03-03 22:32   ` [PATCH 02/17] SUNRPC: svc_setup_socket() gets protocol family from socket Chuck Lever
2009-03-03 22:32   ` [PATCH 03/17] SUNRPC: Change svc_create_xprt() to take a @family argument Chuck Lever
2009-03-03 22:32   ` [PATCH 04/17] SUNRPC: Remove @family argument from svc_create() and svc_create_pooled() Chuck Lever
2009-03-03 22:32   ` [PATCH 05/17] NFS: Revert creation of IPv6 listeners for lockd and NFSv4 callbacks Chuck Lever
2009-03-03 22:32   ` [PATCH 06/17] SUNRPC: Set IPV6ONLY flag on PF_INET6 RPC listener sockets Chuck Lever
     [not found]     ` <20090303223254.2933.70364.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-30 22:17       ` [PATCH 06/17] SUNRPC: Set IPV6ONLY flag on PF_INET6 RPC listenersockets Trond Myklebust
     [not found]         ` <1238451467.23512.11.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-30 22:28           ` Chuck Lever
2009-03-30 22:37             ` Trond Myklebust
     [not found]               ` <1238452665.23512.13.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-30 22:45                 ` Chuck Lever
2009-03-31 12:19                 ` Trond Myklebust [this message]
     [not found]                   ` <1238501960.31172.1.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-31 15:32                     ` Chuck Lever
2009-03-03 22:33   ` [PATCH 07/17] SUNRPC: Use IPv4 loopback for registering AF_INET6 kernel RPC services Chuck Lever
2009-03-03 22:33   ` [PATCH 08/17] SUNRPC: Don't return EPROTONOSUPPORT in svc_register()'s helpers Chuck Lever
     [not found]     ` <20090303223309.2933.51773.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-11 18:32       ` J. Bruce Fields
2009-03-03 22:33   ` [PATCH 09/17] SUNRPC: Clean up address type casts in rpcb_v4_register() Chuck Lever
2009-03-03 22:33   ` [PATCH 10/17] SUNRPC: Use "0" as r_owner Chuck Lever
     [not found]     ` <20090303223324.2933.57002.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-11 19:06       ` J. Bruce Fields
2009-03-11 19:57         ` Chuck Lever
2009-03-11 20:09           ` J. Bruce Fields
2009-03-11 20:18             ` Chuck Lever
2009-03-03 22:33   ` [PATCH 11/17] SUNRPC: Allow callers to pass rpcb_v4_register a NULL address Chuck Lever
2009-03-03 22:33   ` [PATCH 12/17] SUNRPC: Simplify svc_unregister() Chuck Lever
2009-03-03 22:33   ` [PATCH 13/17] SUNRPC: Simplify kernel RPC service registration Chuck Lever
2009-03-03 22:33   ` [PATCH 14/17] SUNRPC: rpcb_register() should handle errors silently Chuck Lever
2009-03-03 22:34   ` [PATCH 15/17] SUNRPC: Remove CONFIG_SUNRPC_REGISTER_V4 Chuck Lever
2009-03-03 22:34   ` [PATCH 16/17] lockd: Start PF_INET6 listener only if IPv6 support is available Chuck Lever
     [not found]     ` <20090303223410.2933.90223.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-30 22:06       ` [PATCH 16/17] lockd: Start PF_INET6 listener only if IPv6 support isavailable Trond Myklebust
2009-03-03 22:34   ` [PATCH 17/17] NFS: Start PF_INET6 callback listener only if IPv6 support is available Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1238501960.31172.1.camel@heimdal.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).