Subject: Re: stray ifnet pointers in mcast membership records & cloning -> crash
To: Bill Studenmund <wrstuden@netbsd.org>
From: Greg Troxel <gdt@ir.bbn.com>
List: tech-net
Date: 03/03/2005 12:11:48
Bill Studenmund <wrstuden@netbsd.org> writes:

> I've been thinking about other options, but I now suspect that calling 
> PURGEIF for all PFs (note: PF, not AF :-) is probably best. The only flip 
> side is to make sure all PFs will deal with being told to prune an 
> interface that they haven't used. The fact I didn't trust that they 
> necessarily would is why we only tell PFs that have an address.

The semantics of PRU_PURGEIF should simply be "remove all references
to this ifp", so if they cause trouble will just need minor fixes.
Given that the INET/INET6 purge routines basically walk pcb lists and
say "is this entry mine, and does it refer to this ifp, and if so
clean it up", I would not expect trouble from others.   But I see your
point in caution when it wasn't clear that calling some of them anyway
is needed.

It might be nice if sys/protosw.h had comments with more
crisply-defined semantics for things like PRU_PURGEIF, like

/*
 * Ensure that no data structures kept by this protocol retain a
 * pointer to the 'struct ifnet *' passed in the third (control) mbuf
 * slot.  This may not be invoked from interrupt context; a valid proc
 * pointer is required.  (XXX It is not clear if a socket must be
 * passed.  No existing routines use the socket pointer.)  The first
 * two mbuf slots (m and nam) should be NULL.
 */

I looked at ns_purgeif, iso_purgeif, and at_purgeif, and they all just
loop through the addrs, deleting each one.   So while that could be
insufficient if ifps are stored in pcbs for those protocols, it won't
hurt to call them with no addresses.

-- 
        Greg Troxel <gdt@ir.bbn.com>