From owner-freebsd-stable@FreeBSD.ORG Wed Mar 1 14:42:29 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3254616A420 for ; Wed, 1 Mar 2006 14:42:29 +0000 (GMT) (envelope-from rosti.bsd@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id 718A343D49 for ; Wed, 1 Mar 2006 14:42:27 +0000 (GMT) (envelope-from rosti.bsd@gmail.com) Received: by wproxy.gmail.com with SMTP id 50so147856wri for ; Wed, 01 Mar 2006 06:42:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type:content-transfer-encoding; b=PnbdPDdpKm6/H5M/4zmtpbUY8bBu+zAAP+ez5lJjoEurGmRo2JTSKCeq0C8oObShzMu/AgviHtXqSePtq4tF3/NYoCkErU1NLI0Sx4vp1T/2qs0skSRbHpRvyVFc2bR+3xkLhrRoZQwNe5kRii8uKHmSRtdEYShp3WGnqEpzvh4= Received: by 10.65.53.20 with SMTP id f20mr107577qbk; Wed, 01 Mar 2006 06:42:26 -0800 (PST) Received: from saturn.lan ( [212.143.154.227]) by mx.gmail.com with ESMTP id f16sm345449qba.2006.03.01.06.42.21; Wed, 01 Mar 2006 06:42:26 -0800 (PST) Date: Wed, 1 Mar 2006 16:42:18 +0200 From: Rostislav Krasny To: Yar Tikhiy 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> <20060223235727.33cddb13.rosti.bsd@gmail.com> <20060224155153.f7da1a52.rosti.bsd@gmail.com> <20060224174007.GF36227@comp.chem.msu.su> <20060225024246.d6284719.rosti.bsd@gmail.com> <20060301124513.GI63713@comp.chem.msu.su> X-Mailer: Sylpheed version 2.2.0 (GTK+ 2.8.12; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Mar 2006 14:42:29 -0000 On Wed, 1 Mar 2006 15:45:13 +0300 Yar Tikhiy 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 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.