svn commit: r318321 - head/sys/netinet
Gleb Smirnoff
glebius at FreeBSD.org
Mon May 15 21:58:38 UTC 2017
Author: glebius
Date: Mon May 15 21:58:36 2017
New Revision: 318321
URL: https://svnweb.freebsd.org/changeset/base/318321
Log:
Reduce in_pcbinfo_init() by two params. No users supply any flags to this
function (they used to say UMA_ZONE_NOFREE), so flag parameter goes away.
The zone_fini parameter also goes away. Previously no protocols (except
divert) supplied zone_fini function, so inpcb locks were leaked with slabs.
This was okay while zones were allocated with UMA_ZONE_NOFREE flag, but now
this is a leak. Fix that by suppling inpcb_fini() function as fini method
for all inpcb zones.
Modified:
head/sys/netinet/in_pcb.c
head/sys/netinet/in_pcb.h
head/sys/netinet/ip_divert.c
head/sys/netinet/raw_ip.c
head/sys/netinet/tcp_subr.c
head/sys/netinet/udp_usrreq.c
Modified: head/sys/netinet/in_pcb.c
==============================================================================
--- head/sys/netinet/in_pcb.c Mon May 15 21:50:34 2017 (r318320)
+++ head/sys/netinet/in_pcb.c Mon May 15 21:58:36 2017 (r318321)
@@ -212,14 +212,25 @@ SYSCTL_INT(_net_inet_ip_portrange, OID_A
*/
/*
+ * Different protocols initialize their inpcbs differently - giving
+ * different name to the lock. But they all are disposed the same.
+ */
+static void
+inpcb_fini(void *mem, int size)
+{
+ struct inpcb *inp = mem;
+
+ INP_LOCK_DESTROY(inp);
+}
+
+/*
* Initialize an inpcbinfo -- we should be able to reduce the number of
* arguments in time.
*/
void
in_pcbinfo_init(struct inpcbinfo *pcbinfo, const char *name,
struct inpcbhead *listhead, int hash_nelements, int porthash_nelements,
- char *inpcbzone_name, uma_init inpcbzone_init, uma_fini inpcbzone_fini,
- uint32_t inpcbzone_flags, u_int hashfields)
+ char *inpcbzone_name, uma_init inpcbzone_init, u_int hashfields)
{
INP_INFO_LOCK_INIT(pcbinfo, name);
@@ -239,8 +250,7 @@ in_pcbinfo_init(struct inpcbinfo *pcbinf
in_pcbgroup_init(pcbinfo, hashfields, hash_nelements);
#endif
pcbinfo->ipi_zone = uma_zcreate(inpcbzone_name, sizeof(struct inpcb),
- NULL, NULL, inpcbzone_init, inpcbzone_fini, UMA_ALIGN_PTR,
- inpcbzone_flags);
+ NULL, NULL, inpcbzone_init, inpcb_fini, UMA_ALIGN_PTR, 0);
uma_zone_set_max(pcbinfo->ipi_zone, maxsockets);
uma_zone_set_warning(pcbinfo->ipi_zone,
"kern.ipc.maxsockets limit reached");
Modified: head/sys/netinet/in_pcb.h
==============================================================================
--- head/sys/netinet/in_pcb.h Mon May 15 21:50:34 2017 (r318320)
+++ head/sys/netinet/in_pcb.h Mon May 15 21:58:36 2017 (r318321)
@@ -690,7 +690,7 @@ VNET_DECLARE(int, ipport_tcpallocs);
void in_pcbinfo_destroy(struct inpcbinfo *);
void in_pcbinfo_init(struct inpcbinfo *, const char *, struct inpcbhead *,
- int, int, char *, uma_init, uma_fini, uint32_t, u_int);
+ int, int, char *, uma_init, u_int);
int in_pcbbind_check_bindmulti(const struct inpcb *ni,
const struct inpcb *oi);
Modified: head/sys/netinet/ip_divert.c
==============================================================================
--- head/sys/netinet/ip_divert.c Mon May 15 21:50:34 2017 (r318320)
+++ head/sys/netinet/ip_divert.c Mon May 15 21:58:36 2017 (r318321)
@@ -141,14 +141,6 @@ div_inpcb_init(void *mem, int size, int
}
static void
-div_inpcb_fini(void *mem, int size)
-{
- struct inpcb *inp = mem;
-
- INP_LOCK_DESTROY(inp);
-}
-
-static void
div_init(void)
{
@@ -158,7 +150,7 @@ div_init(void)
* place for hashbase == NULL.
*/
in_pcbinfo_init(&V_divcbinfo, "div", &V_divcb, 1, 1, "divcb",
- div_inpcb_init, div_inpcb_fini, 0, IPI_HASHFIELDS_NONE);
+ div_inpcb_init, IPI_HASHFIELDS_NONE);
}
static void
Modified: head/sys/netinet/raw_ip.c
==============================================================================
--- head/sys/netinet/raw_ip.c Mon May 15 21:50:34 2017 (r318320)
+++ head/sys/netinet/raw_ip.c Mon May 15 21:58:36 2017 (r318321)
@@ -210,7 +210,7 @@ rip_init(void)
{
in_pcbinfo_init(&V_ripcbinfo, "rip", &V_ripcb, INP_PCBHASH_RAW_SIZE,
- 1, "ripcb", rip_inpcb_init, NULL, 0, IPI_HASHFIELDS_NONE);
+ 1, "ripcb", rip_inpcb_init, IPI_HASHFIELDS_NONE);
EVENTHANDLER_REGISTER(maxsockets_change, rip_zone_change, NULL,
EVENTHANDLER_PRI_ANY);
}
Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c Mon May 15 21:50:34 2017 (r318320)
+++ head/sys/netinet/tcp_subr.c Mon May 15 21:58:36 2017 (r318321)
@@ -647,7 +647,7 @@ tcp_init(void)
hashsize);
}
in_pcbinfo_init(&V_tcbinfo, "tcp", &V_tcb, hashsize, hashsize,
- "tcp_inpcb", tcp_inpcb_init, NULL, 0, IPI_HASHFIELDS_4TUPLE);
+ "tcp_inpcb", tcp_inpcb_init, IPI_HASHFIELDS_4TUPLE);
/*
* These have to be type stable for the benefit of the timers.
Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c Mon May 15 21:50:34 2017 (r318320)
+++ head/sys/netinet/udp_usrreq.c Mon May 15 21:58:36 2017 (r318321)
@@ -203,8 +203,7 @@ udp_init(void)
* a 4-tuple, flip this to 4-tuple.
*/
in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE,
- "udp_inpcb", udp_inpcb_init, NULL, 0,
- IPI_HASHFIELDS_2TUPLE);
+ "udp_inpcb", udp_inpcb_init, IPI_HASHFIELDS_2TUPLE);
V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
uma_zone_set_max(V_udpcb_zone, maxsockets);
@@ -218,8 +217,8 @@ udplite_init(void)
{
in_pcbinfo_init(&V_ulitecbinfo, "udplite", &V_ulitecb, UDBHASHSIZE,
- UDBHASHSIZE, "udplite_inpcb", udplite_inpcb_init, NULL,
- 0, IPI_HASHFIELDS_2TUPLE);
+ UDBHASHSIZE, "udplite_inpcb", udplite_inpcb_init,
+ IPI_HASHFIELDS_2TUPLE);
}
/*
More information about the svn-src-head
mailing list