Re: NFS over IPv6

From: Alfred Perlstein <alfred_at_freebsd.org>
Date: Sun, 11 Jul 2004 21:16:24 -0700
* Jun Kuriyama <kuriyama_at_imgsrc.co.jp> [040711 21:02] wrote:
> At Sun, 11 Jul 2004 20:48:47 -0700,
> Alfred Perlstein wrote:
> > I'm going to make a patch to set the SO_REUSEADDR and SO_REUSEPORT
> > on the sockets.
> > 
> > I'm also going to bump the timeout from 5 to 12 seconds.
> 
> Thanks!  I can test on my box when you make a patch.
> 
> > If there is a timeout, NFS will rebind the socket.  In theory this should
> > be ok as NFS is stateless.  Perhaps there is some IPv6 thing that makes
> > rebound sockets not work right?
> > 
> > Is there a reason why that might be the case?
> 
> I'm not sure there is a timeout in this case.
> 
> When I'm in this situation, NFS client seems to continue retrying
> every 1 second.  Port number in "udp port 973 unreachable" is
> decremented in every retry sequence.

Can you explain more?  Can you try this patch also:


Index: kern/uipc_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.201
diff -u -r1.201 uipc_socket.c
--- kern/uipc_socket.c	11 Jul 2004 23:13:14 -0000	1.201
+++ kern/uipc_socket.c	12 Jul 2004 04:06:19 -0000
_at__at_ -1541,6 +1541,25 _at__at_
 	return 0;
 }
 
+/*
+ * Kernel version of setsockopt(2)/
+ * XXX: optlen is size_t, not socklen_t
+ */
+int
+kern_setsockopt(struct socket *so, int level, int optname, void *optval,
+    size_t optlen)
+{
+	struct sockopt sopt;
+
+	sopt.sopt_level = level;
+	sopt.sopt_name = optname;
+	sopt.sopt_dir = SOPT_SET;
+	sopt.sopt_val = optval;
+	sopt.sopt_valsize = optlen;
+	sopt.sopt_td = NULL;
+	return (sosetopt(so, &sopt));
+}
+
 int
 sosetopt(so, sopt)
 	struct socket *so;
Index: nfsclient/nfs_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/nfsclient/nfs_socket.c,v
retrieving revision 1.111
diff -u -r1.111 nfs_socket.c
--- nfsclient/nfs_socket.c	6 Jul 2004 16:55:41 -0000	1.111
+++ nfsclient/nfs_socket.c	12 Jul 2004 04:16:36 -0000
_at__at_ -157,7 +157,7 _at__at_
 {
 	struct socket *so;
 	int error, rcvreserve, sndreserve;
-	int pktscale;
+	int opt, pktscale;
 	struct sockaddr *saddr;
 	struct thread *td = &thread0; /* only used for socreate and sobind */
 
_at__at_ -172,6 +172,10 _at__at_
 	so = nmp->nm_so;
 	nmp->nm_soflags = so->so_proto->pr_flags;
 
+	opt = 1;
+	(void)kern_setsockopt(so, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+	(void)kern_setsockopt(so, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt));
+
 	/*
 	 * Some servers require that the client port be a reserved port number.
 	 */
_at__at_ -261,7 +265,7 _at__at_
 		}
 		SOCK_UNLOCK(so);
 	}
-	so->so_rcv.sb_timeo = 5 * hz;
+	so->so_rcv.sb_timeo = 12 * hz;
 	so->so_snd.sb_timeo = 5 * hz;
 
 	/*
Index: nfsserver/nfs_srvsock.c
===================================================================
RCS file: /home/ncvs/src/sys/nfsserver/nfs_srvsock.c,v
retrieving revision 1.90
diff -u -r1.90 nfs_srvsock.c
--- nfsserver/nfs_srvsock.c	24 May 2004 04:06:14 -0000	1.90
+++ nfsserver/nfs_srvsock.c	11 Jul 2004 18:05:30 -0000
_at__at_ -433,16 +433,18 _at__at_
 	/* XXXRW: Unlocked read. */
 	if ((slp->ns_flag & SLP_VALID) == 0)
 		return;
-#ifdef notdef
+
 	/*
-	 * Define this to test for nfsds handling this under heavy load.
+	 * We can't do this in the context of a socket callback
+	 * because we're called with locks held.
+	 * XXX: SMP
 	 */
 	if (waitflag == M_DONTWAIT) {
 		NFSD_LOCK();
 		slp->ns_flag |= SLP_NEEDQ;
 		goto dorecs;
 	}
-#endif
+
 
 	NFSD_LOCK();
 	auio.uio_td = NULL;
Index: sys/socketvar.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/socketvar.h,v
retrieving revision 1.131
diff -u -r1.131 socketvar.h
--- sys/socketvar.h	27 Jun 2004 03:23:09 -0000	1.131
+++ sys/socketvar.h	12 Jul 2004 04:05:34 -0000
_at__at_ -438,6 +438,8 _at__at_
 /*
  * From uipc_socket and friends
  */
+int	kern_setsockopt(struct socket *so, int level, int optname,
+    void *optval, size_t optlen);
 int	sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
 int	getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
 void	sbappend(struct sockbuf *sb, struct mbuf *m);
Received on Mon Jul 12 2004 - 02:16:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:01 UTC