Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 Mar 2003 07:52:29 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Maksim Yevmenkin <myevmenk@exodus.net>, current@FreeBSD.ORG, wollman@FreeBSD.ORG
Subject:   Re: PATCH: typo in socreate() or i'm missing something
Message-ID:  <3E60D73D.33D2CED2@mindspring.com>
References:  <20030301202521.D25845-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans wrote:
> On Fri, 28 Feb 2003, Maksim Yevmenkin wrote:
> > sonewconn() calls soalloc(0).
> 
> tcp_input() is a critical caller of sonewconn() and it obviously shouldn't
> sleep.  But sonewconn() is called from process context elsewhere.
> sonewconn() has used a no-wait malloc() since at least 4.4Lite2 (in Lite2
> there is no soalloc() and the malloc() is done directly in sonewconn()).
> I think the call from tcp_input() is the usual case and/or no one cared
> to distinguish the other cases.

The interesting case in the tcp_input() path is an outstanding
"accept" call, in which a new connection is created at interrupt
(in LRP) o NETISR (in traditional, livelockable FreeBSD).

In general, the blocking is done in order to get a process (or
now thread, I guess) context from which to obtain a cred for the
newly created socket.

I've discussed my own approach to this problem with both Jeffrey
Hsu and Jonathan Lemon, and I think it's pretty clever: don't get
the credential from the process (thread).

So how do you get the same/right credential?

Easy.  You cannot accept except on an outstanding listen socket;
so copy the cred from the listening socket, which *is* in scope,
even if p == 0 (or td == 0).

I believe that addresses the problem case... 8-).

-- Terry

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?3E60D73D.33D2CED2>