Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Mar 2010 15:09:10 +0000
From:      Bruce Cran <brucec@muon.cran.org.uk>
To:        "Bjoern A. Zeeb" <bz@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r204808 - head/sys/net
Message-ID:  <20100307150909.GA6554@muon.cran.org.uk>
In-Reply-To: <201003062127.o26LRQ6J042057@svn.freebsd.org>
References:  <201003062127.o26LRQ6J042057@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Mar 06, 2010 at 09:27:26PM +0000, Bjoern A. Zeeb wrote:
> Author: bz
> Date: Sat Mar  6 21:27:26 2010
> New Revision: 204808
> URL: http://svn.freebsd.org/changeset/base/204808
> 
> Log:
>   Introduce a function rn_detachhead() that will free the
>   radix table root nodes.  This is only needed (and available)
>   in the virtualization case to free the resources when tearing
>   down a virtual network stack.
>   
>   Sponsored by:	ISPsystem
>   Reviewed by:	julian, zec
>   MFC after:	5 days
> 
> Modified:
>   head/sys/net/radix.c
>   head/sys/net/radix.h
> 
> Modified: head/sys/net/radix.c
> ==============================================================================
> --- head/sys/net/radix.c	Sat Mar  6 21:24:32 2010	(r204807)
> +++ head/sys/net/radix.c	Sat Mar  6 21:27:26 2010	(r204808)
> @@ -1161,6 +1161,24 @@ rn_inithead(head, off)
>  	return (1);
>  }
>  
> +#ifdef VIMAGE
> +int
> +rn_detachhead(void **head)
> +{
> +	struct radix_node_head *rnh;
> +
> +	KASSERT((head != NULL && *head != NULL),
> +	    ("%s: head already freed", __func__));
> +	rnh = *head;
> +	
> +	/* Free <left,root,right> nodes. */
> +	Free(rnh);
> +
> +	*head = NULL;
> +	return (1);
> +}
> +#endif

Is this sufficient to free all the memory? From what I can see, 'Free' is 
just freeing the pointer and not walking the tree to free the nodes too.

I don't know if the memory allocation is being done differently, but I 
fixed the same issue on Windows by introducing a 'rn_free_subtree' 
function - I don't know if it's entirely correct but the code can be 
seen at http://www.bluestop.org/viewvc/repos/sctpDrv/net/radix.c?r1=24&r2=23&pathrev=24

I also found that rn_zeros wasn't being freed when the driver got 
unloaded.

-- 
Bruce Cran



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100307150909.GA6554>