From bf112579d3d7f5196a96df884e99f1755ce8a4d2 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Sun, 1 Nov 2015 22:53:35 +0000 Subject: Replace the nd6 llinfo malloc(9) with pool_get(9) like arp does. OK mpi@ --- sys/netinet6/nd6.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sys/netinet6') diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 2e8b59e7a8e..7edf8861ce7 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.168 2015/11/01 17:02:44 bluhm Exp $ */ +/* $OpenBSD: nd6.c,v 1.169 2015/11/01 22:53:34 bluhm Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,7 @@ int nd6_debug = 1; int nd6_debug = 0; #endif +struct pool nd6_pool; /* pool for llinfo_nd6 structures */ static int nd6_inuse, nd6_allocated; struct llinfo_nd6 llinfo_nd6 = {&llinfo_nd6, &llinfo_nd6}; @@ -123,6 +125,8 @@ nd6_init(void) return; } + pool_init(&nd6_pool, sizeof(struct llinfo_nd6), 0, 0, 0, "nd6", NULL); + /* initialization of the default router list */ TAILQ_INIT(&nd_defrouter); @@ -996,10 +1000,10 @@ nd6_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt) * Case 2: This route may come from cloning, or a manual route * add with a LL address. */ - ln = malloc(sizeof(*ln), M_RTABLE, M_NOWAIT | M_ZERO); + ln = pool_get(&nd6_pool, PR_NOWAIT | PR_ZERO); rt->rt_llinfo = (caddr_t)ln; if (ln == NULL) { - log(LOG_DEBUG, "%s: malloc failed\n", __func__); + log(LOG_DEBUG, "%s: pool get failed\n", __func__); break; } nd6_inuse++; @@ -1126,7 +1130,7 @@ nd6_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt) rt->rt_llinfo = NULL; rt->rt_flags &= ~RTF_LLINFO; m_freem(ln->ln_hold); - free(ln, M_RTABLE, 0); + pool_put(&nd6_pool, ln); } } -- cgit v1.2.3