Deleted Added
full compact
sctp_output.c (234995) sctp_output.c (235360)
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

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

28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/* $KAME: sctp_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

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

28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/* $KAME: sctp_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 234995 2012-05-04 09:27:00Z tuexen $");
36__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 235360 2012-05-12 20:11:35Z tuexen $");
37
38#include <netinet/sctp_os.h>
39#include <sys/proc.h>
40#include <netinet/sctp_var.h>
41#include <netinet/sctp_sysctl.h>
42#include <netinet/sctp_header.h>
43#include <netinet/sctp_pcb.h>
44#include <netinet/sctputil.h>

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

6568 ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
6569 ph->param_length = htons(ca->sndlen);
6570 }
6571 /*
6572 * We add one here to keep the assoc from
6573 * dis-appearing on us.
6574 */
6575 atomic_add_int(&stcb->asoc.refcnt, 1);
37
38#include <netinet/sctp_os.h>
39#include <sys/proc.h>
40#include <netinet/sctp_var.h>
41#include <netinet/sctp_sysctl.h>
42#include <netinet/sctp_header.h>
43#include <netinet/sctp_pcb.h>
44#include <netinet/sctputil.h>

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

6568 ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
6569 ph->param_length = htons(ca->sndlen);
6570 }
6571 /*
6572 * We add one here to keep the assoc from
6573 * dis-appearing on us.
6574 */
6575 atomic_add_int(&stcb->asoc.refcnt, 1);
6576 sctp_abort_an_association(inp, stcb,
6577 SCTP_RESPONSE_TO_USER_REQ,
6578 m, SCTP_SO_NOT_LOCKED);
6576 sctp_abort_an_association(inp, stcb, m, SCTP_SO_NOT_LOCKED);
6579 /*
6580 * sctp_abort_an_association calls sctp_free_asoc()
6581 * free association will NOT free it since we
6582 * incremented the refcnt .. we do this to prevent
6583 * it being freed and things getting tricky since we
6584 * could end up (from free_asoc) calling inpcb_free
6585 * which would get a recursive lock call to the
6586 * iterator lock.. But as a consequence of that the

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

6664 }
6665 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
6666 if (TAILQ_EMPTY(&asoc->send_queue) &&
6667 TAILQ_EMPTY(&asoc->sent_queue) &&
6668 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
6669 abort_anyway:
6670 atomic_add_int(&stcb->asoc.refcnt, 1);
6671 sctp_abort_an_association(stcb->sctp_ep, stcb,
6577 /*
6578 * sctp_abort_an_association calls sctp_free_asoc()
6579 * free association will NOT free it since we
6580 * incremented the refcnt .. we do this to prevent
6581 * it being freed and things getting tricky since we
6582 * could end up (from free_asoc) calling inpcb_free
6583 * which would get a recursive lock call to the
6584 * iterator lock.. But as a consequence of that the

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

6662 }
6663 asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
6664 if (TAILQ_EMPTY(&asoc->send_queue) &&
6665 TAILQ_EMPTY(&asoc->sent_queue) &&
6666 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
6667 abort_anyway:
6668 atomic_add_int(&stcb->asoc.refcnt, 1);
6669 sctp_abort_an_association(stcb->sctp_ep, stcb,
6672 SCTP_RESPONSE_TO_USER_REQ,
6673 NULL, SCTP_SO_NOT_LOCKED);
6674 atomic_add_int(&stcb->asoc.refcnt, -1);
6675 goto no_chunk_output;
6676 }
6677 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
6678 asoc->primary_destination);
6679 }
6680 }

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

9499 }
9500 if ((SCTP_BASE_SYSCTL(sctp_max_retran_chunk)) &&
9501 (chk->snd_count >= SCTP_BASE_SYSCTL(sctp_max_retran_chunk))) {
9502 /* Gak, we have exceeded max unlucky retran, abort! */
9503 SCTP_PRINTF("Gak, chk->snd_count:%d >= max:%d - send abort\n",
9504 chk->snd_count,
9505 SCTP_BASE_SYSCTL(sctp_max_retran_chunk));
9506 atomic_add_int(&stcb->asoc.refcnt, 1);
6670 NULL, SCTP_SO_NOT_LOCKED);
6671 atomic_add_int(&stcb->asoc.refcnt, -1);
6672 goto no_chunk_output;
6673 }
6674 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
6675 asoc->primary_destination);
6676 }
6677 }

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

9496 }
9497 if ((SCTP_BASE_SYSCTL(sctp_max_retran_chunk)) &&
9498 (chk->snd_count >= SCTP_BASE_SYSCTL(sctp_max_retran_chunk))) {
9499 /* Gak, we have exceeded max unlucky retran, abort! */
9500 SCTP_PRINTF("Gak, chk->snd_count:%d >= max:%d - send abort\n",
9501 chk->snd_count,
9502 SCTP_BASE_SYSCTL(sctp_max_retran_chunk));
9503 atomic_add_int(&stcb->asoc.refcnt, 1);
9507 sctp_abort_an_association(stcb->sctp_ep, stcb, 0, NULL, so_locked);
9504 sctp_abort_an_association(stcb->sctp_ep, stcb, NULL, so_locked);
9508 SCTP_TCB_LOCK(stcb);
9509 atomic_subtract_int(&stcb->asoc.refcnt, 1);
9510 return (SCTP_RETRAN_EXIT);
9511 }
9512 /* pick up the net */
9513 net = chk->whoTo;
9514 switch (net->ro._l_addr.sa.sa_family) {
9515#ifdef INET

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

13133 }
13134 }
13135 if (hold_tcblock == 0) {
13136 SCTP_TCB_LOCK(stcb);
13137 }
13138 atomic_add_int(&stcb->asoc.refcnt, -1);
13139 free_cnt_applied = 0;
13140 /* release this lock, otherwise we hang on ourselves */
9505 SCTP_TCB_LOCK(stcb);
9506 atomic_subtract_int(&stcb->asoc.refcnt, 1);
9507 return (SCTP_RETRAN_EXIT);
9508 }
9509 /* pick up the net */
9510 net = chk->whoTo;
9511 switch (net->ro._l_addr.sa.sa_family) {
9512#ifdef INET

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

13130 }
13131 }
13132 if (hold_tcblock == 0) {
13133 SCTP_TCB_LOCK(stcb);
13134 }
13135 atomic_add_int(&stcb->asoc.refcnt, -1);
13136 free_cnt_applied = 0;
13137 /* release this lock, otherwise we hang on ourselves */
13141 sctp_abort_an_association(stcb->sctp_ep, stcb,
13142 SCTP_RESPONSE_TO_USER_REQ,
13143 mm, SCTP_SO_LOCKED);
13138 sctp_abort_an_association(stcb->sctp_ep, stcb, mm, SCTP_SO_LOCKED);
13144 /* now relock the stcb so everything is sane */
13145 hold_tcblock = 0;
13146 stcb = NULL;
13147 /*
13148 * In this case top is already chained to mm avoid double
13149 * free, since we free it below if top != NULL and driver
13150 * would free it after sending the packet out
13151 */

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

13690 TAILQ_EMPTY(&asoc->sent_queue) &&
13691 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
13692 abort_anyway:
13693 if (free_cnt_applied) {
13694 atomic_add_int(&stcb->asoc.refcnt, -1);
13695 free_cnt_applied = 0;
13696 }
13697 sctp_abort_an_association(stcb->sctp_ep, stcb,
13139 /* now relock the stcb so everything is sane */
13140 hold_tcblock = 0;
13141 stcb = NULL;
13142 /*
13143 * In this case top is already chained to mm avoid double
13144 * free, since we free it below if top != NULL and driver
13145 * would free it after sending the packet out
13146 */

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

13685 TAILQ_EMPTY(&asoc->sent_queue) &&
13686 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
13687 abort_anyway:
13688 if (free_cnt_applied) {
13689 atomic_add_int(&stcb->asoc.refcnt, -1);
13690 free_cnt_applied = 0;
13691 }
13692 sctp_abort_an_association(stcb->sctp_ep, stcb,
13698 SCTP_RESPONSE_TO_USER_REQ,
13699 NULL, SCTP_SO_LOCKED);
13700 /*
13701 * now relock the stcb so everything
13702 * is sane
13703 */
13704 hold_tcblock = 0;
13705 stcb = NULL;
13706 goto out;

--- 294 unchanged lines hidden ---
13693 NULL, SCTP_SO_LOCKED);
13694 /*
13695 * now relock the stcb so everything
13696 * is sane
13697 */
13698 hold_tcblock = 0;
13699 stcb = NULL;
13700 goto out;

--- 294 unchanged lines hidden ---