summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-04-13 08:04:14 +0000
committermpi <mpi@openbsd.org>2016-04-13 08:04:14 +0000
commit1b3ea614272f82213a8fbaf6e3619aea1fe1600a (patch)
tree5f55c837ab26557c25e2291d82b5136ccb4aeb3a
parentremove "abort" promise from debugging code in radiusd (diff)
downloadwireguard-openbsd-1b3ea614272f82213a8fbaf6e3619aea1fe1600a.tar.xz
wireguard-openbsd-1b3ea614272f82213a8fbaf6e3619aea1fe1600a.zip
Keep all pools in the same place.
ok jmatthew@
-rw-r--r--sys/net/art.c26
-rw-r--r--sys/net/art.h5
-rw-r--r--sys/net/rtable.c16
3 files changed, 33 insertions, 14 deletions
diff --git a/sys/net/art.c b/sys/net/art.c
index 62295355b79..552ff62e2b1 100644
--- a/sys/net/art.c
+++ b/sys/net/art.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: art.c,v 1.13 2016/04/12 06:40:44 mpi Exp $ */
+/* $OpenBSD: art.c,v 1.14 2016/04/13 08:04:14 mpi Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
@@ -83,11 +83,12 @@ int art_table_free(struct art_root *, struct art_table *);
int art_table_walk(struct art_root *, struct art_table *,
int (*f)(struct art_node *, void *), void *);
-struct pool at_pool, at_heap_4_pool, at_heap_8_pool;
+struct pool an_pool, at_pool, at_heap_4_pool, at_heap_8_pool;
void
art_init(void)
{
+ pool_init(&an_pool, sizeof(struct art_node), 0, 0, 0, "art_node", NULL);
pool_init(&at_pool, sizeof(struct art_table), 0, 0, 0, "art_table",
NULL);
pool_init(&at_heap_4_pool, AT_HEAPSIZE(4), 0, 0, 0, "art_heap4", NULL);
@@ -790,3 +791,24 @@ moveup:
if (k != i)
goto moveon;
}
+
+struct art_node *
+art_get(struct sockaddr *dst, uint8_t plen)
+{
+ struct art_node *an;
+
+ an = pool_get(&an_pool, PR_NOWAIT | PR_ZERO);
+ if (an == NULL)
+ return (NULL);
+
+ an->an_dst = dst;
+ an->an_plen = plen;
+
+ return (an);
+}
+
+void
+art_put(struct art_node *an)
+{
+ pool_put(&an_pool, an);
+}
diff --git a/sys/net/art.h b/sys/net/art.h
index a6bfd39d4a0..48e172bce95 100644
--- a/sys/net/art.h
+++ b/sys/net/art.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: art.h,v 1.11 2016/04/12 06:40:44 mpi Exp $ */
+/* $OpenBSD: art.h,v 1.12 2016/04/13 08:04:14 mpi Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
@@ -59,4 +59,7 @@ struct art_node *art_lookup(struct art_root *, uint8_t *, int);
int art_walk(struct art_root *,
int (*)(struct art_node *, void *), void *);
+struct art_node *art_get(struct sockaddr *, uint8_t);
+void art_put(struct art_node *);
+
#endif /* _NET_ART_H_ */
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index 630c5e241dd..2221a492a23 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.39 2016/02/24 22:41:53 mpi Exp $ */
+/* $OpenBSD: rtable.c,v 1.40 2016/04/13 08:04:14 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -23,7 +23,6 @@
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/malloc.h>
-#include <sys/pool.h>
#include <sys/queue.h>
#include <sys/domain.h>
#include <sys/srp.h>
@@ -505,8 +504,6 @@ rtable_mpath_next(struct rtentry *rt)
#else /* ART */
-struct pool an_pool; /* pool for ART node structures */
-
static inline uint8_t *satoaddr(struct art_root *, struct sockaddr *);
void rtentry_ref(void *, void *);
@@ -518,7 +515,6 @@ void
rtable_init_backend(unsigned int keylen)
{
art_init();
- pool_init(&an_pool, sizeof(struct art_node), 0, 0, 0, "art_node", NULL);
}
void *
@@ -699,24 +695,22 @@ rtable_insert(unsigned int rtableid, struct sockaddr *dst,
}
#endif /* SMALL_KERNEL */
- an = pool_get(&an_pool, PR_NOWAIT | PR_ZERO);
+ an = art_get(dst, plen);
if (an == NULL)
return (ENOBUFS);
- an->an_dst = dst;
- an->an_plen = plen;
SRPL_INIT(&an->an_rtlist);
prev = art_insert(ar, an, addr, plen);
if (prev == NULL) {
- pool_put(&an_pool, an);
+ art_put(an);
return (ESRCH);
}
if (prev == an) {
rt->rt_flags &= ~RTF_MPATH;
} else {
- pool_put(&an_pool, an);
+ art_put(an);
#ifndef SMALL_KERNEL
an = prev;
@@ -816,7 +810,7 @@ rtable_delete(unsigned int rtableid, struct sockaddr *dst,
SRPL_REMOVE_LOCKED(&rt_rc, &an->an_rtlist, rt, rtentry, rt_next);
rtfree(rt);
- pool_put(&an_pool, an);
+ art_put(an);
return (0);
}