sctputil.c (163964) | sctputil.c (163996) |
---|---|
1/*- 2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 17 unchanged lines hidden (view full) --- 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* $KAME: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 17 unchanged lines hidden (view full) --- 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* $KAME: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 163964 2006-11-03 23:04:34Z rrs $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 163996 2006-11-05 13:25:18Z rrs $"); |
35 36 37#include "opt_ipsec.h" 38#include "opt_compat.h" 39#include "opt_inet6.h" 40#include "opt_inet.h" 41#include "opt_sctp.h" 42 --- 116 unchanged lines hidden (view full) --- 159 struct sctp_tcb *stcb, int from, int incr) 160{ 161 int sctp_cwnd_log_at; 162 163 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 164 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 165 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 166 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_SB; | 35 36 37#include "opt_ipsec.h" 38#include "opt_compat.h" 39#include "opt_inet6.h" 40#include "opt_inet.h" 41#include "opt_sctp.h" 42 --- 116 unchanged lines hidden (view full) --- 159 struct sctp_tcb *stcb, int from, int incr) 160{ 161 int sctp_cwnd_log_at; 162 163 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 164 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 165 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 166 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_SB; |
167 sctp_clog[sctp_cwnd_log_at].x.sb.stcb = (uint32_t) stcb; | 167 sctp_clog[sctp_cwnd_log_at].x.sb.stcb = stcb; |
168 sctp_clog[sctp_cwnd_log_at].x.sb.so_sbcc = sb->sb_cc; 169 if (stcb) 170 sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = stcb->asoc.sb_cc; 171 else 172 sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = 0; 173 sctp_clog[sctp_cwnd_log_at].x.sb.incr = incr; 174} 175 176void 177sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc) 178{ 179 int sctp_cwnd_log_at; 180 181 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 182 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 183 sctp_clog[sctp_cwnd_log_at].from = 0; 184 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_CLOSE; | 168 sctp_clog[sctp_cwnd_log_at].x.sb.so_sbcc = sb->sb_cc; 169 if (stcb) 170 sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = stcb->asoc.sb_cc; 171 else 172 sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = 0; 173 sctp_clog[sctp_cwnd_log_at].x.sb.incr = incr; 174} 175 176void 177sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc) 178{ 179 int sctp_cwnd_log_at; 180 181 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 182 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 183 sctp_clog[sctp_cwnd_log_at].from = 0; 184 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_CLOSE; |
185 sctp_clog[sctp_cwnd_log_at].x.close.inp = (uint32_t) inp; | 185 sctp_clog[sctp_cwnd_log_at].x.close.inp = (void *)inp; |
186 sctp_clog[sctp_cwnd_log_at].x.close.sctp_flags = inp->sctp_flags; 187 if (stcb) { | 186 sctp_clog[sctp_cwnd_log_at].x.close.sctp_flags = inp->sctp_flags; 187 if (stcb) { |
188 sctp_clog[sctp_cwnd_log_at].x.close.stcb = (uint32_t) stcb; | 188 sctp_clog[sctp_cwnd_log_at].x.close.stcb = (void *)stcb; |
189 sctp_clog[sctp_cwnd_log_at].x.close.state = (uint16_t) stcb->asoc.state; 190 } else { 191 sctp_clog[sctp_cwnd_log_at].x.close.stcb = 0; 192 sctp_clog[sctp_cwnd_log_at].x.close.state = 0; 193 } 194 sctp_clog[sctp_cwnd_log_at].x.close.loc = loc; 195} 196 197 198void 199rto_logging(struct sctp_nets *net, int from) 200{ 201 int sctp_cwnd_log_at; 202 203 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 204 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 205 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 206 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_RTT; | 189 sctp_clog[sctp_cwnd_log_at].x.close.state = (uint16_t) stcb->asoc.state; 190 } else { 191 sctp_clog[sctp_cwnd_log_at].x.close.stcb = 0; 192 sctp_clog[sctp_cwnd_log_at].x.close.state = 0; 193 } 194 sctp_clog[sctp_cwnd_log_at].x.close.loc = loc; 195} 196 197 198void 199rto_logging(struct sctp_nets *net, int from) 200{ 201 int sctp_cwnd_log_at; 202 203 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 204 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 205 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 206 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_RTT; |
207 sctp_clog[sctp_cwnd_log_at].x.rto.net = (uint32_t) net; | 207 sctp_clog[sctp_cwnd_log_at].x.rto.net = (void *)net; |
208 sctp_clog[sctp_cwnd_log_at].x.rto.rtt = net->prev_rtt; 209 sctp_clog[sctp_cwnd_log_at].x.rto.rttvar = net->rtt_variance; 210 sctp_clog[sctp_cwnd_log_at].x.rto.direction = net->rto_variance_dir; 211} 212 213void 214sctp_log_strm_del_alt(uint32_t tsn, uint16_t sseq, int from) 215{ --- 13 unchanged lines hidden (view full) --- 229sctp_log_nagle_event(struct sctp_tcb *stcb, int action) 230{ 231 int sctp_cwnd_log_at; 232 233 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 234 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 235 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) action; 236 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_NAGLE; | 208 sctp_clog[sctp_cwnd_log_at].x.rto.rtt = net->prev_rtt; 209 sctp_clog[sctp_cwnd_log_at].x.rto.rttvar = net->rtt_variance; 210 sctp_clog[sctp_cwnd_log_at].x.rto.direction = net->rto_variance_dir; 211} 212 213void 214sctp_log_strm_del_alt(uint32_t tsn, uint16_t sseq, int from) 215{ --- 13 unchanged lines hidden (view full) --- 229sctp_log_nagle_event(struct sctp_tcb *stcb, int action) 230{ 231 int sctp_cwnd_log_at; 232 233 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 234 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 235 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) action; 236 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_NAGLE; |
237 sctp_clog[sctp_cwnd_log_at].x.nagle.stcb = (uint32_t) stcb; | 237 sctp_clog[sctp_cwnd_log_at].x.nagle.stcb = (void *)stcb; |
238 sctp_clog[sctp_cwnd_log_at].x.nagle.total_flight = stcb->asoc.total_flight; 239 sctp_clog[sctp_cwnd_log_at].x.nagle.total_in_queue = stcb->asoc.total_output_queue_size; 240 sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue; 241 sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_flight = stcb->asoc.total_flight_count; 242} 243 244 245void --- 126 unchanged lines hidden (view full) --- 372sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from) 373{ 374 int sctp_cwnd_log_at; 375 376 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 377 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 378 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 379 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_LOCK_EVENT; | 238 sctp_clog[sctp_cwnd_log_at].x.nagle.total_flight = stcb->asoc.total_flight; 239 sctp_clog[sctp_cwnd_log_at].x.nagle.total_in_queue = stcb->asoc.total_output_queue_size; 240 sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue; 241 sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_flight = stcb->asoc.total_flight_count; 242} 243 244 245void --- 126 unchanged lines hidden (view full) --- 372sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from) 373{ 374 int sctp_cwnd_log_at; 375 376 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 377 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 378 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 379 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_LOCK_EVENT; |
380 sctp_clog[sctp_cwnd_log_at].x.lock.sock = (uint32_t) inp->sctp_socket; 381 sctp_clog[sctp_cwnd_log_at].x.lock.inp = (uint32_t) inp; | 380 sctp_clog[sctp_cwnd_log_at].x.lock.sock = (void *)inp->sctp_socket; 381 sctp_clog[sctp_cwnd_log_at].x.lock.inp = (void *)inp; |
382 if (stcb) { 383 sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx); 384 } else { 385 sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = SCTP_LOCK_UNKNOWN; 386 } 387 if (inp) { 388 sctp_clog[sctp_cwnd_log_at].x.lock.inp_lock = mtx_owned(&inp->inp_mtx); 389 sctp_clog[sctp_cwnd_log_at].x.lock.create_lock = mtx_owned(&inp->inp_create_mtx); --- 100 unchanged lines hidden (view full) --- 490sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t cumtsn, uint32_t wake_cnt, int from) 491{ 492 int sctp_cwnd_log_at; 493 494 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 495 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 496 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 497 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_WAKE; | 382 if (stcb) { 383 sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx); 384 } else { 385 sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = SCTP_LOCK_UNKNOWN; 386 } 387 if (inp) { 388 sctp_clog[sctp_cwnd_log_at].x.lock.inp_lock = mtx_owned(&inp->inp_mtx); 389 sctp_clog[sctp_cwnd_log_at].x.lock.create_lock = mtx_owned(&inp->inp_create_mtx); --- 100 unchanged lines hidden (view full) --- 490sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t cumtsn, uint32_t wake_cnt, int from) 491{ 492 int sctp_cwnd_log_at; 493 494 SCTP_STATLOG_GETREF(sctp_cwnd_log_at); 495 sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event(); 496 sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from; 497 sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_WAKE; |
498 sctp_clog[sctp_cwnd_log_at].x.wake.stcb = (uint32_t) stcb; | 498 sctp_clog[sctp_cwnd_log_at].x.wake.stcb = (void *)stcb; |
499 sctp_clog[sctp_cwnd_log_at].x.wake.wake_cnt = wake_cnt; 500 sctp_clog[sctp_cwnd_log_at].x.wake.flight = stcb->asoc.total_flight_count; 501 sctp_clog[sctp_cwnd_log_at].x.wake.send_q = stcb->asoc.send_queue_cnt; 502 sctp_clog[sctp_cwnd_log_at].x.wake.sent_q = stcb->asoc.sent_queue_cnt; 503 504 if (stcb->asoc.stream_queue_cnt < 0xff) 505 sctp_clog[sctp_cwnd_log_at].x.wake.stream_qcnt = (uint8_t) stcb->asoc.stream_queue_cnt; 506 else --- 797 unchanged lines hidden (view full) --- 1304 if (!callout_active(&tmr->timer)) { 1305 splx(s); 1306 if (inp) { 1307 SCTP_INP_DECR_REF(inp); 1308 } 1309 return; 1310 } 1311 if (stcb) { | 499 sctp_clog[sctp_cwnd_log_at].x.wake.wake_cnt = wake_cnt; 500 sctp_clog[sctp_cwnd_log_at].x.wake.flight = stcb->asoc.total_flight_count; 501 sctp_clog[sctp_cwnd_log_at].x.wake.send_q = stcb->asoc.send_queue_cnt; 502 sctp_clog[sctp_cwnd_log_at].x.wake.sent_q = stcb->asoc.sent_queue_cnt; 503 504 if (stcb->asoc.stream_queue_cnt < 0xff) 505 sctp_clog[sctp_cwnd_log_at].x.wake.stream_qcnt = (uint8_t) stcb->asoc.stream_queue_cnt; 506 else --- 797 unchanged lines hidden (view full) --- 1304 if (!callout_active(&tmr->timer)) { 1305 splx(s); 1306 if (inp) { 1307 SCTP_INP_DECR_REF(inp); 1308 } 1309 return; 1310 } 1311 if (stcb) { |
1312 atomic_add_16(&stcb->asoc.refcnt, 1); | 1312 atomic_add_int(&stcb->asoc.refcnt, 1); |
1313 SCTP_TCB_LOCK(stcb); | 1313 SCTP_TCB_LOCK(stcb); |
1314 atomic_add_16(&stcb->asoc.refcnt, -1); | 1314 atomic_add_int(&stcb->asoc.refcnt, -1); |
1315 } 1316 /* mark as being serviced now */ 1317 callout_deactivate(&tmr->timer); 1318 1319 /* call the handler for the appropriate timer type */ 1320 switch (tmr->type) { 1321 case SCTP_TIMER_TYPE_ADDR_WQ: 1322 sctp_handle_addr_wq(); --- 1675 unchanged lines hidden (view full) --- 2998 } else { 2999 /* Hmm .. should not happen */ 3000 control->end_added = 1; 3001 stcb->asoc.control_pdapi = NULL; 3002 goto add_to_end; 3003 } 3004 if (no_lock == 0) 3005 SCTP_INP_READ_UNLOCK(stcb->sctp_ep); | 1315 } 1316 /* mark as being serviced now */ 1317 callout_deactivate(&tmr->timer); 1318 1319 /* call the handler for the appropriate timer type */ 1320 switch (tmr->type) { 1321 case SCTP_TIMER_TYPE_ADDR_WQ: 1322 sctp_handle_addr_wq(); --- 1675 unchanged lines hidden (view full) --- 2998 } else { 2999 /* Hmm .. should not happen */ 3000 control->end_added = 1; 3001 stcb->asoc.control_pdapi = NULL; 3002 goto add_to_end; 3003 } 3004 if (no_lock == 0) 3005 SCTP_INP_READ_UNLOCK(stcb->sctp_ep); |
3006 sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); |
|
3006 } else { 3007 /* append to socket */ 3008add_to_end: 3009 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, 3010 0, 0, 0, 0, 0, 0, 3011 m_notify); 3012 if (control == NULL) { 3013 /* no memory */ --- 1179 unchanged lines hidden (view full) --- 4193 4194 4195static void 4196sctp_user_rcvd(struct sctp_tcb *stcb, int *freed_so_far, int hold_rlock, 4197 uint32_t rwnd_req) 4198{ 4199 /* User pulled some data, do we need a rwnd update? */ 4200 int r_unlocked = 0; | 3007 } else { 3008 /* append to socket */ 3009add_to_end: 3010 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, 3011 0, 0, 0, 0, 0, 0, 3012 m_notify); 3013 if (control == NULL) { 3014 /* no memory */ --- 1179 unchanged lines hidden (view full) --- 4194 4195 4196static void 4197sctp_user_rcvd(struct sctp_tcb *stcb, int *freed_so_far, int hold_rlock, 4198 uint32_t rwnd_req) 4199{ 4200 /* User pulled some data, do we need a rwnd update? */ 4201 int r_unlocked = 0; |
4201 int tcb_incr_up = 0; | |
4202 uint32_t dif, rwnd; 4203 struct socket *so = NULL; 4204 4205 if (stcb == NULL) 4206 return; 4207 | 4202 uint32_t dif, rwnd; 4203 struct socket *so = NULL; 4204 4205 if (stcb == NULL) 4206 return; 4207 |
4208 atomic_add_16(&stcb->asoc.refcnt, 1); 4209 tcb_incr_up = 1; | 4208 atomic_add_int(&stcb->asoc.refcnt, 1); |
4210 4211 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { 4212 /* Pre-check If we are freeing no update */ 4213 goto no_lock; 4214 } 4215 SCTP_INP_INCR_REF(stcb->sctp_ep); 4216 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || 4217 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { --- 68 unchanged lines hidden (view full) --- 4286 } 4287out: 4288 if (so && r_unlocked && hold_rlock) { 4289 SCTP_STAT_INCR(sctps_locks_in_rcv); 4290 SCTP_INP_READ_LOCK(stcb->sctp_ep); 4291 } 4292 SCTP_INP_DECR_REF(stcb->sctp_ep); 4293no_lock: | 4209 4210 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { 4211 /* Pre-check If we are freeing no update */ 4212 goto no_lock; 4213 } 4214 SCTP_INP_INCR_REF(stcb->sctp_ep); 4215 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || 4216 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { --- 68 unchanged lines hidden (view full) --- 4285 } 4286out: 4287 if (so && r_unlocked && hold_rlock) { 4288 SCTP_STAT_INCR(sctps_locks_in_rcv); 4289 SCTP_INP_READ_LOCK(stcb->sctp_ep); 4290 } 4291 SCTP_INP_DECR_REF(stcb->sctp_ep); 4292no_lock: |
4294 if (tcb_incr_up) { 4295 atomic_add_16(&stcb->asoc.refcnt, -1); 4296 } | 4293 atomic_add_int(&stcb->asoc.refcnt, -1); |
4297 return; 4298} 4299 4300int 4301sctp_sorecvmsg(struct socket *so, 4302 struct uio *uio, 4303 struct mbuf **mp, 4304 struct sockaddr *from, --- 261 unchanged lines hidden (view full) --- 4566 if (hold_sblock) { 4567 SOCKBUF_UNLOCK(&so->so_rcv); 4568 hold_sblock = 0; 4569 } 4570 stcb = control->stcb; 4571 if (stcb) { 4572 if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) && 4573 (control->do_not_ref_stcb == 0)) { | 4294 return; 4295} 4296 4297int 4298sctp_sorecvmsg(struct socket *so, 4299 struct uio *uio, 4300 struct mbuf **mp, 4301 struct sockaddr *from, --- 261 unchanged lines hidden (view full) --- 4563 if (hold_sblock) { 4564 SOCKBUF_UNLOCK(&so->so_rcv); 4565 hold_sblock = 0; 4566 } 4567 stcb = control->stcb; 4568 if (stcb) { 4569 if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) && 4570 (control->do_not_ref_stcb == 0)) { |
4574 stcb = NULL; | 4571 if (freecnt_applied == 0) 4572 stcb = NULL; |
4575 } else if (control->do_not_ref_stcb == 0) { 4576 /* you can't free it on me please */ 4577 /* 4578 * The lock on the socket buffer protects us so the 4579 * free code will stop. But since we used the 4580 * socketbuf lock and the sender uses the tcb_lock 4581 * to increment, we need to use the atomic add to 4582 * the refcnt 4583 */ | 4573 } else if (control->do_not_ref_stcb == 0) { 4574 /* you can't free it on me please */ 4575 /* 4576 * The lock on the socket buffer protects us so the 4577 * free code will stop. But since we used the 4578 * socketbuf lock and the sender uses the tcb_lock 4579 * to increment, we need to use the atomic add to 4580 * the refcnt 4581 */ |
4584 atomic_add_16(&stcb->asoc.refcnt, 1); | 4582 atomic_add_int(&stcb->asoc.refcnt, 1); |
4585 freecnt_applied = 1; 4586 /* 4587 * Setup to remember how much we have not yet told 4588 * the peer our rwnd has opened up. Note we grab the 4589 * value from the tcb from last time. Note too that 4590 * sack sending clears this when a sack is sent.. 4591 * which is fine. Once we hit the rwnd_req, we then 4592 * will go to the sctp_user_rcvd() that will not --- 445 unchanged lines hidden (view full) --- 5038 } 5039 if (so->so_rcv.sb_cc > held_length) { 5040 SCTP_STAT_INCR(sctps_locks_in_rcvf); 5041 control->held_length = so->so_rcv.sb_cc; 5042 held_length = 0; 5043 } 5044 goto wait_some_more; 5045 } else if (control->data == NULL) { | 4583 freecnt_applied = 1; 4584 /* 4585 * Setup to remember how much we have not yet told 4586 * the peer our rwnd has opened up. Note we grab the 4587 * value from the tcb from last time. Note too that 4588 * sack sending clears this when a sack is sent.. 4589 * which is fine. Once we hit the rwnd_req, we then 4590 * will go to the sctp_user_rcvd() that will not --- 445 unchanged lines hidden (view full) --- 5036 } 5037 if (so->so_rcv.sb_cc > held_length) { 5038 SCTP_STAT_INCR(sctps_locks_in_rcvf); 5039 control->held_length = so->so_rcv.sb_cc; 5040 held_length = 0; 5041 } 5042 goto wait_some_more; 5043 } else if (control->data == NULL) { |
5046 panic("Impossible data==NULL length !=0"); | 5044 /* 5045 * we must re-sync since data is probably being 5046 * added 5047 */ 5048 SCTP_INP_READ_LOCK(inp); 5049 if ((control->length > 0) && (control->data == NULL)) { 5050 /* 5051 * big trouble.. we have the lock and its 5052 * corrupt? 5053 */ 5054 panic("Impossible data==NULL length !=0"); 5055 } 5056 SCTP_INP_READ_UNLOCK(inp); 5057 /* We will fall around to get more data */ |
5047 } 5048 goto get_more_data; 5049 } else { 5050 /* copy out the mbuf chain */ 5051get_more_data2: 5052 /* 5053 * Do we have a uio, I doubt it if so we grab the size from 5054 * it, if not you get it all --- 217 unchanged lines hidden (view full) --- 5272 if (hold_rlock == 1) { 5273 SCTP_INP_READ_UNLOCK(inp); 5274 hold_rlock = 0; 5275 } 5276 if (hold_sblock) { 5277 SOCKBUF_UNLOCK(&so->so_rcv); 5278 hold_sblock = 0; 5279 } | 5058 } 5059 goto get_more_data; 5060 } else { 5061 /* copy out the mbuf chain */ 5062get_more_data2: 5063 /* 5064 * Do we have a uio, I doubt it if so we grab the size from 5065 * it, if not you get it all --- 217 unchanged lines hidden (view full) --- 5283 if (hold_rlock == 1) { 5284 SCTP_INP_READ_UNLOCK(inp); 5285 hold_rlock = 0; 5286 } 5287 if (hold_sblock) { 5288 SOCKBUF_UNLOCK(&so->so_rcv); 5289 hold_sblock = 0; 5290 } |
5280 if ((stcb) && freecnt_applied) { | 5291 if (freecnt_applied) { |
5281 /* 5282 * The lock on the socket buffer protects us so the free 5283 * code will stop. But since we used the socketbuf lock and 5284 * the sender uses the tcb_lock to increment, we need to use 5285 * the atomic add to the refcnt. 5286 */ | 5292 /* 5293 * The lock on the socket buffer protects us so the free 5294 * code will stop. But since we used the socketbuf lock and 5295 * the sender uses the tcb_lock to increment, we need to use 5296 * the atomic add to the refcnt. 5297 */ |
5287 atomic_add_16(&stcb->asoc.refcnt, -1); | 5298 if (stcb == NULL) { 5299 panic("stcb for refcnt has gone NULL?"); 5300 } 5301 atomic_add_int(&stcb->asoc.refcnt, -1); |
5288 freecnt_applied = 0; 5289 /* Save the value back for next time */ 5290 stcb->freed_by_sorcv_sincelast = freed_so_far; 5291 } 5292 splx(s); 5293#ifdef SCTP_RECV_RWND_LOGGING 5294 if (stcb) { 5295 sctp_misc_ints(SCTP_SORECV_DONE, --- 95 unchanged lines hidden --- | 5302 freecnt_applied = 0; 5303 /* Save the value back for next time */ 5304 stcb->freed_by_sorcv_sincelast = freed_so_far; 5305 } 5306 splx(s); 5307#ifdef SCTP_RECV_RWND_LOGGING 5308 if (stcb) { 5309 sctp_misc_ints(SCTP_SORECV_DONE, --- 95 unchanged lines hidden --- |