From 68b13d6bf4410e7deaa91784de45994032808c7b Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 10 Jun 2005 22:34:51 +0000 Subject: [PATCH] spl->critical section conversion. --- sys/netproto/ipx/ipx.c | 11 +++-- sys/netproto/ipx/ipx_pcb.c | 8 ++-- sys/netproto/ipx/ipx_usrreq.c | 40 +++++++---------- sys/netproto/ipx/spx_usrreq.c | 53 ++++++++++------------ sys/netproto/key/key.c | 54 ++++++++++------------- sys/netproto/key/keydb.c | 15 +++---- sys/netproto/key/keysock.c | 82 +++++++++++++++++++---------------- sys/netproto/natm/natm.c | 68 +++++++++++++++-------------- sys/netproto/natm/natm_pcb.c | 12 ++--- 9 files changed, 166 insertions(+), 177 deletions(-) diff --git a/sys/netproto/ipx/ipx.c b/sys/netproto/ipx/ipx.c index ed77f6d1db..d4d62104c1 100644 --- a/sys/netproto/ipx/ipx.c +++ b/sys/netproto/ipx/ipx.c @@ -34,7 +34,7 @@ * @(#)ipx.c * * $FreeBSD: src/sys/netipx/ipx.c,v 1.17.2.3 2003/04/04 09:35:43 tjr Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.7 2004/03/24 01:58:01 hsu Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.8 2005/06/10 22:34:49 dillon Exp $ */ #include @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -254,7 +255,9 @@ ipx_ifinit(ifp, ia, sipx, scrub) int scrub; { struct sockaddr_ipx oldaddr; - int s = splimp(), error; + int error; + + crit_enter(); /* * Set up new addresses. @@ -277,10 +280,10 @@ ipx_ifinit(ifp, ia, sipx, scrub) (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia, (struct ucred *)NULL))) { ia->ia_addr = oldaddr; - splx(s); + crit_exit(); return (error); } - splx(s); + crit_exit(); ia->ia_ifa.ifa_metric = ifp->if_metric; /* * Add route for the network. diff --git a/sys/netproto/ipx/ipx_pcb.c b/sys/netproto/ipx/ipx_pcb.c index 003852126a..707b6ad279 100644 --- a/sys/netproto/ipx/ipx_pcb.c +++ b/sys/netproto/ipx/ipx_pcb.c @@ -34,7 +34,7 @@ * @(#)ipx_pcb.c * * $FreeBSD: src/sys/netipx/ipx_pcb.c,v 1.18.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_pcb.c,v 1.10 2004/06/06 19:16:09 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx_pcb.c,v 1.11 2005/06/10 22:34:49 dillon Exp $ */ #include @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -312,7 +313,8 @@ ipx_pcbnotify(dst, errno, notify, param) long param; { struct ipxpcb *ipxp, *oinp; - int s = splimp(); + + crit_enter(); for (ipxp = (&ipxpcb)->ipxp_next; ipxp != (&ipxpcb);) { if (!ipx_hosteq(*dst,ipxp->ipxp_faddr)) { @@ -329,7 +331,7 @@ ipx_pcbnotify(dst, errno, notify, param) oinp->ipxp_notify_param = param; (*notify)(oinp); } - splx(s); + crit_exit(); } #ifdef notdef diff --git a/sys/netproto/ipx/ipx_usrreq.c b/sys/netproto/ipx/ipx_usrreq.c index 4b52ab4a7f..9604d67408 100644 --- a/sys/netproto/ipx/ipx_usrreq.c +++ b/sys/netproto/ipx/ipx_usrreq.c @@ -34,7 +34,7 @@ * @(#)ipx_usrreq.c * * $FreeBSD: src/sys/netipx/ipx_usrreq.c,v 1.26.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_usrreq.c,v 1.8 2004/06/05 05:34:57 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx_usrreq.c,v 1.9 2005/06/10 22:34:49 dillon Exp $ */ #include "opt_ipx.h" @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -425,12 +426,11 @@ static int ipx_usr_abort(so) struct socket *so; { - int s; struct ipxpcb *ipxp = sotoipxpcb(so); - s = splnet(); + crit_enter(); ipx_pcbdetach(ipxp); - splx(s); + crit_exit(); sofree(so); soisdisconnected(so); return (0); @@ -440,14 +440,13 @@ static int ipx_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int error; - int s; struct ipxpcb *ipxp = sotoipxpcb(so); if (ipxp != NULL) return (EINVAL); - s = splnet(); + crit_enter(); error = ipx_pcballoc(so, &ipxpcb); - splx(s); + crit_exit(); if (error == 0) error = soreserve(so, ipxsendspace, ipxrecvspace, ai->sb_rlimit); @@ -466,14 +465,13 @@ static int ipx_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int error; - int s; struct ipxpcb *ipxp = sotoipxpcb(so); if (!ipx_nullhost(ipxp->ipxp_faddr)) return (EISCONN); - s = splnet(); + crit_enter(); error = ipx_pcbconnect(ipxp, nam, td); - splx(s); + crit_exit(); if (error == 0) soisconnected(so); return (error); @@ -483,14 +481,13 @@ static int ipx_detach(so) struct socket *so; { - int s; struct ipxpcb *ipxp = sotoipxpcb(so); if (ipxp == NULL) return (ENOTCONN); - s = splnet(); + crit_enter(); ipx_pcbdetach(ipxp); - splx(s); + crit_exit(); return (0); } @@ -498,14 +495,13 @@ static int ipx_disconnect(so) struct socket *so; { - int s; struct ipxpcb *ipxp = sotoipxpcb(so); if (ipx_nullhost(ipxp->ipxp_faddr)) return (ENOTCONN); - s = splnet(); + crit_enter(); ipx_pcbdisconnect(ipxp); - splx(s); + crit_exit(); soisdisconnected(so); return (0); } @@ -528,8 +524,8 @@ ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, int error; struct ipxpcb *ipxp = sotoipxpcb(so); struct ipx_addr laddr; - int s = 0; + crit_enter(); if (nam != NULL) { laddr = ipxp->ipxp_laddr; if (!ipx_nullhost(ipxp->ipxp_faddr)) { @@ -539,10 +535,8 @@ ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, /* * Must block input while temporarily connected. */ - s = splnet(); error = ipx_pcbconnect(ipxp, nam, td); if (error) { - splx(s); goto send_release; } } else { @@ -555,11 +549,10 @@ ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, m = NULL; if (nam != NULL) { ipx_pcbdisconnect(ipxp); - splx(s); ipxp->ipxp_laddr = laddr; } - send_release: + crit_exit(); if (m != NULL) m_freem(m); return (error); @@ -588,14 +581,13 @@ static int ripx_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int error = 0; - int s; struct ipxpcb *ipxp = sotoipxpcb(so); if ((error = suser_cred(ai->p_ucred, NULL_CRED_OKAY)) != 0) return (error); - s = splnet(); + crit_enter(); error = ipx_pcballoc(so, &ipxrawpcb); - splx(s); + crit_exit(); if (error) return (error); error = soreserve(so, ipxsendspace, ipxrecvspace, ai->sb_rlimit); diff --git a/sys/netproto/ipx/spx_usrreq.c b/sys/netproto/ipx/spx_usrreq.c index 199854dc53..eb4341f702 100644 --- a/sys/netproto/ipx/spx_usrreq.c +++ b/sys/netproto/ipx/spx_usrreq.c @@ -34,7 +34,7 @@ * @(#)spx_usrreq.h * * $FreeBSD: src/sys/netipx/spx_usrreq.c,v 1.27.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/spx_usrreq.c,v 1.15 2004/07/31 07:52:56 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/spx_usrreq.c,v 1.16 2005/06/10 22:34:49 dillon Exp $ */ #include @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -1267,16 +1268,15 @@ spx_ctloutput(struct socket *so, struct sockopt *sopt) static int spx_usr_abort(struct socket *so) { - int s; struct ipxpcb *ipxp; struct spxpcb *cb; ipxp = sotoipxpcb(so); cb = ipxtospxpcb(ipxp); - s = splnet(); + crit_enter(); spx_drop(cb, ECONNABORTED); - splx(s); + crit_exit(); return (0); } @@ -1305,7 +1305,6 @@ static int spx_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int error; - int s; struct ipxpcb *ipxp; struct spxpcb *cb; struct mbuf *mm; @@ -1316,7 +1315,7 @@ spx_attach(struct socket *so, int proto, struct pru_attach_info *ai) if (ipxp != NULL) return (EISCONN); - s = splnet(); + crit_enter(); error = ipx_pcballoc(so, &ipxpcb); if (error) goto spx_attach_end; @@ -1357,7 +1356,7 @@ spx_attach(struct socket *so, int proto, struct pru_attach_info *ai) SPXTV_MIN, SPXTV_REXMTMAX); ipxp->ipxp_pcb = (caddr_t)cb; spx_attach_end: - splx(s); + crit_exit(); return (error); } @@ -1381,14 +1380,13 @@ static int spx_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { int error; - int s; struct ipxpcb *ipxp; struct spxpcb *cb; ipxp = sotoipxpcb(so); cb = ipxtospxpcb(ipxp); - s = splnet(); + crit_enter(); if (ipxp->ipxp_lport == 0) { error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); if (error) @@ -1415,14 +1413,13 @@ spx_connect(struct socket *so, struct sockaddr *nam, struct thread *td) ipxp->ipxp_fport = 0; error = spx_output(cb, (struct mbuf *)NULL); spx_connect_end: - splx(s); + crit_exit(); return (error); } static int spx_detach(struct socket *so) { - int s; struct ipxpcb *ipxp; struct spxpcb *cb; @@ -1431,12 +1428,12 @@ spx_detach(struct socket *so) if (ipxp == NULL) return (ENOTCONN); - s = splnet(); + crit_enter(); if (cb->s_state > TCPS_LISTEN) spx_disconnect(cb); else spx_close(cb); - splx(s); + crit_exit(); return (0); } @@ -1448,16 +1445,15 @@ spx_detach(struct socket *so) static int spx_usr_disconnect(struct socket *so) { - int s; struct ipxpcb *ipxp; struct spxpcb *cb; ipxp = sotoipxpcb(so); cb = ipxtospxpcb(ipxp); - s = splnet(); + crit_enter(); spx_disconnect(cb); - splx(s); + crit_exit(); return (0); } @@ -1486,18 +1482,17 @@ spx_listen(struct socket *so, struct thread *td) static int spx_rcvd(struct socket *so, int flags) { - int s; struct ipxpcb *ipxp; struct spxpcb *cb; ipxp = sotoipxpcb(so); cb = ipxtospxpcb(ipxp); - s = splnet(); + crit_enter(); cb->s_flags |= SF_RVD; spx_output(cb, (struct mbuf *)NULL); cb->s_flags &= ~SF_RVD; - splx(s); + crit_exit(); return (0); } @@ -1524,7 +1519,6 @@ spx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *controlp, struct thread *td) { int error; - int s; struct ipxpcb *ipxp; struct spxpcb *cb; @@ -1532,7 +1526,7 @@ spx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, ipxp = sotoipxpcb(so); cb = ipxtospxpcb(ipxp); - s = splnet(); + crit_enter(); if (flags & PRUS_OOB) { if (sbspace(&so->so_snd) < -512) { error = ENOBUFS; @@ -1557,7 +1551,7 @@ spx_send_end: m_freem(controlp); if (m != NULL) m_freem(m); - splx(s); + crit_exit(); return (error); } @@ -1565,7 +1559,6 @@ static int spx_shutdown(struct socket *so) { int error; - int s; struct ipxpcb *ipxp; struct spxpcb *cb; @@ -1573,12 +1566,12 @@ spx_shutdown(struct socket *so) ipxp = sotoipxpcb(so); cb = ipxtospxpcb(ipxp); - s = splnet(); + crit_enter(); socantsendmore(so); cb = spx_usrclosed(cb); if (cb != NULL) error = spx_output(cb, (struct mbuf *)NULL); - splx(s); + crit_exit(); return (error); } @@ -1706,8 +1699,8 @@ spx_fasttimo(void) { struct ipxpcb *ipxp; struct spxpcb *cb; - int s = splnet(); + crit_enter(); ipxp = ipxpcb.ipxp_next; if (ipxp != NULL) { for (; ipxp != &ipxpcb; ipxp = ipxp->ipxp_next) { @@ -1720,7 +1713,7 @@ spx_fasttimo(void) } } } - splx(s); + crit_exit(); } /* @@ -1733,15 +1726,15 @@ spx_slowtimo(void) { struct ipxpcb *ip, *ipnxt; struct spxpcb *cb; - int s = splnet(); int i; /* * Search through tcb's and update active timers. */ + crit_enter(); ip = ipxpcb.ipxp_next; if (ip == NULL) { - splx(s); + crit_exit(); return; } while (ip != &ipxpcb) { @@ -1763,7 +1756,7 @@ tpgone: ip = ipnxt; } spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */ - splx(s); + crit_exit(); } /* diff --git a/sys/netproto/key/key.c b/sys/netproto/key/key.c index 3a94338389..e9f2f5ae7b 100644 --- a/sys/netproto/key/key.c +++ b/sys/netproto/key/key.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netkey/key.c,v 1.16.2.13 2002/07/24 18:17:40 ume Exp $ */ -/* $DragonFly: src/sys/netproto/key/key.c,v 1.12 2005/02/08 22:56:19 hsu Exp $ */ +/* $DragonFly: src/sys/netproto/key/key.c,v 1.13 2005/06/10 22:34:50 dillon Exp $ */ /* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */ /* @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -512,7 +513,6 @@ key_allocsp(spidx, dir) { struct secpolicy *sp; struct timeval tv; - int s; /* sanity check */ if (spidx == NULL) @@ -528,7 +528,7 @@ key_allocsp(spidx, dir) } /* get a SP entry */ - s = splnet(); /*called from softclock()*/ + crit_enter(); KEYDEBUG(KEYDEBUG_IPSEC_DATA, printf("*** objects\n"); kdebug_secpolicyindex(spidx)); @@ -544,7 +544,7 @@ key_allocsp(spidx, dir) goto found; } - splx(s); + crit_exit(); return NULL; found: @@ -555,7 +555,7 @@ found: microtime(&tv); sp->lastused = tv.tv_sec; sp->refcnt++; - splx(s); + crit_exit(); KEYDEBUG(KEYDEBUG_IPSEC_STAMP, printf("DP key_allocsp cause refcnt++:%d SP:%p\n", sp->refcnt, sp)); @@ -574,7 +574,6 @@ key_gettunnel(osrc, odst, isrc, idst) struct secpolicy *sp; const int dir = IPSEC_DIR_INBOUND; struct timeval tv; - int s; struct ipsecrequest *r1, *r2, *p; struct sockaddr *os, *od, *is, *id; struct secpolicyindex spidx; @@ -585,7 +584,7 @@ key_gettunnel(osrc, odst, isrc, idst) return NULL; } - s = splnet(); /*called from softclock()*/ + crit_enter(); LIST_FOREACH(sp, &sptree[dir], chain) { if (sp->state == IPSEC_SPSTATE_DEAD) continue; @@ -625,14 +624,14 @@ key_gettunnel(osrc, odst, isrc, idst) goto found; } } - splx(s); + crit_exit(); return NULL; found: microtime(&tv); sp->lastused = tv.tv_sec; sp->refcnt++; - splx(s); + crit_exit(); return sp; } @@ -930,7 +929,6 @@ key_allocsa(family, src, dst, proto, spi) u_int stateidx, state; struct sockaddr_in sin; struct sockaddr_in6 sin6; - int s; const u_int *saorder_state_valid; int arraysize; @@ -956,7 +954,7 @@ key_allocsa(family, src, dst, proto, spi) * IPsec tunnel packet is received. But ESP tunnel mode is * encrypted so we can't check internal IP header. */ - s = splnet(); /*called from softclock()*/ + crit_enter(); LIST_FOREACH(sah, &sahtree, chain) { /* * search a valid state list for inbound packet. @@ -1055,12 +1053,12 @@ key_allocsa(family, src, dst, proto, spi) } /* not found */ - splx(s); + crit_exit(); return NULL; found: sav->refcnt++; - splx(s); + crit_exit(); KEYDEBUG(KEYDEBUG_IPSEC_STAMP, printf("DP allocsa cause refcnt++:%d SA:%p\n", sav->refcnt, sav)); @@ -1205,8 +1203,6 @@ static void key_delsp(sp) struct secpolicy *sp; { - int s; - /* sanity check */ if (sp == NULL) panic("key_delsp: NULL pointer is passed.\n"); @@ -1216,7 +1212,7 @@ key_delsp(sp) if (sp->refcnt > 0) return; /* can't free */ - s = splnet(); /*called from softclock()*/ + crit_enter(); /* remove from SP index */ if (__LIST_CHAINED(sp)) LIST_REMOVE(sp, chain); @@ -1241,7 +1237,7 @@ key_delsp(sp) keydb_delsecpolicy(sp); - splx(s); + crit_exit(); return; } @@ -2479,14 +2475,13 @@ static int key_spdexpire(sp) struct secpolicy *sp; { - int s; struct mbuf *result = NULL, *m; int len; int error = -1; struct sadb_lifetime *lt; /* XXX: Why do we lock ? */ - s = splnet(); /*called from softclock()*/ + crit_enter(); /* sanity check */ if (sp == NULL) @@ -2579,7 +2574,7 @@ key_spdexpire(sp) fail: if (result) m_freem(result); - splx(s); + crit_exit(); return error; } @@ -2621,14 +2616,13 @@ key_delsah(sah) { struct secasvar *sav, *nextsav; u_int stateidx, state; - int s; int zombie = 0; /* sanity check */ if (sah == NULL) panic("key_delsah: NULL pointer is passed.\n"); - s = splnet(); /*called from softclock()*/ + crit_enter(); /* searching all SA registerd in the secindex. */ for (stateidx = 0; @@ -2661,7 +2655,7 @@ key_delsah(sah) /* don't delete sah only if there are savs. */ if (zombie) { - splx(s); + crit_exit(); return; } @@ -2676,7 +2670,7 @@ key_delsah(sah) KFREE(sah); - splx(s); + crit_exit(); return; } @@ -4167,12 +4161,11 @@ void key_timehandler(void *__dummy) { u_int dir; - int s; struct timeval tv; microtime(&tv); - s = splnet(); /*called from softclock()*/ + crit_enter(); /* SPD */ { @@ -4422,7 +4415,7 @@ key_timehandler(void *__dummy) callout_reset(&key_timehandler_ch, hz, key_timehandler, NULL); #endif /* IPSEC_DEBUG2 */ - splx(s); + crit_exit(); return; } @@ -6398,7 +6391,6 @@ static int key_expire(sav) struct secasvar *sav; { - int s; int satype; struct mbuf *result = NULL, *m; int len; @@ -6406,7 +6398,7 @@ key_expire(sav) struct sadb_lifetime *lt; /* XXX: Why do we lock ? */ - s = splnet(); /*called from softclock()*/ + crit_enter(); /* sanity check */ if (sav == NULL) @@ -6503,13 +6495,13 @@ key_expire(sav) mtod(result, struct sadb_msg *)->sadb_msg_len = PFKEY_UNIT64(result->m_pkthdr.len); - splx(s); + crit_exit(); return key_sendup_mbuf(NULL, result, KEY_SENDUP_REGISTERED); fail: if (result) m_freem(result); - splx(s); + crit_exit(); return error; } diff --git a/sys/netproto/key/keydb.c b/sys/netproto/key/keydb.c index b6b326f967..d387db1df8 100644 --- a/sys/netproto/key/keydb.c +++ b/sys/netproto/key/keydb.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netkey/keydb.c,v 1.1.2.1 2000/07/15 07:14:42 kris Exp $ */ -/* $DragonFly: src/sys/netproto/key/keydb.c,v 1.6 2004/04/22 05:09:50 dillon Exp $ */ +/* $DragonFly: src/sys/netproto/key/keydb.c,v 1.7 2005/06/10 22:34:50 dillon Exp $ */ /* $KAME: keydb.c,v 1.64 2000/05/11 17:02:30 itojun Exp $ */ /* @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -128,25 +129,21 @@ void keydb_refsecasvar(p) struct secasvar *p; { - int s; - - s = splnet(); + crit_enter(); p->refcnt++; - splx(s); + crit_exit(); } void keydb_freesecasvar(p) struct secasvar *p; { - int s; - - s = splnet(); + crit_enter(); p->refcnt--; /* negative refcnt will cause panic intentionally */ if (p->refcnt <= 0) keydb_delsecasvar(p); - splx(s); + crit_exit(); } static void diff --git a/sys/netproto/key/keysock.c b/sys/netproto/key/keysock.c index b7b91ef6d8..345d9b6a17 100644 --- a/sys/netproto/key/keysock.c +++ b/sys/netproto/key/keysock.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netkey/keysock.c,v 1.1.2.4 2003/01/11 19:10:59 ume Exp $ */ -/* $DragonFly: src/sys/netproto/key/keysock.c,v 1.12 2005/03/04 02:21:49 hsu Exp $ */ +/* $DragonFly: src/sys/netproto/key/keysock.c,v 1.13 2005/06/10 22:34:50 dillon Exp $ */ /* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ /* @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -77,7 +78,6 @@ key_output(struct mbuf *m, struct socket *so, ...) { struct sadb_msg *msg; int len, error = 0; - int s; if (m == 0) panic("key_output: NULL pointer was passed.\n"); @@ -114,10 +114,10 @@ key_output(struct mbuf *m, struct socket *so, ...) } /*XXX giant lock*/ - s = splnet(); + crit_enter(); error = key_parse(m, so); m = NULL; - splx(s); + crit_exit(); end: if (m) m_freem(m); @@ -369,10 +369,11 @@ key_sendup_mbuf(so, m, target) static int key_abort(struct socket *so) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_abort(so); - splx(s); + crit_exit(); return error; } @@ -384,7 +385,7 @@ static int key_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct keycb *kp; - int s, error; + int error; if (sotorawcb(so) != 0) return EISCONN; /* XXX panic? */ @@ -394,20 +395,20 @@ key_attach(struct socket *so, int proto, struct pru_attach_info *ai) bzero(kp, sizeof *kp); /* - * The splnet() is necessary to block protocols from sending + * The critical section is necessary to block protocols from sending * error notifications (like RTM_REDIRECT or RTM_LOSING) while * this PCB is extant but incompletely initialized. * Probably we should try to do more of this work beforehand and - * eliminate the spl. + * eliminate the critical section. */ - s = splnet(); + crit_enter(); so->so_pcb = (caddr_t)kp; error = raw_usrreqs.pru_attach(so, proto, ai); kp = (struct keycb *)sotorawcb(so); if (error) { free(kp, M_PCB); so->so_pcb = (caddr_t) 0; - splx(s); + crit_exit(); return error; } @@ -421,7 +422,7 @@ key_attach(struct socket *so, int proto, struct pru_attach_info *ai) soisconnected(so); so->so_options |= SO_USELOOPBACK; - splx(s); + crit_exit(); return 0; } @@ -432,10 +433,11 @@ key_attach(struct socket *so, int proto, struct pru_attach_info *ai) static int key_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_bind(so, nam, td); /* xxx just EINVAL */ - splx(s); + crit_exit(); return error; } @@ -446,10 +448,11 @@ key_bind(struct socket *so, struct sockaddr *nam, struct thread *td) static int key_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_connect(so, nam, td); /* XXX just EINVAL */ - splx(s); + crit_exit(); return error; } @@ -461,9 +464,9 @@ static int key_detach(struct socket *so) { struct keycb *kp = (struct keycb *)sotorawcb(so); - int s, error; + int error; - s = splnet(); + crit_enter(); if (kp != 0) { if (kp->kp_raw.rcb_proto.sp_protocol == PF_KEY) /* XXX: AF_KEY */ @@ -473,7 +476,7 @@ key_detach(struct socket *so) key_freereg(so); } error = raw_usrreqs.pru_detach(so); - splx(s); + crit_exit(); return error; } @@ -484,10 +487,11 @@ key_detach(struct socket *so) static int key_disconnect(struct socket *so) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_disconnect(so); - splx(s); + crit_exit(); return error; } @@ -498,10 +502,11 @@ key_disconnect(struct socket *so) static int key_peeraddr(struct socket *so, struct sockaddr **nam) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_peeraddr(so, nam); - splx(s); + crit_exit(); return error; } @@ -513,10 +518,11 @@ static int key_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct mbuf *control, struct thread *td) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_send(so, flags, m, nam, control, td); - splx(s); + crit_exit(); return error; } @@ -527,10 +533,11 @@ key_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, static int key_shutdown(struct socket *so) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_shutdown(so); - splx(s); + crit_exit(); return error; } @@ -541,10 +548,11 @@ key_shutdown(struct socket *so) static int key_sockaddr(struct socket *so, struct sockaddr **nam) { - int s, error; - s = splnet(); + int error; + + crit_enter(); error = raw_usrreqs.pru_sockaddr(so, nam); - splx(s); + crit_exit(); return error; } diff --git a/sys/netproto/natm/natm.c b/sys/netproto/natm/natm.c index 72c69dca0f..fe31def9e3 100644 --- a/sys/netproto/natm/natm.c +++ b/sys/netproto/natm/natm.c @@ -1,6 +1,6 @@ /* $NetBSD: natm.c,v 1.5 1996/11/09 03:26:26 chuck Exp $ */ /* $FreeBSD: src/sys/netnatm/natm.c,v 1.12 2000/02/13 03:32:03 peter Exp $ */ -/* $DragonFly: src/sys/netproto/natm/natm.c,v 1.17 2004/06/06 19:16:13 dillon Exp $ */ +/* $DragonFly: src/sys/netproto/natm/natm.c,v 1.18 2005/06/10 22:34:51 dillon Exp $ */ /* * @@ -95,8 +95,8 @@ natm_usr_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct natmpcb *npcb; int error = 0; - int s = SPLSOFTNET(); + crit_enter(); npcb = (struct natmpcb *) so->so_pcb; if (npcb) { @@ -118,7 +118,7 @@ natm_usr_attach(struct socket *so, int proto, struct pru_attach_info *ai) so->so_pcb = (caddr_t) (npcb = npcb_alloc(M_WAITOK)); npcb->npcb_socket = so; out: - splx(s); + crit_exit(); return (error); } @@ -127,8 +127,8 @@ natm_usr_detach(struct socket *so) { struct natmpcb *npcb; int error = 0; - int s = SPLSOFTNET(); + crit_enter(); npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL) { error = EINVAL; @@ -142,7 +142,7 @@ natm_usr_detach(struct socket *so) so->so_pcb = NULL; sofree(so); out: - splx(s); + crit_exit(); return (error); } @@ -154,9 +154,10 @@ natm_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) struct atm_pseudoioctl api; struct ifnet *ifp; int error = 0; - int s2, s = SPLSOFTNET(); - int proto = so->so_proto->pr_protocol; + int proto; + crit_enter(); + proto = so->so_proto->pr_protocol; npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL) { error = EINVAL; @@ -212,21 +213,21 @@ natm_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; - s2 = splimp(); + crit_enter(); if (ifp->if_ioctl == NULL || ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api, td->td_proc->p_ucred) != 0) { - splx(s2); + crit_exit(); npcb_free(npcb, NPCB_REMOVE); error = EIO; goto out; } - splx(s2); + crit_exit(); soisconnected(so); out: - splx(s); + crit_exit(); return (error); } @@ -237,8 +238,8 @@ natm_usr_disconnect(struct socket *so) struct atm_pseudoioctl api; struct ifnet *ifp; int error = 0; - int s2, s = SPLSOFTNET(); + crit_enter(); npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL) { error = EINVAL; @@ -260,16 +261,16 @@ natm_usr_disconnect(struct socket *so) ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; - s2 = splimp(); + crit_enter(); if (ifp->if_ioctl != NULL) ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api, (struct ucred *)NULL); - splx(s2); + crit_exit(); npcb_free(npcb, NPCB_REMOVE); soisdisconnected(so); out: - splx(s); + crit_exit(); return (error); } @@ -287,9 +288,10 @@ natm_usr_send(struct socket *so, int flags, struct mbuf *m, struct natmpcb *npcb; struct atm_pseudohdr *aph; int error = 0; - int s = SPLSOFTNET(); int proto = so->so_proto->pr_protocol; + crit_enter(); + npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL) { error = EINVAL; @@ -320,7 +322,7 @@ natm_usr_send(struct socket *so, int flags, struct mbuf *m, error = atm_output(npcb->npcb_ifp, m, NULL, NULL); out: - splx(s); + crit_exit(); return (error); } @@ -330,8 +332,8 @@ natm_usr_peeraddr(struct socket *so, struct sockaddr **nam) struct natmpcb *npcb; struct sockaddr_natm *snatm, ssnatm; int error = 0; - int s = SPLSOFTNET(); + crit_enter(); npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL) { error = EINVAL; @@ -349,7 +351,7 @@ natm_usr_peeraddr(struct socket *so, struct sockaddr **nam) *nam = dup_sockaddr((struct sockaddr *)snatm); out: - splx(s); + crit_exit(); return (error); } @@ -360,7 +362,8 @@ natm_usr_control(struct socket *so, u_long cmd, caddr_t arg, struct natmpcb *npcb; struct atm_rawioctl ario; int error = 0; - int s = SPLSOFTNET(); + + crit_enter(); npcb = (struct natmpcb *) so->so_pcb; if (npcb == NULL) { @@ -393,7 +396,7 @@ natm_usr_control(struct socket *so, u_long cmd, caddr_t arg, error = EOPNOTSUPP; out: - splx(s); + crit_exit(); return (error); } @@ -441,7 +444,7 @@ struct proc *p; #endif { - int error = 0, s, s2; + int error = 0; struct natmpcb *npcb; struct sockaddr_natm *snatm; struct atm_pseudoioctl api; @@ -450,7 +453,7 @@ struct proc *p; struct ifnet *ifp; int proto = so->so_proto->pr_protocol; - s = SPLSOFTNET(); + crit_enter(); npcb = (struct natmpcb *) so->so_pcb; @@ -550,16 +553,16 @@ struct proc *p; ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; - s2 = splimp(); + crit_enter(); if (ifp->if_ioctl == NULL || ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api, (struct ucred *)NULL) != 0) { - splx(s2); + crit_exit(); npcb_free(npcb, NPCB_REMOVE); error = EIO; break; } - splx(s2); + crit_exit(); soisconnected(so); @@ -582,10 +585,10 @@ struct proc *p; ATM_PH_VPI(&api.aph) = npcb->npcb_vpi; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; - s2 = splimp(); + crit_enter(); if (ifp->if_ioctl != NULL) ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api, (struct ucred *)NULL); - splx(s2); + crit_exit(); npcb_free(npcb, NPCB_REMOVE); soisdisconnected(so); @@ -692,7 +695,7 @@ struct proc *p; } done: - splx(s); + crit_exit(); return(error); } @@ -747,7 +750,7 @@ natm_init() } /* - * natmintr: splsoftnet interrupt + * natmintr: software interrupt * * note: we expect a socket pointer in rcvif rather than an interface * pointer. we can get the interface pointer from the so's PCB if @@ -757,7 +760,6 @@ static int natmintr(struct netmsg *msg) { struct mbuf *m = ((struct netmsg_packet *)msg)->nm_packet; - int s; struct socket *so; struct natmpcb *npcb; @@ -769,9 +771,9 @@ natmintr(struct netmsg *msg) npcb = (struct natmpcb *) m->m_pkthdr.rcvif; /* XXX: overloaded */ so = npcb->npcb_socket; - s = splimp(); /* could have atm devs @ different levels */ + crit_enter(); npcb->npcb_inq--; - splx(s); + crit_exit(); if (npcb->npcb_flags & NPCB_DRAIN) { m_freem(m); diff --git a/sys/netproto/natm/natm_pcb.c b/sys/netproto/natm/natm_pcb.c index fc5ff61458..ae0099cffc 100644 --- a/sys/netproto/natm/natm_pcb.c +++ b/sys/netproto/natm/natm_pcb.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netnatm/natm_pcb.c,v 1.6.6.1 2000/08/03 18:56:28 peter Exp $ */ -/* $DragonFly: src/sys/netproto/natm/natm_pcb.c,v 1.4 2003/08/23 10:06:24 rob Exp $ */ +/* $DragonFly: src/sys/netproto/natm/natm_pcb.c,v 1.5 2005/06/10 22:34:51 dillon Exp $ */ /* $NetBSD: natm_pcb.c,v 1.4 1996/11/09 03:26:27 chuck Exp $ */ /* @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -88,7 +89,7 @@ struct natmpcb *npcb; int op; { - int s = splimp(); + crit_enter(); if ((npcb->npcb_flags & NPCB_FREE) == 0) { LIST_REMOVE(npcb, pcblist); @@ -102,7 +103,7 @@ int op; } } - splx(s); + crit_exit(); } @@ -120,9 +121,8 @@ u_int8_t vpi; { struct natmpcb *cpcb = NULL; /* current pcb */ - int s = splimp(); - + crit_enter(); /* * lookup required */ @@ -163,7 +163,7 @@ u_int8_t vpi; LIST_INSERT_HEAD(&natm_pcbs, cpcb, pcblist); done: - splx(s); + crit_exit(); return(cpcb); } -- 2.41.0