diff options
-rw-r--r-- | sys/kern/uipc_proto.c | 3 | ||||
-rw-r--r-- | sys/kern/uipc_usrreq.c | 17 | ||||
-rw-r--r-- | sys/sys/unpcb.h | 3 |
3 files changed, 17 insertions, 6 deletions
diff --git a/sys/kern/uipc_proto.c b/sys/kern/uipc_proto.c index a3a1802575c..d57340cd9c3 100644 --- a/sys/kern/uipc_proto.c +++ b/sys/kern/uipc_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_proto.c,v 1.17 2018/04/08 18:57:39 guenther Exp $ */ +/* $OpenBSD: uipc_proto.c,v 1.18 2019/07/15 12:28:06 bluhm Exp $ */ /* $NetBSD: uipc_proto.c,v 1.8 1996/02/13 21:10:47 christos Exp $ */ /*- @@ -79,6 +79,7 @@ struct protosw unixsw[] = { struct domain unixdomain = { .dom_family = AF_UNIX, .dom_name = "unix", + .dom_init = unp_init, .dom_externalize = unp_externalize, .dom_dispose = unp_dispose, .dom_protosw = unixsw, diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 09fd1bbf77b..6e936a56f22 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.140 2019/05/24 15:17:29 bluhm Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.141 2019/07/15 12:28:06 bluhm Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -50,6 +50,7 @@ #include <sys/mbuf.h> #include <sys/task.h> #include <sys/pledge.h> +#include <sys/pool.h> void uipc_setaddr(const struct unpcb *, struct mbuf *); @@ -72,6 +73,7 @@ void unp_mark(struct fdpass *, int); void unp_scan(struct mbuf *, void (*)(struct fdpass *, int)); int unp_nam2sun(struct mbuf *, struct sockaddr_un **, size_t *); +struct pool unpcb_pool; /* list of sets of files that were sent over sockets that are now closed */ SLIST_HEAD(,unp_deferral) unp_deferred = SLIST_HEAD_INITIALIZER(unp_deferred); @@ -90,6 +92,13 @@ struct sockaddr sun_noname = { sizeof(sun_noname), AF_UNIX }; ino_t unp_ino; /* prototype for fake inode numbers */ void +unp_init(void) +{ + pool_init(&unpcb_pool, sizeof(struct unpcb), 0, + IPL_NONE, 0, "unpcb", NULL); +} + +void uipc_setaddr(const struct unpcb *unp, struct mbuf *nam) { if (unp != NULL && unp->unp_addr != NULL) { @@ -370,7 +379,7 @@ uipc_attach(struct socket *so, int proto) if (error) return (error); } - unp = malloc(sizeof(*unp), M_PCB, M_NOWAIT|M_ZERO); + unp = pool_get(&unpcb_pool, PR_NOWAIT|PR_ZERO); if (unp == NULL) return (ENOBUFS); unp->unp_socket = so; @@ -414,7 +423,7 @@ unp_detach(struct unpcb *unp) soisdisconnected(unp->unp_socket); unp->unp_socket->so_pcb = NULL; m_freem(unp->unp_addr); - free(unp, M_PCB, sizeof *unp); + pool_put(&unpcb_pool, unp); if (unp_rights) task_add(systq, &unp_gc_task); } @@ -638,7 +647,7 @@ unp_drop(struct unpcb *unp, int errno) */ sofree(so, SL_NOUNLOCK); m_freem(unp->unp_addr); - free(unp, M_PCB, sizeof *unp); + pool_put(&unpcb_pool, unp); } } diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h index 4239c282c63..daa22a11d57 100644 --- a/sys/sys/unpcb.h +++ b/sys/sys/unpcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unpcb.h,v 1.16 2017/11/02 14:01:18 florian Exp $ */ +/* $OpenBSD: unpcb.h,v 1.17 2019/07/15 12:28:06 bluhm Exp $ */ /* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */ /* @@ -96,6 +96,7 @@ int uipc_usrreq(struct socket *, int , struct mbuf *, int uipc_attach(struct socket *, int); int uipc_detach(struct socket *); +void unp_init(void); int unp_bind(struct unpcb *, struct mbuf *, struct proc *); int unp_connect(struct socket *, struct mbuf *, struct proc *); int unp_connect2(struct socket *, struct socket *); |