Heh. This would achieve much the same thing that I was after.
This doesn't do the work to do dls_destroy()... so I'm not entirely sure
that it is safe. But it *looks* safe to me.
So, in your gate, if you did the following, it would pretty much achieve
the same thing I was after:
s/mac_unregister/mac_destroy/ (and assume that it could never fail, so
maybe cast it to (void).)
s/mac_condemn/mac_unregister/
-- Garrett
On Fri, 2007-09-07 at 12:04 -0400, Sebastien Roy wrote:
> Garrett D'Amore wrote:
> > On Fri, 2007-09-07 at 16:49 +0100, Paul Durrant wrote:
> >> On 07/09/2007, Garrett D'Amore <[EMAIL PROTECTED]> wrote:
> >>>> You mean upstream callers that have done mac_open()? That should take
> >>>> a ref. on the mac_impl_t.
> >>> Yes, but since that reference count would not be covered by a lock that
> >>> the driver currently knows about or could safely acquire, the driver
> >>> clould not rely upon it to tell it anything meaningful.
> >>>
> >> ? Surely mac_unregister() *must* take the same lock as mac_open() to
> >> check the ref. count? It should do, if it doesn't today.
> >
> > Yes, but you're *missing* the point.
> >
> > The point is that without calling mac_unregister(), the driver doesn't
> > know if there are any active upstream callers.
> >
> > So the only easy solution I can come up with without major contortions
> > on the part of drivers, is to create a new function, that separates
> > *unregistration* (which honors such a reference count) from actually
> > freeing the memory associated with the mac_impl_t.
>
> For the Clearview iptun work, I created a mac_condemn() function which is
> basically:
>
> int
> mac_condemn(mac_handle_t mh)
> {
> mac_impl_t *mip = (mac_impl_t *)mh;
>
> rw_enter(&i_mac_impl_lock, RW_WRITER);
> if (mip->mi_ref > 0) {
> ASSERT(!mip->mi_disabled);
> rw_exit(&i_mac_impl_lock);
> return (EBUSY);
> }
> mip->mi_disabled = B_TRUE;
> rw_exit(&i_mac_impl_lock);
> return (0);
> }
>
> This allows me (the driver) to call mac_condemn(), then disable things
> safely until I'm ready to call mac_unregister(), which safely frees the
> mac_impl_t.
>
> -Seb
_______________________________________________
networking-discuss mailing list
[email protected]