Code duplication but rib_head is special. Not found an easy way to go

back and harmize the use cases among RIB, IPFW, PF yet but it's also not
the scope of this work.   Prevents instant panics on teardown and frees
the FIB bits again.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Bjoern A. Zeeb 2016-02-03 21:56:51 +00:00
parent 2414e86439
commit a5243af262
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/vnet/; revision=295220
3 changed files with 19 additions and 2 deletions

View File

@ -353,10 +353,24 @@ rt_table_init(int offset)
return (rh);
}
static int
rt_freeentry(struct radix_node *rn, void *arg)
{
struct radix_head * const rnh = arg;
struct radix_node *x;
x = (struct radix_node *)rn_delete(rn + 2, NULL, rnh);
if (x != NULL)
R_Free(x);
return (0);
}
void
rt_table_destroy(struct rib_head *rh)
{
rn_walktree(&rh->rmhead.head, rt_freeentry, &rh->rmhead.head);
/* Assume table is already empty */
rw_destroy(&rh->rib_lock);
free(rh, M_RTABLE);

View File

@ -133,7 +133,8 @@ int
in_detachhead(void **head, int off)
{
return (rn_detachhead(head));
rt_table_destroy((struct rib_head *)(*head));
return (1);
}
#endif

View File

@ -237,7 +237,9 @@ in6_detachhead(void **head, int off)
{
callout_drain(&V_rtq_mtutimer);
return (rn_detachhead(head));
rt_table_destroy((struct rib_head *)(*head));
return (1);
}
#endif