summaryrefslogtreecommitdiffstats
path: root/sys/netipx
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-03-24 00:26:25 +0000
committerrwatson <rwatson@FreeBSD.org>2006-03-24 00:26:25 +0000
commit81ed88b306e130fbe70d91da4ffdddffb2b018a8 (patch)
tree3239ef6f7e8f25c9b10ccb62882b895981a5f3aa /sys/netipx
parentaa09ae8a755b2256a7314dd2c0c8367640262d3a (diff)
downloadFreeBSD-src-81ed88b306e130fbe70d91da4ffdddffb2b018a8.zip
FreeBSD-src-81ed88b306e130fbe70d91da4ffdddffb2b018a8.tar.gz
Protect spx_iss using its own mutex, spx_mtx, rather than piggy-backing
on the global IPX mutex, which is not held at all necessary strategic points. MFC after: 1 month
Diffstat (limited to 'sys/netipx')
-rw-r--r--sys/netipx/spx_usrreq.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c
index 4ffafc3..037c53d 100644
--- a/sys/netipx/spx_usrreq.c
+++ b/sys/netipx/spx_usrreq.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
/*
* SPX protocol implementation.
*/
+static struct mtx spx_mtx; /* Protects only spx_iss. */
static u_short spx_iss;
static u_short spx_newchecks[50];
static int spx_hardnosed;
@@ -74,6 +75,10 @@ static int traceallspxs = 0;
static struct spx_istat spx_istat;
static int spxrexmtthresh = 3;
+#define SPX_LOCK_INIT() mtx_init(&spx_mtx, "spx_mtx", NULL, MTX_DEF)
+#define SPX_LOCK() mtx_lock(&spx_mtx)
+#define SPX_UNLOCK() mtx_unlock(&spx_mtx)
+
/* Following was struct spxstat spxstat; */
#ifndef spxstat
#define spxstat spx_istat.newstats
@@ -149,6 +154,7 @@ void
spx_init(void)
{
+ SPX_LOCK_INIT();
spx_iss = 1; /* WRONG !! should fish it out of TODR */
}
@@ -1626,8 +1632,10 @@ spx_template(struct spxpcb *cb)
ipx->ipx_pt = IPXPROTO_SPX;
ipx->ipx_sna = ipxp->ipxp_laddr;
ipx->ipx_dna = ipxp->ipxp_faddr;
+ SPX_LOCK();
cb->s_sid = htons(spx_iss);
spx_iss += SPX_ISSINCR/2;
+ SPX_UNLOCK();
cb->s_alo = 1;
cb->s_cwnd = (sbspace(sb) * CUNIT) / cb->s_mtu;
cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
@@ -1794,8 +1802,10 @@ spx_slowtimo(void)
IPX_UNLOCK(cb->s_ipxpcb);
}
}
- spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
IPX_LIST_UNLOCK();
+ SPX_LOCK();
+ spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
+ SPX_UNLOCK();
}
/*
OpenPOWER on IntegriCloud