Deleted Added
full compact
sctp_output.c (163953) sctp_output.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: sctp_output.c,v 1.46 2005/03/06 16:04:17 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: sctp_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 163953 2006-11-03 15:23:16Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 163996 2006-11-05 13:25:18Z rrs $");
35
36#include "opt_ipsec.h"
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_sctp.h"
41#include <sys/param.h>
42#include <sys/systm.h>

--- 4438 unchanged lines hidden (view full) ---

4481 ph = mtod(m, struct sctp_paramhdr *);
4482 ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
4483 ph->param_length = htons(m->m_pkthdr.len);
4484 }
4485 /*
4486 * We add one here to keep the assoc from
4487 * dis-appearing on us.
4488 */
35
36#include "opt_ipsec.h"
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_sctp.h"
41#include <sys/param.h>
42#include <sys/systm.h>

--- 4438 unchanged lines hidden (view full) ---

4481 ph = mtod(m, struct sctp_paramhdr *);
4482 ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
4483 ph->param_length = htons(m->m_pkthdr.len);
4484 }
4485 /*
4486 * We add one here to keep the assoc from
4487 * dis-appearing on us.
4488 */
4489 atomic_add_16(&stcb->asoc.refcnt, 1);
4489 atomic_add_int(&stcb->asoc.refcnt, 1);
4490 sctp_abort_an_association(inp, stcb,
4491 SCTP_RESPONSE_TO_USER_REQ,
4492 m);
4493 /*
4494 * sctp_abort_an_association calls sctp_free_asoc()
4495 * free association will NOT free it since we
4496 * incremented the refcnt .. we do this to prevent
4497 * it being freed and things getting tricky since we
4498 * could end up (from free_asoc) calling inpcb_free
4499 * which would get a recursive lock call to the
4500 * iterator lock.. But as a consequence of that the
4501 * stcb will return to us un-locked.. since
4502 * free_asoc returns with either no TCB or the TCB
4503 * unlocked, we must relock.. to unlock in the
4504 * iterator timer :-0
4505 */
4506 SCTP_TCB_LOCK(stcb);
4490 sctp_abort_an_association(inp, stcb,
4491 SCTP_RESPONSE_TO_USER_REQ,
4492 m);
4493 /*
4494 * sctp_abort_an_association calls sctp_free_asoc()
4495 * free association will NOT free it since we
4496 * incremented the refcnt .. we do this to prevent
4497 * it being freed and things getting tricky since we
4498 * could end up (from free_asoc) calling inpcb_free
4499 * which would get a recursive lock call to the
4500 * iterator lock.. But as a consequence of that the
4501 * stcb will return to us un-locked.. since
4502 * free_asoc returns with either no TCB or the TCB
4503 * unlocked, we must relock.. to unlock in the
4504 * iterator timer :-0
4505 */
4506 SCTP_TCB_LOCK(stcb);
4507 atomic_add_16(&stcb->asoc.refcnt, -1);
4507 atomic_add_int(&stcb->asoc.refcnt, -1);
4508 goto no_chunk_output;
4509 }
4510 } else {
4511 if (m) {
4512 ret = sctp_msg_append(stcb, stcb->asoc.primary_destination, m,
4513 &ca->sndrcv, 1);
4514 }
4515 asoc = &stcb->asoc;

--- 53 unchanged lines hidden (view full) ---

4569 asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
4570 }
4571 }
4572 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
4573 if (TAILQ_EMPTY(&asoc->send_queue) &&
4574 TAILQ_EMPTY(&asoc->sent_queue) &&
4575 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
4576 abort_anyway:
4508 goto no_chunk_output;
4509 }
4510 } else {
4511 if (m) {
4512 ret = sctp_msg_append(stcb, stcb->asoc.primary_destination, m,
4513 &ca->sndrcv, 1);
4514 }
4515 asoc = &stcb->asoc;

--- 53 unchanged lines hidden (view full) ---

4569 asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
4570 }
4571 }
4572 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
4573 if (TAILQ_EMPTY(&asoc->send_queue) &&
4574 TAILQ_EMPTY(&asoc->sent_queue) &&
4575 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
4576 abort_anyway:
4577 atomic_add_16(&stcb->asoc.refcnt, 1);
4577 atomic_add_int(&stcb->asoc.refcnt, 1);
4578 sctp_abort_an_association(stcb->sctp_ep, stcb,
4579 SCTP_RESPONSE_TO_USER_REQ,
4580 NULL);
4578 sctp_abort_an_association(stcb->sctp_ep, stcb,
4579 SCTP_RESPONSE_TO_USER_REQ,
4580 NULL);
4581 atomic_add_16(&stcb->asoc.refcnt, -1);
4581 atomic_add_int(&stcb->asoc.refcnt, -1);
4582 goto no_chunk_output;
4583 }
4584 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
4585 asoc->primary_destination);
4586 }
4587 }
4588
4589 }

--- 4971 unchanged lines hidden (view full) ---

9561 (stcb->asoc.chunks_on_out_queue >
9562 sctp_max_chunks_on_queue)) {
9563 error = EWOULDBLOCK;
9564 splx(s);
9565 goto out_unlocked;
9566 }
9567 }
9568 /* Keep the stcb from being freed under our feet */
4582 goto no_chunk_output;
4583 }
4584 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
4585 asoc->primary_destination);
4586 }
4587 }
4588
4589 }

--- 4971 unchanged lines hidden (view full) ---

9561 (stcb->asoc.chunks_on_out_queue >
9562 sctp_max_chunks_on_queue)) {
9563 error = EWOULDBLOCK;
9564 splx(s);
9565 goto out_unlocked;
9566 }
9567 }
9568 /* Keep the stcb from being freed under our feet */
9569 atomic_add_16(&stcb->asoc.refcnt, 1);
9569 atomic_add_int(&stcb->asoc.refcnt, 1);
9570 free_cnt_applied = 1;
9571
9572 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
9573 error = ECONNRESET;
9574 goto out_unlocked;
9575 }
9576 if (create_lock_applied) {
9577 SCTP_ASOC_CREATE_UNLOCK(inp);

--- 134 unchanged lines hidden (view full) ---

9712 } else {
9713 mm->m_next = top;
9714 }
9715 }
9716 if (hold_tcblock == 0) {
9717 SCTP_TCB_LOCK(stcb);
9718 hold_tcblock = 1;
9719 }
9570 free_cnt_applied = 1;
9571
9572 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
9573 error = ECONNRESET;
9574 goto out_unlocked;
9575 }
9576 if (create_lock_applied) {
9577 SCTP_ASOC_CREATE_UNLOCK(inp);

--- 134 unchanged lines hidden (view full) ---

9712 } else {
9713 mm->m_next = top;
9714 }
9715 }
9716 if (hold_tcblock == 0) {
9717 SCTP_TCB_LOCK(stcb);
9718 hold_tcblock = 1;
9719 }
9720 atomic_add_16(&stcb->asoc.refcnt, -1);
9720 atomic_add_int(&stcb->asoc.refcnt, -1);
9721 free_cnt_applied = 0;
9722 /* release this lock, otherwise we hang on ourselves */
9723 sctp_abort_an_association(stcb->sctp_ep, stcb,
9724 SCTP_RESPONSE_TO_USER_REQ,
9725 mm);
9726 /* now relock the stcb so everything is sane */
9727 hold_tcblock = 0;
9728 stcb = NULL;

--- 428 unchanged lines hidden (view full) ---

10157 }
10158 }
10159 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
10160 if (TAILQ_EMPTY(&asoc->send_queue) &&
10161 TAILQ_EMPTY(&asoc->sent_queue) &&
10162 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
10163 abort_anyway:
10164 if (free_cnt_applied) {
9721 free_cnt_applied = 0;
9722 /* release this lock, otherwise we hang on ourselves */
9723 sctp_abort_an_association(stcb->sctp_ep, stcb,
9724 SCTP_RESPONSE_TO_USER_REQ,
9725 mm);
9726 /* now relock the stcb so everything is sane */
9727 hold_tcblock = 0;
9728 stcb = NULL;

--- 428 unchanged lines hidden (view full) ---

10157 }
10158 }
10159 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
10160 if (TAILQ_EMPTY(&asoc->send_queue) &&
10161 TAILQ_EMPTY(&asoc->sent_queue) &&
10162 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
10163 abort_anyway:
10164 if (free_cnt_applied) {
10165 atomic_add_16(&stcb->asoc.refcnt, -1);
10165 atomic_add_int(&stcb->asoc.refcnt, -1);
10166 free_cnt_applied = 0;
10167 }
10168 sctp_abort_an_association(stcb->sctp_ep, stcb,
10169 SCTP_RESPONSE_TO_USER_REQ,
10170 NULL);
10171 /*
10172 * now relock the stcb so everything
10173 * is sane

--- 113 unchanged lines hidden (view full) ---

10287
10288 if (create_lock_applied) {
10289 SCTP_ASOC_CREATE_UNLOCK(inp);
10290 create_lock_applied = 0;
10291 }
10292 if ((stcb) && hold_tcblock) {
10293 SCTP_TCB_UNLOCK(stcb);
10294 }
10166 free_cnt_applied = 0;
10167 }
10168 sctp_abort_an_association(stcb->sctp_ep, stcb,
10169 SCTP_RESPONSE_TO_USER_REQ,
10170 NULL);
10171 /*
10172 * now relock the stcb so everything
10173 * is sane

--- 113 unchanged lines hidden (view full) ---

10287
10288 if (create_lock_applied) {
10289 SCTP_ASOC_CREATE_UNLOCK(inp);
10290 create_lock_applied = 0;
10291 }
10292 if ((stcb) && hold_tcblock) {
10293 SCTP_TCB_UNLOCK(stcb);
10294 }
10295 if ((stcb) && (free_cnt_applied)) {
10296 atomic_add_16(&stcb->asoc.refcnt, -1);
10295 if (stcb && free_cnt_applied) {
10296 atomic_add_int(&stcb->asoc.refcnt, -1);
10297 }
10298#ifdef INVARIENTS
10299 if (stcb) {
10300 if (mtx_owned(&stcb->tcb_mtx)) {
10301 panic("Leaving with tcb mtx owned?");
10302 }
10303 if (mtx_owned(&stcb->tcb_send_mtx)) {
10304 panic("Leaving with tcb send mtx owned?");

--- 74 unchanged lines hidden ---
10297 }
10298#ifdef INVARIENTS
10299 if (stcb) {
10300 if (mtx_owned(&stcb->tcb_mtx)) {
10301 panic("Leaving with tcb mtx owned?");
10302 }
10303 if (mtx_owned(&stcb->tcb_send_mtx)) {
10304 panic("Leaving with tcb send mtx owned?");

--- 74 unchanged lines hidden ---