From owner-freebsd-net Wed Jan 15 14:24:15 2003 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4D26637B405 for ; Wed, 15 Jan 2003 14:24:13 -0800 (PST) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 88D1843EB2 for ; Wed, 15 Jan 2003 14:24:11 -0800 (PST) (envelope-from tmoestl@gmx.net) Received: (qmail 21410 invoked by uid 0); 15 Jan 2003 22:24:10 -0000 Received: from p508e7cf6.dip.t-dialin.net (HELO galatea.local) (80.142.124.246) by mail.gmx.net (mp020-rz3) with SMTP; 15 Jan 2003 22:24:10 -0000 Received: from localhost ([127.0.0.1] helo=galatea.local) by galatea.local with esmtp (Exim 4.12 #1) id 18Yvys-0000P5-00; Wed, 15 Jan 2003 23:25:54 +0100 Received: (from tmm@localhost) by galatea.local (8.12.6/8.12.6/Submit) id h0FMPm0c001554; Wed, 15 Jan 2003 23:25:48 +0100 (CET) Date: Wed, 15 Jan 2003 23:25:48 +0100 From: Thomas Moestl To: Bruce Evans Cc: Martin Blapp , current@FreeBSD.ORG, net@FreeBSD.ORG Subject: Re: PANIC in tcp_syncache.c sonewconn() line 562 Message-ID: <20030115222548.GC286@crow.dom2ip.de> Mail-Followup-To: Bruce Evans , Martin Blapp , current@FreeBSD.ORG, net@FreeBSD.ORG References: <20030114100620.W76016@levais.imp.ch> <20030115020320.L17332-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030115020320.L17332-100000@gamplex.bde.org> User-Agent: Mutt/1.4i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Wed, 2003/01/15 at 02:20:12 +1100, Bruce Evans wrote: > On Tue, 14 Jan 2003, Martin Blapp wrote: > > > > > Hi Thomas, > > > > > s = splnet(); > > > + if (so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING)) { > > > + splx(s); > > > + return (EINVAL); > > > + } > > > error = (*so->so_proto->pr_usrreqs->pru_listen)(so, td); > > > if (error) { > > > splx(s); > > > > > > > Can you commit this ? The fix looks appropriate, but the manpage should > > also be changed to reflect the change. > > > > ERRORS > > Listen() will fail if: > > > > [EBADF] The argument s is not a valid descriptor. > > [ENOTSOCK] The argument s is not a socket. > > [EOPNOTSUPP] The socket is not of a type that > > supports the operation listen(). > > [EINVAL] Listen() has been already called on the socket. > > > > Any objections from others ? > > EINVAL is a bogus errno for this, but is standard. POSIX has better > wording: "The socket is already connected". The patch also returns > EINVAL if the socket is being connected. Is this right? (Maybe we > should wait until we can tell if it is connected.) Yes, I think so; calling listen() for SS_ISCONNECTING sockets can also lead to bogus states, although that could of course be avoided in another way. For applications, however, it does not matter much, since sockets can never be safely assumed to be in SS_ISCONNECTING (they can always change to SS_ISCONNECTED or time out behind the application's back). > POSIX also specifies the errors EDESTADDRREQ, EACCES, another EINVAL for > shut down sockets, and ENOBUFS. The last 3 "may" cause listen() to fail > and the others (including the first EINVAL) "shall" cause it to fail. EDESTADDRREQ seems to not be generated, instead e.g. tcp_usr_listen() always chooses a local address (which does not really make much sense, but changing it might break old applications I guess). ENOBUFS does not seem to occur. Shut down sockets seem to not be handled specially. - Thomas -- Thomas Moestl http://www.tu-bs.de/~y0015675/ http://people.FreeBSD.org/~tmm/ PGP fingerprint: 1C97 A604 2BD0 E492 51D0 9C0F 1FE6 4F1D 419C 776C To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message