Subject: Re: proposed fix for stray ifnet pointers from interface deletion
To: Greg Troxel <>
From: Bill Studenmund <>
List: tech-net
Date: 07/18/2005 13:28:48
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jul 18, 2005 at 04:10:24PM -0400, Greg Troxel wrote:
> Bill Studenmund <> writes:
> > The real fix for this is to add reference counts. That way we really kn=
> > when no one else has a copy of the pointer. Way back when I made the
> > initial patch for deleting interfaces, I added code so that we added and
> > deleted references, and only deleted the innards of an ifnet (and ifadd=
r) =20
> > when the count went to zero. Thus we should be able to avoid this whole
> > class of errors.
> I don't see a reference count in struct ifnet now, so I'm not sure I

Nope, they didn't make it in with the rest of the patch. Which was a bit=20
of a shame as the refcount was the harder part of detach/delete.

> follow you.  It certainly makes sense to do reference counting when
> there could be dangling pointers, but one can also make a case that a
> reference to an ifnet that's being logically deleted should be cleaned
> up somehow.

Well, it "should" be cleaned up. However as a lot of EMails have shown=20
(and as this very thread shows), it's not always easy to get right. :-)

With reference counting, you know exactly when all of the references are=20
cleaned up.

> Did you mean by your comment 'The real fix' that you do not want me to
> commit the proposed change?  My change is really just fixing a logic
> error where PRU_PURGEIF was not called and should have been, and doing
> that doesn't preclude adding reference counts later (or even make it
> harder, I think).

No, go ahead. For two reasons: 1) I think you're right that this fix and=20
reference counts are independent, and 2) I certainly don't have the time=20
now to add reference counting, so I feel I shouldn't say reference counts=
should preclude anything. :-)

Take care,


Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.3 (NetBSD)