Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Mar 2006 16:42:18 +0200
From:      Rostislav Krasny <rosti.bsd@gmail.com>
To:        Yar Tikhiy <yar@comp.chem.msu.su>
Cc:        freebsd-stable@freebsd.org, dwmalone@maths.tcd.ie, des@des.no, mak@ll.mit.edu, MH@kernel32.de, freebsd-stable-local@be-well.ilk.org
Subject:   Re: SSH login takes very long time...sometimes
Message-ID:  <20060301164218.8459fbcf.rosti.bsd@gmail.com>
In-Reply-To: <20060301124513.GI63713@comp.chem.msu.su>
References:  <20060221165959.GB77513@comp.chem.msu.su> <20060222024430.ad4b5c60.rosti.bsd@gmail.com> <yge1wxvz5ha.wl%ume@mahoroba.org> <20060223235727.33cddb13.rosti.bsd@gmail.com> <ygefym98o7i.wl%ume@mahoroba.org> <20060224155153.f7da1a52.rosti.bsd@gmail.com> <ygewtfkelbu.wl%ume@mahoroba.org> <20060224174007.GF36227@comp.chem.msu.su> <20060225024246.d6284719.rosti.bsd@gmail.com> <ygeslq7ew25.wl%ume@mahoroba.org> <20060301124513.GI63713@comp.chem.msu.su>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 1 Mar 2006 15:45:13 +0300
Yar Tikhiy <yar@comp.chem.msu.su> wrote:

> On Sat, Feb 25, 2006 at 04:28:50PM +0900, Hajimu UMEMOTO wrote:
> > >>>>> On Sat, 25 Feb 2006 02:42:46 +0200
> > >>>>> Rostislav Krasny <rosti.bsd@gmail.com> said:
> > 
> > rosti> I've found the problem in both: ftpd(8) and ftp(1). In the ftpd(8) a
> > rosti> getaddrinfo() is called in two places with hints.ai_socktype == 0 and
> > rosti> hints.ai_family == PF_UNSPEC. In the ftp(1) a command reply timeout is
> > rosti> only 60 seconds. Those things are what I've changed to fix the problem.
> > rosti> Two diffs are attached to this email. The ftpd.c.diff extends -4 and -6
> > rosti> ftpd options. So if this patch is good, the ftpd(8) manual page and the
> > rosti> default /etc/inetd.conf should also be changed appropriately.
> > 
> > For your ftpd.c.diff, I like your idea to reduce redundant query.  It
> > is enough to query just appropriate address family.  In inetd mode, we
> > know the address family already.  So, we don't need to rely on the
> > -4/-6 option.  The following diff is against ftpd.c with your patch
> > applied:
> 
> I finally tried the proposed patches for ftpd and really liked the
> idea of reducing the name queries made to only one address family
> if it's known.  Thank you both!
> 
> I've got only one small remark on style, see below.
> 
> > --- ftpd.c.rosti	Sat Feb 25 15:41:52 2006
> > +++ ftpd.c	Sat Feb 25 16:01:46 2006
> > @@ -423,10 +423,6 @@ main(int argc, char *argv[], char **envp
> >  		}
> >  	}
> >  
> > -#ifdef VIRTUAL_HOSTING
> > -	inithosts(family);
> > -#endif
> > -
> >  	if (daemon_mode) {
> >  		int *ctl_sock, fd, maxfd = -1, nfds, i;
> >  		fd_set defreadfds, readfds;
> > @@ -456,6 +452,10 @@ main(int argc, char *argv[], char **envp
> >  		sa.sa_handler = reapchild;
> >  		(void)sigaction(SIGCHLD, &sa, NULL);
> >  
> > +#ifdef VIRTUAL_HOSTING
> > +		inithosts(family);
> > +#endif
> > +
> >  		/*
> >  		 * Open a socket, bind it to the FTP port, and start
> >  		 * listening.
> > @@ -525,6 +525,14 @@ main(int argc, char *argv[], char **envp
> >  			syslog(LOG_ERR, "getpeername (%s): %m",argv[0]);
> >  			exit(1);
> >  		}
> > +
> > +#ifdef VIRTUAL_HOSTING
> > +		family = his_addr.su_family;
> > +		if (his_addr.su_family == AF_INET6 &&
> > +		    IN6_IS_ADDR_V4MAPPED(&his_addr.su_sin6.sin6_addr))
> > +			family = AF_INET;
> 
> Perheps a better style here would be to use if/else:
> 
> 	if (his_addr.su_family == AF_INET6 &&
> 	    IN6_IS_ADDR_V4MAPPED(&his_addr.su_sin6.sin6_addr))
> 		family = AF_INET;
> 	else
> 		family = his_addr.su_family;
> 
> > +		inithosts(family);

Or even shorter:

 	if (his_addr.su_family == AF_INET6 &&
 	    IN6_IS_ADDR_V4MAPPED(&his_addr.su_sin6.sin6_addr))
 		inithosts(AF_INET);
 	else
 		inithosts(his_addr.su_family);

The 'family' variable isn't used in the inetd mode.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060301164218.8459fbcf.rosti.bsd>