diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2019-07-15 12:40:43 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2019-07-15 12:40:43 +0000 |
commit | 130f2b7e50ebc5880fd6a2861903dc1dd1431020 (patch) | |
tree | 17ac6bc81bc7da73ce53763105e53dadea7f39b0 /sys | |
parent | af3a305f8811acb38256df7d7d60c66e48d5c9ac (diff) |
Initialize struct inpcb pool not on demand, but during initialization.
Removes a global variable and avoids MP problems.
OK mpi@ visa@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in_pcb.c | 19 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 3 | ||||
-rw-r--r-- | sys/netinet/in_proto.c | 3 |
3 files changed, 16 insertions, 9 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index e1b876919d2..97a6157d133 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.247 2018/10/04 17:33:41 bluhm Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.248 2019/07/15 12:40:42 bluhm Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -114,7 +114,6 @@ int ipport_hilastauto = IPPORT_HILASTAUTO; struct baddynamicports baddynamicports; struct baddynamicports rootonlyports; struct pool inpcb_pool; -int inpcb_pool_initialized = 0; int in_pcbresize (struct inpcbtable *, int); @@ -124,6 +123,17 @@ struct inpcbhead *in_pcbhash(struct inpcbtable *, int, const struct in_addr *, u_short, const struct in_addr *, u_short); struct inpcbhead *in_pcblhash(struct inpcbtable *, int, u_short); +/* + * in_pcb is used for inet and inet6. in6_pcb only contains special + * IPv6 cases. So the internet initializer is used for both domains. + */ +void +in_init(void) +{ + pool_init(&inpcb_pool, sizeof(struct inpcb), 0, + IPL_SOFTNET, 0, "inpcb", NULL); +} + struct inpcbhead * in_pcbhash(struct inpcbtable *table, int rdom, const struct in_addr *faddr, u_short fport, @@ -218,11 +228,6 @@ in_pcballoc(struct socket *so, struct inpcbtable *table) NET_ASSERT_LOCKED(); - if (inpcb_pool_initialized == 0) { - pool_init(&inpcb_pool, sizeof(struct inpcb), 0, - IPL_SOFTNET, 0, "inpcbpl", NULL); - inpcb_pool_initialized = 1; - } inp = pool_get(&inpcb_pool, PR_NOWAIT|PR_ZERO); if (inp == NULL) return (ENOBUFS); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index a8fa2235c95..4c9ff602699 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.115 2018/10/04 17:33:41 bluhm Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.116 2019/07/15 12:40:42 bluhm Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -256,6 +256,7 @@ extern int in_pcbnotifymiss; #define sotopf(so) (so->so_proto->pr_domain->dom_family) +void in_init(void); void in_losing(struct inpcb *); int in_pcballoc(struct socket *, struct inpcbtable *); int in_pcbbind(struct inpcb *, struct mbuf *, struct proc *); diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 66487b361a8..53e86b16b33 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.92 2019/06/13 08:12:11 claudio Exp $ */ +/* $OpenBSD: in_proto.c,v 1.93 2019/07/15 12:40:42 bluhm Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -441,6 +441,7 @@ const struct protosw inetsw[] = { struct domain inetdomain = { .dom_family = AF_INET, .dom_name = "internet", + .dom_init = in_init, .dom_protosw = inetsw, .dom_protoswNPROTOSW = &inetsw[nitems(inetsw)], .dom_sasize = sizeof(struct sockaddr_in), |