From owner-freebsd-current@FreeBSD.ORG Mon Jul 12 04:16:25 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C49A16A4CE; Mon, 12 Jul 2004 04:16:25 +0000 (GMT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id DF0EA43D2D; Mon, 12 Jul 2004 04:16:24 +0000 (GMT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id D7F935C89E; Sun, 11 Jul 2004 21:16:24 -0700 (PDT) Date: Sun, 11 Jul 2004 21:16:24 -0700 From: Alfred Perlstein To: Jun Kuriyama Message-ID: <20040712041624.GX95729@elvis.mu.org> References: <7mk6xey51w.wl@black3.imgsrc.co.jp> <7m8ydqvuaq.wl@black3.imgsrc.co.jp> <20040712034847.GV95729@elvis.mu.org> <7mzn65vpo2.wl@black3.imgsrc.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7mzn65vpo2.wl@black3.imgsrc.co.jp> User-Agent: Mutt/1.4.2.1i cc: Current cc: rwatson@FreeBSD.org Subject: Re: NFS over IPv6 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2004 04:16:25 -0000 * Jun Kuriyama [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 @@ -1541,6 +1541,25 @@ 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 @@ -157,7 +157,7 @@ { 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 */ @@ -172,6 +172,10 @@ 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. */ @@ -261,7 +265,7 @@ } 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 @@ -433,16 +433,18 @@ /* 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 @@ -438,6 +438,8 @@ /* * 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);