On Wed, Aug 07, 2013 at 03:20:12PM +0200, Christopher Zimmermann wrote:
> On Wed, 7 Aug 2013 07:11:38 +0200
> Claudio Jeker <[email protected]> wrote:
> 
> > On Tue, Aug 06, 2013 at 09:24:13PM +0200, Christopher Zimmermann
> > wrote:
> > > Hi,
> > > 
> > > I'm currently working towards an IP_SENDSRCADDR implementation.
> > > As a first step I moved the calls to in_pcbrehash() from 
> > > in_pcb(dis)connect() and in_pcbbind() to the call sites of those 
> > > functions. This should save some calls to in_pcbrehash() in the 
> > > in_pcbconnect() codepath.
> > > Also I improved code sharing between the IPv4 and IPv6 stacks by 
> > > implementing a generic in_pcbsetport used by both stacks.
> > > The next step will be to replace in_pcbconnect() by in_selectsrc() 
> > > and in_pcbsetport() in udp_output() like the IPv6 stack does it.
> > > The splsoftnet() lock could then be removed. Also implementing
> > > IP_SENDSRCADDR will become trivial because in_selectsrc() won't
> > > modify the struct inpcb like in_pcbconnect() does at the moment.
> > > 
> > > Not much testing yet. Just surfing the web and sending this mail...
> > > 
> > > I'd really like some feedback on whether I'm on the right track or 
> > > doing something stupid here. I have no experience in the OpenBSD 
> > > IP-stack yet.
> > > 
> > > 
> > 
> > Moving the calls of of in_pcbrehash() to outside of in_pcb.c is wrong.
> > This is an internal function for the specific way fast PCB lookups are
> > done at the moment.  Having that all over the place in higher level
> > code where someone does a bind or connect call is not an option IMO.
> > This needs to be done differently, sorry.
> > 
> > -- 
> > :wq Claudio
> 
> Fixed this. Since I won't call in_pcbconnect from udp_output() anymore
> when I'm finished this is no problem at all :)
> 
> Now I'm wondering whether the call to in6_pcbsetport() in udp6_output()
> should be splnet protected? Isn't it possible for two processes to
> acquire the same free port when one finds it before the other has
> claimed it via in_pcbrehash() ?
> 

splnet() is only needed for the bottom of the network stack, anything that
does stuff on struct ifnet (like interface queues or if_start and
interface interrupt handlers). The rest of the network stack should only
need splsoftnet() especially user facing stuff like in_pcb functions.

-- 
:wq Claudio

Reply via email to