From 42cd5f7b8b30faa01b665f77341de79ba4f2bac0 Mon Sep 17 00:00:00 2001 From: rwatson Date: Thu, 8 Jun 2006 23:18:40 +0000 Subject: [PATCH] Merge spx_usrreq.c:1.70 from HEAD to RELENG_6: 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. --- sys/netipx/spx_usrreq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c index 45384d019bc..833e50ffeb7 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(); } /* -- 2.45.2