Subject: Re: socreate()
To: Elad Efrat <elad@NetBSD.org>
From: David Young <email@example.com>
Date: 11/02/2006 00:33:39
On Wed, Oct 25, 2006 at 11:54:01PM +0200, Elad Efrat wrote:
> Jason Thorpe wrote:
> > On Oct 25, 2006, at 2:41 PM, Elad Efrat wrote:
> >> hi,
> >> can socreate() sleep? (I want to add a kauth(9) call in there to
> >> implement socket policies in one place)
> > s = splsoftnet();
> > so = pool_get(&socket_pool, PR_WAITOK);
> >> I *think* someone mentioned something about that in some thread in the
> >> past; looking at the code it seems that if_gre.c:gre_kick(), called at
> >> IPL_NET, can call socreate().
> > socreate() must never be called from interrupt context.
> okay then I perhaps don't understand the code.
> if_gre.c:gre_kick() says it "Must be called at IPL_NET" (and it is, from
> gre_ioctl(), right after splnet() was called). gre_kick() in turn calls
> kthread_create1() with 'func' being gre_thread(). in turn, that calls
> gre_thread1(), which can call gre_socreate1(), which can call
> granted, I'm not familiar with neither the gre(4) code nor kernel
> threads, but is there any guarantee that the above won't result in at
> least some cases where socreate() is called at IPL_NET?
In gre(4), socreate(9) is only called from the kernel thread. It's safe.
gre_kick() has to be called at IPL_NET to synchronize it with interrupts
that might affect the state of the gre_softc. I will update the comment.
David Young OJC Technologies
firstname.lastname@example.org Urbana, IL * (217) 278-3933