Hi,

To make the nd6 code more like arp, I would like to replace the
llinfo malloc(9) with pool_get(9).

ok?

bluhm

Index: netinet/if_ether.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.179
diff -u -p -r1.179 if_ether.c
--- netinet/if_ether.c  27 Oct 2015 15:22:58 -0000      1.179
+++ netinet/if_ether.c  1 Nov 2015 19:47:45 -0000
@@ -215,7 +215,7 @@ arp_rtrequest(struct ifnet *ifp, int req
                la = pool_get(&arp_pool, PR_NOWAIT | PR_ZERO);
                rt->rt_llinfo = (caddr_t)la;
                if (la == NULL) {
-                       log(LOG_DEBUG, "%s: malloc failed\n", __func__);
+                       log(LOG_DEBUG, "%s: pool get failed\n", __func__);
                        break;
                }
                arp_inuse++;
Index: netinet6/nd6.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.168
diff -u -p -r1.168 nd6.c
--- netinet6/nd6.c      1 Nov 2015 17:02:44 -0000       1.168
+++ netinet6/nd6.c      1 Nov 2015 19:47:45 -0000
@@ -39,6 +39,7 @@
 #include <sys/sockio.h>
 #include <sys/time.h>
 #include <sys/kernel.h>
+#include <sys/pool.h>
 #include <sys/protosw.h>
 #include <sys/errno.h>
 #include <sys/ioctl.h>
@@ -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
                 * 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
                rt->rt_llinfo = NULL;
                rt->rt_flags &= ~RTF_LLINFO;
                m_freem(ln->ln_hold);
-               free(ln, M_RTABLE, 0);
+               pool_put(&nd6_pool, ln);
        }
 }
 

Reply via email to