summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_domain.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-09-01 05:01:55 +0000
committersam <sam@FreeBSD.org>2003-09-01 05:01:55 +0000
commitf13a722652fb71f09c5943abad4fac4e82da66b4 (patch)
treee9449d38bd3c07716fd5ddaf45d24b3e93a4d0de /sys/kern/uipc_domain.c
parentb972498a825f3774c635f067ed719aa73daa6559 (diff)
downloadFreeBSD-src-f13a722652fb71f09c5943abad4fac4e82da66b4.zip
FreeBSD-src-f13a722652fb71f09c5943abad4fac4e82da66b4.tar.gz
o interlock domain list when adding domains
o remove irrlevant spl Notes: 1. We don't lock domain list traversals as this is safe until we start removing domains. 2. The calculation of max_datalen in net_init_domain appears safe as noone depends on max_hdr and max_datalen having consistent values. 3. Giant is still held for fast and slow timeouts; this must stay until each timeout routine is properly locked (coming soon). Sponsored by: FreeBSD Fondation
Diffstat (limited to 'sys/kern/uipc_domain.c')
-rw-r--r--sys/kern/uipc_domain.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 0fa21ac..98fba8f 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
#include <sys/domain.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/socketvar.h>
#include <sys/systm.h>
#include <vm/uma.h>
@@ -67,7 +69,8 @@ static struct callout pfslow_callout;
static void pffasttimo(void *);
static void pfslowtimo(void *);
-struct domain *domains;
+struct domain *domains; /* registered protocol domains */
+struct mtx dom_mtx; /* domain list lock */
/*
* Add a new protocol domain to the list of supported domains
@@ -77,10 +80,8 @@ struct domain *domains;
static void
net_init_domain(struct domain *dp)
{
- register struct protosw *pr;
- int s;
+ struct protosw *pr;
- s = splnet();
if (dp->dom_init)
(*dp->dom_init)();
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){
@@ -96,7 +97,6 @@ net_init_domain(struct domain *dp)
*/
max_hdr = max_linkhdr + max_protohdr;
max_datalen = MHLEN - max_hdr;
- splx(s);
}
/*
@@ -107,14 +107,13 @@ net_init_domain(struct domain *dp)
void
net_add_domain(void *data)
{
- int s;
struct domain *dp;
dp = (struct domain *)data;
- s = splnet();
+ mtx_lock(&dom_mtx);
dp->dom_next = domains;
domains = dp;
- splx(s);
+ mtx_unlock(&dom_mtx);
net_init_domain(dp);
}
@@ -131,6 +130,8 @@ domaininit(void *dummy)
NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
uma_zone_set_max(socket_zone, maxsockets);
+ mtx_init(&dom_mtx, "domain list lock", NULL, MTX_DEF);
+
if (max_linkhdr < 16) /* XXX */
max_linkhdr = 16;
OpenPOWER on IntegriCloud