summaryrefslogtreecommitdiffstats
path: root/sys/netipx/ipx_usrreq.c
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2002-05-20 05:41:09 +0000
committertanimura <tanimura@FreeBSD.org>2002-05-20 05:41:09 +0000
commit92d8381dd544a8237b3fd68c4e7fce9bd0903fb2 (patch)
tree2465ddbcecac65f96c5c6d5cef1a4fe3f1ac03f8 /sys/netipx/ipx_usrreq.c
parent969293170b27461145f69a538d5abd15fea34ba1 (diff)
downloadFreeBSD-src-92d8381dd544a8237b3fd68c4e7fce9bd0903fb2.zip
FreeBSD-src-92d8381dd544a8237b3fd68c4e7fce9bd0903fb2.tar.gz
Lock down a socket, milestone 1.
o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a socket buffer. The mutex in the receive buffer also protects the data in struct socket. o Determine the lock strategy for each members in struct socket. o Lock down the following members: - so_count - so_options - so_linger - so_state o Remove *_locked() socket APIs. Make the following socket APIs touching the members above now require a locked socket: - sodisconnect() - soisconnected() - soisconnecting() - soisdisconnected() - soisdisconnecting() - sofree() - soref() - sorele() - sorwakeup() - sotryfree() - sowakeup() - sowwakeup() Reviewed by: alfred
Diffstat (limited to 'sys/netipx/ipx_usrreq.c')
-rw-r--r--sys/netipx/ipx_usrreq.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c
index f0c803a..68d9f10 100644
--- a/sys/netipx/ipx_usrreq.c
+++ b/sys/netipx/ipx_usrreq.c
@@ -146,7 +146,9 @@ ipx_input(m, ipxp)
if (sbappendaddr(&ipxp->ipxp_socket->so_rcv, (struct sockaddr *)&ipx_ipx,
m, (struct mbuf *)NULL) == 0)
goto bad;
+ SOCK_LOCK(ipxp->ipxp_socket);
sorwakeup(ipxp->ipxp_socket);
+ SOCK_UNLOCK(ipxp->ipxp_socket);
return;
bad:
m_freem(m);
@@ -159,7 +161,9 @@ ipx_abort(ipxp)
struct socket *so = ipxp->ipxp_socket;
ipx_pcbdisconnect(ipxp);
+ SOCK_LOCK(so);
soisdisconnected(so);
+ SOCK_UNLOCK(so);
}
/*
@@ -186,7 +190,9 @@ ipx_drop(ipxp, errno)
}*/
so->so_error = errno;
ipx_pcbdisconnect(ipxp);
+ SOCK_LOCK(so);
soisdisconnected(so);
+ SOCK_UNLOCK(so);
}
static int
@@ -200,6 +206,7 @@ ipx_output(ipxp, m0)
register struct route *ro;
struct mbuf *m;
struct mbuf *mprev = NULL;
+ int soopts;
/*
* Calculate data length.
@@ -261,9 +268,14 @@ ipx_output(ipxp, m0)
* Output datagram.
*/
so = ipxp->ipxp_socket;
- if (so->so_options & SO_DONTROUTE)
+ SOCK_LOCK(so);
+ if (so->so_options & SO_DONTROUTE) {
+ soopts = so->so_options & SO_BROADCAST;
+ SOCK_UNLOCK(so);
return (ipx_outputfl(m, (struct route *)NULL,
- (so->so_options & SO_BROADCAST) | IPX_ROUTETOIF));
+ soopts | IPX_ROUTETOIF));
+ }
+ SOCK_UNLOCK(so);
/*
* Use cached route for previous datagram if
* possible. If the previous net was the same
@@ -306,7 +318,10 @@ ipx_output(ipxp, m0)
}
ipxp->ipxp_lastdst = ipx->ipx_dna;
#endif /* ancient_history */
- return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST));
+ SOCK_LOCK(so);
+ soopts = so->so_options & SO_BROADCAST;
+ SOCK_UNLOCK(so);
+ return (ipx_outputfl(m, ro, soopts));
}
int
@@ -429,8 +444,11 @@ ipx_usr_abort(so)
s = splnet();
ipx_pcbdetach(ipxp);
splx(s);
+ SOCK_LOCK(so);
sotryfree(so);
+ SOCK_LOCK(so);
soisdisconnected(so);
+ SOCK_UNLOCK(so);
return (0);
}
@@ -480,8 +498,11 @@ ipx_connect(so, nam, td)
s = splnet();
error = ipx_pcbconnect(ipxp, nam, td);
splx(s);
- if (error == 0)
+ if (error == 0) {
+ SOCK_LOCK(so);
soisconnected(so);
+ SOCK_UNLOCK(so);
+ }
return (error);
}
@@ -512,7 +533,9 @@ ipx_disconnect(so)
s = splnet();
ipx_pcbdisconnect(ipxp);
splx(s);
+ SOCK_LOCK(so);
soisdisconnected(so);
+ SOCK_UNLOCK(so);
return (0);
}
OpenPOWER on IntegriCloud