From 66a25ac45e495379c05c76339c0aa59353cd4381 Mon Sep 17 00:00:00 2001 From: Eirik Nygaard Date: Fri, 15 Jul 2005 17:19:28 +0000 Subject: [PATCH] Convert spl* to critical sections. --- sys/netinet/sctp_asconf.c | 21 +-- sys/netinet/sctp_input.c | 12 +- sys/netinet/sctp_output.c | 155 ++++++++------------ sys/netinet/sctp_pcb.c | 88 ++++-------- sys/netinet/sctp_usrreq.c | 278 +++++++++++++----------------------- sys/netinet/sctputil.c | 28 ++-- sys/netinet6/sctp6_usrreq.c | 155 +++++++------------- 7 files changed, 261 insertions(+), 476 deletions(-) diff --git a/sys/netinet/sctp_asconf.c b/sys/netinet/sctp_asconf.c index 521f4ebcbb..c76fe795fa 100644 --- a/sys/netinet/sctp_asconf.c +++ b/sys/netinet/sctp_asconf.c @@ -1,5 +1,5 @@ /* $KAME: sctp_asconf.c,v 1.23 2004/08/17 06:28:01 t-momose Exp $ */ -/* $DragonFly: src/sys/netinet/sctp_asconf.c,v 1.2 2005/07/15 15:15:26 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet/sctp_asconf.c,v 1.3 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -1805,7 +1806,6 @@ static void sctp_addr_mgmt_ep(struct sctp_inpcb *inp, struct ifaddr *ifa, uint16_t type) { struct sctp_tcb *stcb; - int s; SCTP_INP_WLOCK(inp); /* make sure we're "allowed" to add this type of addr */ @@ -1879,18 +1879,14 @@ sctp_addr_mgmt_ep(struct sctp_inpcb *inp, struct ifaddr *ifa, uint16_t type) } } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); /* process for all associations for this endpoint */ LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { SCTP_TCB_LOCK(stcb); sctp_addr_mgmt_assoc(inp, stcb, ifa, type); SCTP_TCB_UNLOCK(stcb); } /* for each stcb */ - splx(s); + crit_exit(); SCTP_INP_WUNLOCK(inp); } @@ -1901,7 +1897,6 @@ static void sctp_addr_mgmt_restrict_ep(struct sctp_inpcb *inp, struct ifaddr *ifa) { struct sctp_tcb *stcb; - int s; /* is this endpoint bound to all? */ if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) { @@ -1912,11 +1907,7 @@ sctp_addr_mgmt_restrict_ep(struct sctp_inpcb *inp, struct ifaddr *ifa) return; } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); SCTP_INP_RLOCK(inp); /* process for all associations for this endpoint */ LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { @@ -1930,7 +1921,7 @@ sctp_addr_mgmt_restrict_ep(struct sctp_inpcb *inp, struct ifaddr *ifa) } #endif /* SCTP_DEBUG */ } /* for each stcb */ - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); } diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 19b3c2b8f5..86e370f2d4 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1,5 +1,5 @@ /* $KAME: sctp_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */ -/* $DragonFly: src/sys/netinet/sctp_input.c,v 1.5 2005/07/15 15:39:48 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet/sctp_input.c,v 1.6 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (C) 2002, 2003, 2004 Cisco Systems Inc, @@ -59,6 +59,7 @@ #include #include #include +#include #if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) #include @@ -4086,7 +4087,6 @@ sctp_input(m, va_alist) #endif { int iphlen; - int s; u_int8_t ecn_bits; struct ip *ip; struct sctphdr *sh; @@ -4383,15 +4383,11 @@ sctp_input(m, va_alist) offset -= sizeof(struct sctp_chunkhdr); ecn_bits = ip->ip_tos; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_common_input_processing(&m, iphlen, offset, length, sh, ch, inp, stcb, net, ecn_bits); /* inp's ref-count reduced && stcb unlocked */ - splx(s); + crit_exit(); if (m) { sctp_m_freem(m); } diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index da421ff8ae..35740f1beb 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -1,5 +1,5 @@ /* $KAME: sctp_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */ -/* $DragonFly: src/sys/netinet/sctp_output.c,v 1.3 2005/07/15 15:15:26 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet/sctp_output.c,v 1.4 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (C) 2002, 2003, 2004 Cisco Systems Inc, @@ -64,6 +64,7 @@ #ifdef INET6 #include #endif +#include #if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) #include @@ -7214,18 +7215,13 @@ sctp_output(inp, m, addr, control, p, flags) struct sctp_association *asoc; int create_lock_applied = 0; int queue_only, error = 0; - int s; struct sctp_sndrcvinfo srcv; int un_sent = 0; int use_rcvinfo = 0; t_inp = inp; /* struct route ro;*/ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); queue_only = 0; ip_inp = (struct inpcb *)inp; stcb = NULL; @@ -7247,7 +7243,7 @@ sctp_output(inp, m, addr, control, p, flags) control = NULL; } sctp_m_freem(m); - splx(s); + crit_exit(); return (EFAULT); } /* Can't allow a V6 address on a non-v6 socket */ @@ -7263,7 +7259,7 @@ sctp_output(inp, m, addr, control, p, flags) control = NULL; } sctp_m_freem(m); - splx(s); + crit_exit(); return (EFAULT); } create_lock_applied = 1; @@ -7276,7 +7272,7 @@ sctp_output(inp, m, addr, control, p, flags) control = NULL; } sctp_m_freem(m); - splx(s); + crit_exit(); return (EINVAL); } } @@ -7288,7 +7284,7 @@ sctp_output(inp, m, addr, control, p, flags) /* its a sendall */ sctppcbinfo.mbuf_track--; sctp_m_freem(control); - splx(s); + crit_exit(); if (create_lock_applied) { SCTP_ASOC_CREATE_UNLOCK(inp); create_lock_applied = 0; @@ -7311,7 +7307,7 @@ sctp_output(inp, m, addr, control, p, flags) sctppcbinfo.mbuf_track--; sctp_m_freem(control); sctp_m_freem(m); - splx(s); + crit_exit(); return (ENOTCONN); } net = stcb->asoc.primary_destination; @@ -7344,7 +7340,7 @@ sctp_output(inp, m, addr, control, p, flags) SCTP_TCB_LOCK(stcb); SCTP_INP_RUNLOCK(inp); if (stcb == NULL) { - splx(s); + crit_exit(); if (create_lock_applied) { SCTP_ASOC_CREATE_UNLOCK(inp); create_lock_applied = 0; @@ -7391,7 +7387,7 @@ sctp_output(inp, m, addr, control, p, flags) create_lock_applied = 0; } sctp_m_freem(m); - splx(s); + crit_exit(); return (ENOTCONN); } else if ((stcb == NULL) && (addr == NULL)) { @@ -7405,7 +7401,7 @@ sctp_output(inp, m, addr, control, p, flags) create_lock_applied = 0; } sctp_m_freem(m); - splx(s); + crit_exit(); return (ENOENT); } else if (stcb == NULL) { /* UDP mode, we must go ahead and start the INIT process */ @@ -7421,7 +7417,7 @@ sctp_output(inp, m, addr, control, p, flags) create_lock_applied = 0; } sctp_m_freem(m); - splx(s); + crit_exit(); return (ENOENT); } stcb = sctp_aloc_assoc(inp, addr, 1, &error, 0); @@ -7436,7 +7432,7 @@ sctp_output(inp, m, addr, control, p, flags) create_lock_applied = 0; } sctp_m_freem(m); - splx(s); + crit_exit(); return (error); } if (create_lock_applied) { @@ -7536,7 +7532,7 @@ sctp_output(inp, m, addr, control, p, flags) sctp_m_freem(m); error = ECONNRESET; } - splx(s); + crit_exit(); SCTP_TCB_UNLOCK(stcb); return (error); } @@ -7576,7 +7572,7 @@ sctp_output(inp, m, addr, control, p, flags) } if ((error = sctp_msg_append(stcb, net, m, &srcv, flags))) { SCTP_TCB_UNLOCK(stcb); - splx(s); + crit_exit(); return (error); } if (net->flight_size > net->cwnd) { @@ -7630,7 +7626,7 @@ sctp_output(inp, m, addr, control, p, flags) } #endif SCTP_TCB_UNLOCK(stcb); - splx(s); + crit_exit(); return (0); } @@ -9523,7 +9519,6 @@ sctp_copy_it_in(struct sctp_inpcb *inp, */ struct socket *so; int error = 0; - int s; int frag_size, mbcnt = 0, mbcnt_e = 0; unsigned int sndlen; unsigned int tot_demand; @@ -9534,11 +9529,7 @@ sctp_copy_it_in(struct sctp_inpcb *inp, uint32_t my_vtag; int resv_in_first; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); so = stcb->sctp_socket; chk = NULL; mm = NULL; @@ -9554,7 +9545,7 @@ sctp_copy_it_in(struct sctp_inpcb *inp, if (sndlen > so->so_snd.sb_hiwat) { /* It will NEVER fit */ error = EMSGSIZE; - splx(s); + crit_exit(); goto release; } /* Do I need to block? */ @@ -9623,23 +9614,23 @@ sctp_copy_it_in(struct sctp_inpcb *inp, * here for us */ error = inp->error_on_block; - splx(s); + crit_exit(); goto out_locked; } if (error) { - splx(s); + crit_exit(); goto out_locked; } /* did we encounter a socket error? */ if (so->so_error) { error = so->so_error; - splx(s); + crit_exit(); goto out_locked; } error = sblock(&so->so_snd, M_WAITOK); if (error) { /* Can't aquire the lock */ - splx(s); + crit_exit(); goto out_locked; } #if defined(__FreeBSD__) && __FreeBSD_version >= 502115 @@ -9649,12 +9640,12 @@ sctp_copy_it_in(struct sctp_inpcb *inp, #endif /* The socket is now set not to sendmore.. its gone */ error = EPIPE; - splx(s); + crit_exit(); goto release; } if (so->so_error) { error = so->so_error; - splx(s); + crit_exit(); goto release; } if (asoc->peer_supports_prsctp) { @@ -9722,10 +9713,10 @@ sctp_copy_it_in(struct sctp_inpcb *inp, SCTP_RESPONSE_TO_USER_REQ, mm); mm = NULL; - splx(s); + crit_exit(); goto out_notlocked; } - splx(s); + crit_exit(); goto release; } @@ -9736,14 +9727,14 @@ sctp_copy_it_in(struct sctp_inpcb *inp, (asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) { /* got data while shutting down */ error = ECONNRESET; - splx(s); + crit_exit(); goto release; } /* Is the stream no. valid? */ if (srcv->sinfo_stream >= asoc->streamoutcnt) { /* Invalid stream number */ error = EINVAL; - splx(s); + crit_exit(); goto release; } if (asoc->strmout == NULL) { @@ -9754,19 +9745,19 @@ sctp_copy_it_in(struct sctp_inpcb *inp, } #endif error = EFAULT; - splx(s); + crit_exit(); goto release; } if ((srcv->sinfo_flags & MSG_EOF) && (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && (tot_out == 0)) { - splx(s); + crit_exit(); goto zap_by_it_now; } if (tot_out == 0) { /* not allowed */ error = EMSGSIZE; - splx(s); + crit_exit(); goto release; } /* save off the tag */ @@ -9778,7 +9769,7 @@ sctp_copy_it_in(struct sctp_inpcb *inp, /* two choices here, it all fits in one chunk or * we need multiple chunks. */ - splx(s); + crit_exit(); SOCKBUF_UNLOCK(&so->so_snd); if (tot_out <= frag_size) { /* no need to setup a template */ @@ -9822,17 +9813,13 @@ sctp_copy_it_in(struct sctp_inpcb *inp, if (chk->flags & SCTP_PR_SCTP_BUFFER) { asoc->sent_queue_cnt_removeable++; } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if ((asoc->state == 0) || (my_vtag != asoc->my_vtag) || (so != inp->sctp_socket) || (inp->sctp_socket == 0)) { /* connection was aborted */ - splx(s); + crit_exit(); error = ECONNRESET; goto clean_up; } @@ -9846,7 +9833,7 @@ sctp_copy_it_in(struct sctp_inpcb *inp, */ sctp_insert_on_wheel(asoc, strq); } - splx(s); + crit_exit(); clean_up: if (error) { SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk); @@ -9923,17 +9910,13 @@ clean_up: /* now move it to the streams actual queue */ /* first stop protocol processing */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if ((asoc->state == 0) || (my_vtag != asoc->my_vtag) || (so != inp->sctp_socket) || (inp->sctp_socket == 0)) { /* connection was aborted */ - splx(s); + crit_exit(); error = ECONNRESET; goto temp_clean_up; } @@ -9954,7 +9937,7 @@ clean_up: sctp_insert_on_wheel(asoc, strq); } /* Ok now we can allow pping */ - splx(s); + crit_exit(); temp_clean_up: if (error) { SOCKBUF_LOCK(&so->so_snd); @@ -9985,11 +9968,7 @@ zap_by_it_now: asoc->total_output_mbuf_queue_size, mbcnt); #endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); SOCKBUF_LOCK(&so->so_snd); asoc->total_output_queue_size += dataout; asoc->total_output_mbuf_queue_size += mbcnt; @@ -10048,7 +10027,7 @@ zap_by_it_now: asoc->state |= SCTP_STATE_SHUTDOWN_PENDING; } } - splx(s); + crit_exit(); #ifdef SCTP_DEBUG if (sctp_debug_on & SCTP_DEBUG_OUTPUT2) { printf("++total out:%d total_mbuf_out:%d\n", @@ -10092,7 +10071,7 @@ sctp_sosend(struct socket *so, { unsigned int sndlen; int error, use_rcvinfo; - int s, queue_only = 0, queue_only_for_init=0; + int queue_only = 0, queue_only_for_init=0; int un_sent = 0; int now_filled=0; struct sctp_inpcb *inp; @@ -10123,17 +10102,13 @@ sctp_sosend(struct socket *so, sndlen = top->m_pkthdr.len; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING)) { /* The listner can NOT send */ error = EFAULT; - splx(s); + crit_exit(); goto out; } if (addr) { @@ -10142,7 +10117,7 @@ sctp_sosend(struct socket *so, (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { /* Should I really unlock ? */ error = EFAULT; - splx(s); + crit_exit(); goto out; } @@ -10150,7 +10125,7 @@ sctp_sosend(struct socket *so, if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) && (addr->sa_family == AF_INET6)) { error = EINVAL; - splx(s); + crit_exit(); goto out; } } @@ -10161,7 +10136,7 @@ sctp_sosend(struct socket *so, if (stcb == NULL) { SCTP_INP_RUNLOCK(inp); error = ENOTCONN; - splx(s); + crit_exit(); goto out; } SCTP_TCB_LOCK(stcb); @@ -10223,11 +10198,11 @@ sctp_sosend(struct socket *so, if ((stcb == NULL) && (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) { error = ENOTCONN; - splx(s); + crit_exit(); goto out; } else if ((stcb == NULL) && (addr == NULL)) { error = ENOENT; - splx(s); + crit_exit(); goto out; } else if (stcb == NULL) { /* UDP style, we must go ahead and start the INIT process */ @@ -10235,14 +10210,14 @@ sctp_sosend(struct socket *so, (srcv.sinfo_flags & MSG_ABORT)) { /* User asks to abort a non-existant asoc */ error = ENOENT; - splx(s); + crit_exit(); goto out; } /* get an asoc/stcb struct */ stcb = sctp_aloc_assoc(inp, addr, 1, &error, 0); if (stcb == NULL) { /* Error is setup for us in the call */ - splx(s); + crit_exit(); goto out; } if (create_lock_applied) { @@ -10351,7 +10326,7 @@ sctp_sosend(struct socket *so, ; } else { error = ECONNRESET; - splx(s); + crit_exit(); goto out; } } @@ -10378,7 +10353,7 @@ sctp_sosend(struct socket *so, * protocol processing until we are ready to * send/queue it. */ - splx(s); + crit_exit(); error = sctp_copy_it_in(inp, stcb, asoc, net, &srcv, uio, flags); if (error) goto out; @@ -10387,7 +10362,7 @@ sctp_sosend(struct socket *so, * buffers, or use top to do a msg_append. */ error = sctp_msg_append(stcb, net, top, &srcv, flags); - splx(s); + crit_exit(); if (error) goto out; /* zap the top since it is now being used */ @@ -10440,39 +10415,27 @@ sctp_sosend(struct socket *so, printf("USR Send calls sctp_chunk_output\n"); } #endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_pegs[SCTP_OUTPUT_FRM_SND]++; sctp_chunk_output(inp, stcb, 0); - splx(s); + crit_exit(); } else if ((queue_only == 0) && (stcb->asoc.peers_rwnd == 0) && (stcb->asoc.total_flight == 0)) { /* We get to have a probe outstanding */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_from_user_send = 1; sctp_chunk_output(inp, stcb, 0); sctp_from_user_send = 0; - splx(s); + crit_exit(); } else if (!TAILQ_EMPTY(&stcb->asoc.control_send_queue)) { int num_out, reason, cwnd_full; /* Here we do control only */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, &reason, 1, &cwnd_full, 1, &now, &now_filled); - splx(s); + crit_exit(); } #ifdef SCTP_DEBUG if (sctp_debug_on & SCTP_DEBUG_OUTPUT1) { diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 19f4f1b777..389c67eeb5 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -1,5 +1,5 @@ /* $KAME: sctp_pcb.c,v 1.37 2004/08/17 06:28:02 t-momose Exp $ */ -/* $DragonFly: src/sys/netinet/sctp_pcb.c,v 1.4 2005/07/15 15:46:55 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet/sctp_pcb.c,v 1.5 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -60,6 +60,7 @@ #include #include #include +#include #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) #include #endif @@ -2236,19 +2237,15 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate) #if !defined(__FreeBSD__) || __FreeBSD_version < 500000 struct rtentry *rt; #endif - int s, cnt; + int cnt; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); SCTP_ASOC_CREATE_LOCK(inp); SCTP_INP_WLOCK(inp); if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { /* been here before */ - splx(s); + crit_exit(); printf("Endpoint was all gone (dup free)?\n"); SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); @@ -2338,7 +2335,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate) /* now is there some left in our SHUTDOWN state? */ if (cnt_in_sd) { inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE; - splx(s); + crit_exit(); SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return; @@ -2364,7 +2361,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate) #ifdef IPSEC #ifdef __OpenBSD__ /* XXX IPsec cleanup here */ - int s2 = spltdb(); + crit_enter(); if (ip_pcb->inp_tdb_in) TAILQ_REMOVE(&ip_pcb->inp_tdb_in->tdb_inp_in, ip_pcb, inp_tdb_in_next); @@ -2383,7 +2380,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate) ipsp_reffree(ip_pcb->inp_ipsec_localauth); if (ip_pcb->inp_ipsec_remoteauth) ipsp_reffree(ip_pcb->inp_ipsec_remoteauth); - splx(s2); + crit_exit(); #else ipsec4_delete_pcbpolicy(ip_pcb); #endif @@ -2521,7 +2518,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate) sctppcbinfo.ipi_count_ep--; SCTP_INP_INFO_WUNLOCK(); - splx(s); + crit_exit(); } @@ -3318,18 +3315,13 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb) struct sctp_tmit_chunk *chk; struct sctp_asconf_addr *aparam; struct sctp_socket_q_list *sq; - int s; /* first, lets purge the entry from the hash table. */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if (stcb->asoc.state == 0) { printf("Freeing already free association:%p - huh??\n", stcb); - splx(s); + crit_exit(); return; } asoc = &stcb->asoc; @@ -3633,7 +3625,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb) if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { sctp_inpcb_free(inp, 0); } - splx(s); + crit_exit(); } @@ -3928,18 +3920,12 @@ sctp_add_local_addr_assoc(struct sctp_tcb *stcb, struct ifaddr *ifa) int sctp_insert_laddr(struct sctpladdr *list, struct ifaddr *ifa) { struct sctp_laddr *laddr; - int s; - -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); laddr = (struct sctp_laddr *)SCTP_ZONE_GET(sctppcbinfo.ipi_zone_laddr); if (laddr == NULL) { /* out of memory? */ - splx(s); + crit_exit(); return (EINVAL); } sctppcbinfo.ipi_count_laddr++; @@ -3949,7 +3935,7 @@ sctp_insert_laddr(struct sctpladdr *list, struct ifaddr *ifa) { /* insert it */ LIST_INSERT_HEAD(list, laddr, sctp_nxt_addr); - splx(s); + crit_exit(); return (0); } @@ -3959,19 +3945,13 @@ sctp_insert_laddr(struct sctpladdr *list, struct ifaddr *ifa) { void sctp_remove_laddr(struct sctp_laddr *laddr) { - int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); /* remove from the list */ LIST_REMOVE(laddr, sctp_nxt_addr); SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_laddr, laddr); sctppcbinfo.ipi_count_laddr--; sctppcbinfo.ipi_gencnt_laddr++; - - splx(s); + crit_exit(); } /* @@ -5048,7 +5028,7 @@ sctp_initiate_iterator(asoc_func af, uint32_t pcb_state, uint32_t asoc_state, struct sctp_inpcb *s_inp) { struct sctp_iterator *it=NULL; - int s; + if (af == NULL) { return (-1); } @@ -5084,13 +5064,9 @@ sctp_initiate_iterator(asoc_func af, uint32_t pcb_state, uint32_t asoc_state, SCTP_INP_INFO_WLOCK(); LIST_INSERT_HEAD(&sctppcbinfo.iteratorhead, it, sctp_nxt_itr); SCTP_INP_INFO_WUNLOCK(); -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_iterator_timer(it); - splx(s); + crit_exit(); return (0); } @@ -5112,9 +5088,7 @@ callout_init(struct callout *c) void callout_reset(struct callout *c, int to_ticks, void (*ftn)(void *), void *arg) { - int s; - - s = splhigh(); + crit_enter(); if (c->c_flags & CALLOUT_PENDING) callout_stop(c); @@ -5136,21 +5110,19 @@ callout_reset(struct callout *c, int to_ticks, void (*ftn)(void *), void *arg) c->c_time = ticks + to_ticks; TAILQ_INSERT_TAIL(&sctppcbinfo.callqueue, c, tqe); #endif - splx(s); + crit_exit(); } int callout_stop(struct callout *c) { - int s; - - s = splhigh(); + crit_enter(); /* * Don't attempt to delete a callout that's not on the queue. */ if (!(c->c_flags & CALLOUT_PENDING)) { c->c_flags &= ~CALLOUT_ACTIVE; - splx(s); + crit_exit(); return (0); } c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING| CALLOUT_FIRED); @@ -5161,7 +5133,7 @@ callout_stop(struct callout *c) TAILQ_REMOVE(&sctppcbinfo.callqueue, c, tqe); c->c_func = NULL; #endif - splx(s); + crit_exit(); return (1); } @@ -5172,8 +5144,8 @@ sctp_fasttim(void) struct callout *c, *n; struct calloutlist locallist; int inited = 0; - int s; - s = splhigh(); + + crit_enter(); /* run through and subtract and mark all callouts */ c = TAILQ_FIRST(&sctppcbinfo.callqueue); while (c) { @@ -5200,14 +5172,14 @@ sctp_fasttim(void) /* now validate that it did not get canceled */ if (c->c_flags & CALLOUT_FIRED) { c->c_flags &= ~CALLOUT_PENDING; - splx(s); + crit_exit(); (*c->c_func)(c->c_arg); - s = splhigh(); + crit_enter(); } c = TAILQ_FIRST(&locallist); } } - splx(s); + crit_exit(); } #endif #endif /* _SCTP_NEEDS_CALLOUT_ */ diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 3b952947ca..5782ba7604 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1,5 +1,5 @@ /* $KAME: sctp_usrreq.c,v 1.47 2005/03/06 16:04:18 itojun Exp $ */ -/* $DragonFly: src/sys/netinet/sctp_usrreq.c,v 1.5 2005/07/15 15:52:00 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet/sctp_usrreq.c,v 1.6 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) @@ -457,7 +458,6 @@ sctp_ctlinput(cmd, sa, vip) { struct ip *ip = vip; struct sctphdr *sh; - int s; if (sa->sa_family != AF_INET || @@ -499,11 +499,7 @@ sctp_ctlinput(cmd, sa, vip) * 'from' holds our local endpoint address. * Thus we reverse the to and the from in the lookup. */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); stcb = sctp_findassociation_addr_sa((struct sockaddr *)&from, (struct sockaddr *)&to, &inp, &net, 1); @@ -538,7 +534,7 @@ sctp_ctlinput(cmd, sa, vip) } } - splx(s); + crit_exit(); } #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) return; @@ -555,7 +551,7 @@ sctp_getcred(SYSCTL_HANDLER_ARGS) struct sctp_inpcb *inp; struct sctp_nets *net; struct sctp_tcb *stcb; - int error, s; + int error; #if __FreeBSD_version >= 500000 || defined(__DragonFly__) error = suser(req->td); @@ -568,7 +564,7 @@ sctp_getcred(SYSCTL_HANDLER_ARGS) if (error) return (error); - s = splnet(); + crit_enter(); stcb = sctp_findassociation_addr_sa(sintosa(&addrs[0]), sintosa(&addrs[1]), &inp, &net, 1); @@ -584,8 +580,8 @@ sctp_getcred(SYSCTL_HANDLER_ARGS) } error = SYSCTL_OUT(req, inp->sctp_socket->so_cred, sizeof(struct ucred)); SCTP_TCB_UNLOCK(stcb); - out: - splx(s); +out: + crit_exit(); return (error); } @@ -707,19 +703,14 @@ static int sctp_abort(struct socket *so) { struct sctp_inpcb *inp; - int s; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) return EINVAL; /* ??? possible? panic instead? */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_inpcb_free(inp, 1); - splx(s); + crit_exit(); return 0; } @@ -734,26 +725,22 @@ sctp_attach(struct socket *so, int proto, struct proc *p) { struct sctp_inpcb *inp; struct inpcb *ip_inp; - int s, error; + int error; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp != 0) { - splx(s); + crit_exit(); return EINVAL; } error = soreserve(so, sctp_sendspace, sctp_recvspace, NULL); if (error) { - splx(s); + crit_exit(); return error; } error = sctp_inpcb_alloc(so); if (error) { - splx(s); + crit_exit(); return error; } inp = (struct sctp_inpcb *)so->so_pcb; @@ -782,7 +769,7 @@ sctp_attach(struct socket *so, int proto, struct proc *p) #if defined(__NetBSD__) so->so_send = sctp_sosend; #endif - splx(s); + crit_exit(); return 0; } @@ -799,7 +786,7 @@ sctp_bind(struct socket *so, struct mbuf *nam, struct proc *p) struct sockaddr *addr = nam ? mtod(nam, struct sockaddr *) : NULL; #endif struct sctp_inpcb *inp; - int s, error; + int error; #ifdef INET6 if (addr && addr->sa_family != AF_INET) @@ -811,13 +798,9 @@ sctp_bind(struct socket *so, struct mbuf *nam, struct proc *p) if (inp == 0) return EINVAL; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); error = sctp_inpcb_bind(so, addr, p); - splx(s); + crit_exit(); return error; } @@ -826,22 +809,18 @@ static int sctp_detach(struct socket *so) { struct sctp_inpcb *inp; - int s; + inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) return EINVAL; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || (so->so_rcv.sb_cc > 0)) { sctp_inpcb_free(inp, 1); } else { sctp_inpcb_free(inp, 0); } - splx(s); + crit_exit(); return 0; } @@ -963,23 +942,18 @@ static int sctp_disconnect(struct socket *so) { struct sctp_inpcb *inp; - int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { - splx(s); + crit_exit(); return (ENOTCONN); } SCTP_INP_RLOCK(inp); if (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { if (LIST_EMPTY(&inp->sctp_asoc_list)) { /* No connection */ - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); return (0); } else { @@ -989,7 +963,7 @@ sctp_disconnect(struct socket *so) stcb = LIST_FIRST(&inp->sctp_asoc_list); if (stcb == NULL) { - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); return (EINVAL); } @@ -1017,7 +991,7 @@ sctp_disconnect(struct socket *so) SCTP_INP_RUNLOCK(inp); sctp_free_assoc(inp, stcb); /* No unlock tcb assoc is gone */ - splx(s); + crit_exit(); return (0); } if (!TAILQ_EMPTY(&asoc->out_wheel)) { @@ -1075,14 +1049,14 @@ sctp_disconnect(struct socket *so) } SCTP_TCB_UNLOCK(stcb); SCTP_INP_RUNLOCK(inp); - splx(s); + crit_exit(); return (0); } /* not reached */ } else { /* UDP model does not support this */ SCTP_INP_RUNLOCK(inp); - splx(s); + crit_exit(); return EOPNOTSUPP; } } @@ -1091,16 +1065,11 @@ int sctp_shutdown(struct socket *so) { struct sctp_inpcb *inp; - int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) { - splx(s); + crit_exit(); return EINVAL; } SCTP_INP_RLOCK(inp); @@ -1113,7 +1082,7 @@ sctp_shutdown(struct socket *so) so->so_state &= ~SS_CANTRCVMORE; #endif /* This proc will wakeup for read and do nothing (I hope) */ - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); return (EOPNOTSUPP); } @@ -1133,7 +1102,7 @@ sctp_shutdown(struct socket *so) * Ok we hit the case that the shutdown call was made * after an abort or something. Nothing to do now. */ - splx(s); + crit_exit(); return (0); } SCTP_TCB_LOCK(stcb); @@ -1184,7 +1153,7 @@ sctp_shutdown(struct socket *so) SCTP_TCB_UNLOCK(stcb); } SCTP_INP_RUNLOCK(inp); - splx(s); + crit_exit(); return 0; } @@ -1460,11 +1429,6 @@ sctp_do_connect_x(struct socket *so, int delay ) { -#if defined(__NetBSD__) || defined(__OpenBSD__) - int s = splsoftnet(); -#else - int s = splnet(); -#endif int error = 0; struct sctp_tcb *stcb = NULL; struct sockaddr *sa; @@ -1475,10 +1439,11 @@ sctp_do_connect_x(struct socket *so, } #endif /* SCTP_DEBUG */ + crit_enter(); if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { /* We are already connected AND the TCP model */ - splx(s); + crit_exit(); return (EADDRINUSE); } if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) { @@ -1487,7 +1452,7 @@ sctp_do_connect_x(struct socket *so, SCTP_INP_RUNLOCK(inp); } if (stcb) { - splx(s); + crit_exit(); return (EALREADY); } @@ -1495,7 +1460,7 @@ sctp_do_connect_x(struct socket *so, if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (EFAULT); } @@ -1517,7 +1482,7 @@ sctp_do_connect_x(struct socket *so, if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { /* Must be non-mapped for connectx */ SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return EINVAL; } num_v6++; @@ -1531,7 +1496,7 @@ sctp_do_connect_x(struct socket *so, /* Already have or am bring up an association */ SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_TCB_UNLOCK(stcb); - splx(s); + crit_exit(); return (EALREADY); } if ((at + incr) > m->m_len) { @@ -1547,7 +1512,7 @@ sctp_do_connect_x(struct socket *so, #ifdef INET6 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) && (num_v6 > 0)) { - splx(s); + crit_exit(); SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return (EINVAL); @@ -1571,7 +1536,7 @@ sctp_do_connect_x(struct socket *so, */ SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return EINVAL; } } @@ -1583,7 +1548,7 @@ sctp_do_connect_x(struct socket *so, error = sctp_inpcb_bind(so, NULL, p); if (error) { SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (error); } } else { @@ -1594,7 +1559,7 @@ sctp_do_connect_x(struct socket *so, if (stcb == NULL) { /* Gak! no memory */ SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (error); } /* move to second address */ @@ -1610,7 +1575,7 @@ sctp_do_connect_x(struct socket *so, /* assoc gone no un-lock */ sctp_free_assoc(inp, stcb); SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (ENOBUFS); } @@ -1620,7 +1585,7 @@ sctp_do_connect_x(struct socket *so, /* assoc gone no un-lock */ sctp_free_assoc(inp, stcb); SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (ENOBUFS); } } @@ -1642,7 +1607,7 @@ sctp_do_connect_x(struct socket *so, soisconnecting(so); } SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return error; } @@ -2719,7 +2684,7 @@ sctp_optsset(struct socket *so, #endif ) { - int error, *mopt, set_opt, s; + int error, *mopt, set_opt; struct mbuf *m; struct sctp_tcb *stcb = NULL; struct sctp_inpcb *inp; @@ -2901,14 +2866,10 @@ sctp_optsset(struct socket *so, } sctp_send_str_reset_req(stcb, strrst->strrst_num_streams, strrst->strrst_list, two_way, not_peer); -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_chunk_output(inp, stcb, 12); SCTP_TCB_UNLOCK(stcb); - splx(s); + crit_exit(); } break; @@ -3607,16 +3568,12 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) { struct mbuf *m = NULL; struct sctp_inpcb *inp; - int s, error; + int error; inp = (struct sctp_inpcb *)so->so_pcb; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if (inp == 0) { - splx(s); + crit_exit(); /* I made the same as TCP since we are not setup? */ return (ECONNRESET); } @@ -3628,7 +3585,7 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) else #endif /* INET6 */ error = ip_ctloutput(so, sopt); - splx(s); + crit_exit(); return (error); } if (sopt->sopt_valsize > MCLBYTES) { @@ -3645,7 +3602,7 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) MCLGET(m, MB_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { sctp_m_freem(m); - splx(s); + crit_exit(); return (ENOBUFS); } } @@ -3679,7 +3636,7 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt) sctp_m_freem(m); } out: - splx(s); + crit_exit(); return (error); } @@ -3701,11 +3658,7 @@ sctp_ctloutput(op, so, level, optname, mp) family = so->so_proto->pr_domain->dom_family; error = 0; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_exit(); switch (family) { case PF_INET: inp = sotoinpcb(so); @@ -3720,7 +3673,7 @@ sctp_ctloutput(op, so, level, optname, mp) break; #endif default: - splx(s); + crit_exit(); return EAFNOSUPPORT; } #ifndef INET6 @@ -3729,7 +3682,7 @@ sctp_ctloutput(op, so, level, optname, mp) if (inp == NULL && in6p == NULL) #endif { - splx(s); + crit_exit(); if (op == PRCO_SETOPT && *mp) (void) m_free(*mp); return (ECONNRESET); @@ -3745,7 +3698,7 @@ sctp_ctloutput(op, so, level, optname, mp) break; #endif } - splx(s); + crit_exit(); return (error); } /* Ok if we reach here it is a SCTP option we hope */ @@ -3758,7 +3711,7 @@ sctp_ctloutput(op, so, level, optname, mp) } else { error = EINVAL; } - splx(s); + crit_exit(); return (error); } @@ -3777,11 +3730,6 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) { struct sockaddr *addr = mtod(nam, struct sockaddr *); #endif -#endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - int s = splsoftnet(); -#else - int s = splnet(); #endif int error = 0; struct sctp_inpcb *inp; @@ -3794,9 +3742,10 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) printf("Port %d\n", ntohs(((struct sockaddr_in *)addr)->sin_port)); } #endif /* SCTP_DEBUG */ + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) { - splx(s); + crit_exit(); /* I made the same as TCP since we are not setup? */ return (ECONNRESET); } @@ -3807,7 +3756,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) /* Should I really unlock ? */ SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (EFAULT); } #ifdef INET6 @@ -3815,7 +3764,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) (addr->sa_family == AF_INET6)) { SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (EINVAL); } #endif /* INET6 */ @@ -3826,7 +3775,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) error = sctp_inpcb_bind(so, NULL, p); if (error) { SCTP_ASOC_CREATE_UNLOCK(inp); - splx(s); + crit_exit(); return (error); } SCTP_INP_WLOCK(inp); @@ -3835,7 +3784,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { /* We are already connected AND the TCP model */ - splx(s); + crit_exit(); SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return (EADDRINUSE); @@ -3859,14 +3808,14 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) /* Already have or am bring up an association */ SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_TCB_UNLOCK(stcb); - splx(s); + crit_exit(); return (EALREADY); } /* We are GOOD to go */ stcb = sctp_aloc_assoc(inp, addr, 1, &error, 0); if (stcb == NULL) { /* Gak! no memory */ - splx(s); + crit_exit(); return (error); } if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { @@ -3879,14 +3828,13 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p) sctp_send_initiate(inp, stcb); SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_TCB_UNLOCK(stcb); - splx(s); + crit_exit(); return error; } int sctp_usr_recvd(struct socket *so, int flags) { - int s; struct sctp_socket_q_list *sq=NULL; /* * The user has received some data, we may be able to stuff more @@ -3910,11 +3858,7 @@ sctp_usr_recvd(struct socket *so, int flags) #endif return (ECONNRESET); } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); /* * Grab the first one on the list. It will re-insert itself if * it runs out of room @@ -4023,7 +3967,7 @@ sctp_usr_recvd(struct socket *so, int flags) if (stcb) SCTP_TCB_UNLOCK(stcb); SCTP_INP_WUNLOCK(inp); - splx(s); + crit_exit(); return (0); } @@ -4042,17 +3986,13 @@ sctp_listen(struct socket *so, struct proc *p) * to the sys/kern/uipc_socket.c module to reverse this but this * MUST be in place if the socket API for SCTP is to work properly. */ -#if defined(__NetBSD__) || defined(__OpenBSD__) - int s = splsoftnet(); -#else - int s = splnet(); -#endif int error = 0; struct sctp_inpcb *inp; + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) { - splx(s); + crit_exit(); /* I made the same as TCP since we are not setup? */ return (ECONNRESET); } @@ -4060,7 +4000,7 @@ sctp_listen(struct socket *so, struct proc *p) if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { /* We are already connected AND the TCP model */ - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); return (EADDRINUSE); } @@ -4069,7 +4009,7 @@ sctp_listen(struct socket *so, struct proc *p) SCTP_INP_RUNLOCK(inp); if ((error = sctp_inpcb_bind(so, NULL, p))) { /* bind error, probably perm */ - splx(s); + crit_exit(); return (error); } } else { @@ -4100,7 +4040,7 @@ sctp_listen(struct socket *so, struct proc *p) } SCTP_INP_WUNLOCK(inp); SOCK_UNLOCK(so); - splx(s); + crit_exit(); return (error); } @@ -4112,31 +4052,27 @@ sctp_accept(struct socket *so, struct sockaddr **addr) sctp_accept(struct socket *so, struct mbuf *nam) { struct sockaddr *addr = mtod(nam, struct sockaddr *); -#endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - int s = splsoftnet(); -#else - int s = splnet(); #endif struct sctp_tcb *stcb; struct sockaddr *prim; struct sctp_inpcb *inp; + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) { - splx(s); + crit_exit(); return (ECONNRESET); } SCTP_INP_RLOCK(inp); if (so->so_state & SS_ISDISCONNECTED) { - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); return (ECONNABORTED); } stcb = LIST_FIRST(&inp->sctp_asoc_list); if (stcb == NULL) { - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); return (ECONNRESET); } @@ -4209,7 +4145,7 @@ sctp_accept(struct socket *so, struct mbuf *nam) } SCTP_INP_WUNLOCK(inp); - splx(s); + crit_exit(); return (0); } @@ -4225,7 +4161,6 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) #else struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *); #endif - int s; struct sctp_inpcb *inp; /* * Do the malloc first in case it blocks. @@ -4239,14 +4174,10 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) #endif sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (!inp) { - splx(s); + crit_exit(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) FREE(sin, M_SONAME); #endif @@ -4303,7 +4234,7 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) } } if (!fnd) { - splx(s); + crit_exit(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) FREE(sin, M_SONAME); #endif @@ -4312,7 +4243,7 @@ sctp_ingetaddr(struct socket *so, struct mbuf *nam) } } SCTP_INP_RUNLOCK(inp); - splx(s); + crit_exit(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) (*addr) = (struct sockaddr *)sin; #endif @@ -4329,7 +4260,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) { struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *); #endif - int s, fnd; + int fnd; struct sockaddr_in *sin_a; struct sctp_inpcb *inp; struct sctp_tcb *stcb; @@ -4342,11 +4273,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) /* UDP type and listeners will drop out here */ return (ENOTCONN); } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK | @@ -4361,7 +4288,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) /* We must recapture incase we blocked */ inp = (struct sctp_inpcb *)so->so_pcb; if (!inp) { - splx(s); + crit_exit(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) FREE(sin, M_SONAME); #endif @@ -4373,7 +4300,7 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) SCTP_TCB_LOCK(stcb); SCTP_INP_RUNLOCK(inp); if (stcb == NULL) { - splx(s); + crit_exit(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) FREE(sin, M_SONAME); #endif @@ -4392,13 +4319,13 @@ sctp_peeraddr(struct socket *so, struct mbuf *nam) SCTP_TCB_UNLOCK(stcb); if (!fnd) { /* No IPv4 address */ - splx(s); + crit_exit(); #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) FREE(sin, M_SONAME); #endif return ENOENT; } - splx(s); + crit_exit(); return (0); } @@ -4444,17 +4371,12 @@ sctp_usrreq(so, req, m, nam, control) { struct proc *p = curproc; #endif - int s; int error = 0; int family; family = so->so_proto->pr_domain->dom_family; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if (req == PRU_CONTROL) { switch (family) { case PF_INET: @@ -4474,7 +4396,7 @@ sctp_usrreq(so, req, m, nam, control) default: error = EAFNOSUPPORT; } - splx(s); + crit_exit(); return (error); } #ifdef __NetBSD__ @@ -4497,10 +4419,10 @@ sctp_usrreq(so, req, m, nam, control) break; #endif /* INET6 */ default: - splx(s); + crit_exit(); return (EAFNOSUPPORT); } - splx(s); + crit_exit(); return (0); } #endif @@ -4513,7 +4435,7 @@ sctp_usrreq(so, req, m, nam, control) break; case PRU_BIND: if (nam == NULL) { - splx(s); + crit_exit(); return (EINVAL); } error = sctp_bind(so, nam, p); @@ -4523,7 +4445,7 @@ sctp_usrreq(so, req, m, nam, control) break; case PRU_CONNECT: if (nam == NULL) { - splx(s); + crit_exit(); return (EINVAL); } error = sctp_connect(so, nam, p); @@ -4533,7 +4455,7 @@ sctp_usrreq(so, req, m, nam, control) break; case PRU_ACCEPT: if (nam == NULL) { - splx(s); + crit_exit(); return (EINVAL); } error = sctp_accept(so, nam); @@ -4594,7 +4516,7 @@ sctp_usrreq(so, req, m, nam, control) default: break; } - splx(s); + crit_exit(); return (error); } #endif diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 73dde75256..874ab2263e 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -1,5 +1,5 @@ /* $KAME: sctputil.c,v 1.36 2005/03/06 16:04:19 itojun Exp $ */ -/* $DragonFly: src/sys/netinet/sctputil.c,v 1.3 2005/07/15 15:15:27 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet/sctputil.c,v 1.4 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -64,6 +64,7 @@ #include #include #include +#include #if defined(__FreeBSD__) || defined(__DragonFly__) #include @@ -588,19 +589,14 @@ void sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb, void sctp_audit_log(u_int8_t ev, u_int8_t fd) { - int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_audit_data[sctp_audit_indx][0] = ev; sctp_audit_data[sctp_audit_indx][1] = fd; sctp_audit_indx++; if (sctp_audit_indx >= SCTP_AUDIT_SIZE) { sctp_audit_indx = 0; } - splx(s); + crit_exit(); } #endif @@ -914,7 +910,7 @@ sctp_timeout_handler(void *t) struct sctp_tcb *stcb; struct sctp_nets *net; struct sctp_timer *tmr; - int s, did_output, typ; + int did_output, typ; #if defined(__APPLE__) boolean_t funnel_state; @@ -922,11 +918,7 @@ sctp_timeout_handler(void *t) funnel_state = thread_funnel_set(network_flock, TRUE); #endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); tmr = (struct sctp_timer *)t; inp = (struct sctp_inpcb *)tmr->ep; stcb = (struct sctp_tcb *)tmr->tcb; @@ -946,7 +938,7 @@ sctp_timeout_handler(void *t) SCTP_INP_WLOCK(inp); if (inp->sctp_socket == 0) { - splx(s); + crit_exit(); #if defined(__APPLE__) /* release BSD kernel funnel/mutex */ (void) thread_funnel_set(network_flock, FALSE); @@ -956,7 +948,7 @@ sctp_timeout_handler(void *t) } if (stcb) { if (stcb->asoc.state == 0) { - splx(s); + crit_exit(); #if defined(__APPLE__) /* release BSD kernel funnel/mutex */ (void) thread_funnel_set(network_flock, FALSE); @@ -972,7 +964,7 @@ sctp_timeout_handler(void *t) #endif /* SCTP_DEBUG */ #ifndef __NetBSD__ if (!callout_active(&tmr->timer)) { - splx(s); + crit_exit(); #if defined(__APPLE__) /* release BSD kernel funnel/mutex */ (void) thread_funnel_set(network_flock, FALSE); @@ -1197,7 +1189,7 @@ sctp_timeout_handler(void *t) } #endif /* SCTP_DEBUG */ - splx(s); + crit_exit(); #if defined(__APPLE__) /* release BSD kernel funnel/mutex */ (void) thread_funnel_set(network_flock, FALSE); diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index 4a6536f107..c38ec7c55d 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -1,5 +1,5 @@ /* $KAME: sctp6_usrreq.c,v 1.35 2004/08/17 06:28:03 t-momose Exp $ */ -/* $DragonFly: src/sys/netinet6/sctp6_usrreq.c,v 1.3 2005/07/15 15:52:00 eirikn Exp $ */ +/* $DragonFly: src/sys/netinet6/sctp6_usrreq.c,v 1.4 2005/07/15 17:19:28 eirikn Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -200,7 +201,6 @@ sctp6_input(mp, offp, proto) u_int8_t ecn_bits; struct sctp_tcb *stcb = NULL; int off = *offp; - int s; ip6 = mtod(m, struct ip6_hdr *); #ifndef PULLDOWN_TEST @@ -341,12 +341,12 @@ sctp_skip_csum: struct m_tag *mtag; struct tdb_ident *tdbi; struct tdb *tdb; - int error, s; + int error; /* Find most recent IPsec tag */ i_inp = (struct inpcb *)in6p; mtag = m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL); - s = splnet(); + crit_enter(); if (mtag != NULL) { tdbi = (struct tdb_ident *)(mtag + 1); tdb = gettdb(tdbi->spi, &tdbi->dst, tdbi->proto); @@ -356,7 +356,7 @@ sctp_skip_csum: ipsp_spd_lookup(m, af, iphlen, &error, IPSP_DIRECTION_IN, tdb, i_inp); if (error) { - splx(s); + crit_exit(); goto bad; } @@ -368,7 +368,7 @@ sctp_skip_csum: i_inp->inp_ipo = ipsec_add_policy(i_inp, af, IPSP_DIRECTION_OUT); if (i_inp->inp_ipo == NULL) { - splx(s); + crit_exit(); goto bad; } } @@ -396,7 +396,7 @@ sctp_skip_csum: i_inp->inp_tdb_in = NULL; } } - splx(s); + crit_exit(); } #else if (ipsec6_in_reject_so(m, in6p->sctp_socket)) { @@ -439,15 +439,11 @@ sctp_skip_csum: length = ntohs(ip6->ip6_plen) + iphlen; offset -= sizeof(*ch); ecn_bits = ((ntohl(ip6->ip6_flow) >> 20) & 0x000000ff); -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); (void)sctp_common_input_processing(&m, iphlen, offset, length, sh, ch, in6p, stcb, net, ecn_bits); /* inp's ref-count reduced && stcb unlocked */ - splx(s); + crit_exit(); /* XXX this stuff below gets moved to appropriate parts later... */ if (m) m_freem(m); @@ -579,7 +575,7 @@ sctp6_ctlinput(cmd, pktdst, d) { struct sctphdr sh; struct ip6ctlparam *ip6cp = NULL; - int s, cm; + int cm; if (pktdst->sa_family != AF_INET6 || pktdst->sa_len != sizeof(struct sockaddr_in6)) @@ -630,11 +626,7 @@ sctp6_ctlinput(cmd, pktdst, d) final.sin6_addr = ((struct sockaddr_in6 *)pktdst)->sin6_addr; #endif /* __FreeBSD_cc_version */ final.sin6_port = sh.dest_port; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); stcb = sctp_findassociation_addr_sa((struct sockaddr *)ip6cp->ip6c_src, (struct sockaddr *)&final, &inp, &net, 1); @@ -677,7 +669,7 @@ sctp6_ctlinput(cmd, pktdst, d) if (stcb) SCTP_TCB_UNLOCK(stcb); } - splx(s); + crit_exit(); } } @@ -693,7 +685,7 @@ sctp6_getcred(SYSCTL_HANDLER_ARGS) struct sctp_inpcb *inp; struct sctp_nets *net; struct sctp_tcb *stcb; - int error, s; + int error; #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 error = suser(req->td); @@ -710,11 +702,7 @@ sctp6_getcred(SYSCTL_HANDLER_ARGS) error = SYSCTL_IN(req, addrs, sizeof(addrs)); if (error) return (error); -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); stcb = sctp_findassociation_addr_sa(sin6tosa(&addrs[0]), sin6tosa(&addrs[1]), @@ -732,8 +720,8 @@ sctp6_getcred(SYSCTL_HANDLER_ARGS) sizeof(struct ucred)); SCTP_TCB_UNLOCK (stcb); - out: - splx(s); +out: + crit_exit(); return (error); } @@ -748,19 +736,14 @@ static int sctp6_abort(struct socket *so) { struct sctp_inpcb *inp; - int s; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) return EINVAL; /* ??? possible? panic instead? */ soisdisconnected(so); -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); sctp_inpcb_free(inp, 1); - splx(s); + crit_exit(); return 0; } @@ -774,7 +757,7 @@ sctp6_attach(struct socket *so, int proto, struct proc *p) #endif { struct in6pcb *inp6; - int s, error; + int error; struct sctp_inpcb *inp; inp = (struct sctp_inpcb *)so->so_pcb; @@ -786,13 +769,9 @@ sctp6_attach(struct socket *so, int proto, struct proc *p) if (error) return error; } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); error = sctp_inpcb_alloc(so); - splx(s); + crit_exit(); if (error) return error; inp = (struct sctp_inpcb *)so->so_pcb; @@ -852,7 +831,7 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) #endif struct sctp_inpcb *inp; struct in6pcb *inp6; - int s, error; + int error; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) @@ -925,13 +904,9 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) inp->inp_vflag &= ~INP_IPV6; #endif #endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); error = sctp_inpcb_bind(so, (struct sockaddr *)&sin, p); - splx(s); + crit_exit(); return error; } } @@ -950,13 +925,9 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p) return EINVAL; } } -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); error = sctp_inpcb_bind(so, addr, p); - splx(s); + crit_exit(); return error; } @@ -965,22 +936,17 @@ static int sctp6_detach(struct socket *so) { struct sctp_inpcb *inp; - int s; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) return EINVAL; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || (so->so_rcv.sb_cc > 0)) sctp_inpcb_free(inp, 1); else sctp_inpcb_free(inp, 0); - splx(s); + crit_exit(); return 0; } @@ -988,22 +954,17 @@ static int sctp6_disconnect(struct socket *so) { struct sctp_inpcb *inp; - int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); /* XXX */ -#endif + crit_enter(); inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { - splx(s); + crit_exit(); return (ENOTCONN); } if (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { if (LIST_EMPTY(&inp->sctp_asoc_list)) { /* No connection */ - splx(s); + crit_exit(); return (ENOTCONN); } else { int some_on_streamwheel = 0; @@ -1012,7 +973,7 @@ sctp6_disconnect(struct socket *so) stcb = LIST_FIRST(&inp->sctp_asoc_list); if (stcb == NULL) { - splx(s); + crit_exit(); return (EINVAL); } asoc = &stcb->asoc; @@ -1068,12 +1029,12 @@ sctp6_disconnect(struct socket *so) */ asoc->state |= SCTP_STATE_SHUTDOWN_PENDING; } - splx(s); + crit_exit(); return (0); } } else { /* UDP model does not support this */ - splx(s); + crit_exit(); return EOPNOTSUPP; } } @@ -1248,11 +1209,6 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) { struct sockaddr *addr = mtod(nam, struct sockaddr *); #endif -#endif -#if defined(__NetBSD__) || defined(__OpenBSD__) - int s = splsoftnet(); -#else - int s = splnet(); #endif int error = 0; struct sctp_inpcb *inp; @@ -1263,10 +1219,11 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) struct sockaddr_storage ss; #endif /* INET */ + crit_enter(); inp6 = (struct in6pcb *)so->so_pcb; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == 0) { - splx(s); + crit_exit(); return (ECONNRESET); /* I made the same as TCP since * we are not setup? */ } @@ -1278,7 +1235,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) SCTP_INP_RUNLOCK(inp); error = sctp6_bind(so, NULL, p); if (error) { - splx(s); + crit_exit(); SCTP_ASOC_CREATE_UNLOCK(inp); return (error); @@ -1289,7 +1246,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED)) { /* We are already connected AND the TCP model */ - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return (EADDRINUSE); @@ -1311,13 +1268,13 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) * destined to a v4 addr or v4-mapped addr */ if (addr->sa_family == AF_INET) { - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return EINVAL; } if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return EINVAL; @@ -1331,7 +1288,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) addr = (struct sockaddr *)&ss; } else { /* mapped addresses aren't enabled */ - splx(s); + crit_exit(); SCTP_INP_RUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); return EINVAL; @@ -1363,7 +1320,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) /* Already have or am bring up an association */ SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_TCB_UNLOCK (stcb); - splx(s); + crit_exit(); return (EALREADY); } /* We are GOOD to go */ @@ -1371,7 +1328,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) SCTP_ASOC_CREATE_UNLOCK(inp); if (stcb == NULL) { /* Gak! no memory */ - splx(s); + crit_exit(); return (error); } if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) { @@ -1383,7 +1340,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p) SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); sctp_send_initiate(inp, stcb); SCTP_TCB_UNLOCK (stcb); - splx(s); + crit_exit(); return error; } @@ -1568,23 +1525,19 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam) struct sockaddr *addr = mtod(nam, struct sockaddr *); #endif struct in6pcb *inp6 = sotoin6pcb(so); - int error, s; + int error; if (inp6 == NULL) return EINVAL; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); /* allow v6 addresses precedence */ error = sctp6_getaddr(so, nam); if (error) { /* try v4 next if v6 failed */ error = sctp_ingetaddr(so, nam); if (error) { - splx(s); + crit_exit(); return (error); } #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) @@ -1616,7 +1569,7 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam) nam->m_len = sizeof(struct sockaddr_in6); #endif } - splx(s); + crit_exit(); return (error); } @@ -1632,23 +1585,19 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) struct sockaddr *addr = mtod(nam, struct sockaddr *); #endif struct in6pcb *inp6 = sotoin6pcb(so); - int error, s; + int error; if (inp6 == NULL) return EINVAL; -#if defined(__NetBSD__) || defined(__OpenBSD__) - s = splsoftnet(); -#else - s = splnet(); -#endif + crit_enter(); /* allow v6 addresses precedence */ error = sctp6_peeraddr(so, nam); if (error) { /* try v4 next if v6 failed */ error = sctp_peeraddr(so, nam); if (error) { - splx(s); + crit_exit(); return (error); } /* if I'm V6ONLY, convert it to v4-mapped */ @@ -1677,7 +1626,7 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam) nam->m_len = sizeof(struct sockaddr_in6); #endif } - splx(s); + crit_exit(); return error; } -- 2.41.0