Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jan 2003 23:25:48 +0100
From:      Thomas Moestl <tmoestl@gmx.net>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Martin Blapp <mb@imp.ch>, current@FreeBSD.ORG, net@FreeBSD.ORG
Subject:   Re: PANIC in tcp_syncache.c sonewconn() line 562
Message-ID:  <20030115222548.GC286@crow.dom2ip.de>
In-Reply-To: <20030115020320.L17332-100000@gamplex.bde.org>
References:  <20030114100620.W76016@levais.imp.ch> <20030115020320.L17332-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <tmoestl@gmx.net>	http://www.tu-bs.de/~y0015675/
              <tmm@FreeBSD.org>	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-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030115222548.GC286>