Deleted Added
full compact
sctp_input.c (235414) sctp_input.c (235416)
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_input.c,v 1.27 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_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 235414 2012-05-13 17:36:04Z tuexen $");
36__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 235416 2012-05-13 19:32:49Z tuexen $");
37
38#include <netinet/sctp_os.h>
39#include <netinet/sctp_var.h>
40#include <netinet/sctp_sysctl.h>
41#include <netinet/sctp_pcb.h>
42#include <netinet/sctp_header.h>
43#include <netinet/sctputil.h>
44#include <netinet/sctp_output.h>

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

295 /* abandon the upper streams */
296 newcnt = ntohs(init->num_inbound_streams);
297 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
298 if (chk->rec.data.stream_number >= newcnt) {
299 TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next);
300 asoc->send_queue_cnt--;
301 if (chk->data != NULL) {
302 sctp_free_bufspace(stcb, asoc, chk, 1);
37
38#include <netinet/sctp_os.h>
39#include <netinet/sctp_var.h>
40#include <netinet/sctp_sysctl.h>
41#include <netinet/sctp_pcb.h>
42#include <netinet/sctp_header.h>
43#include <netinet/sctputil.h>
44#include <netinet/sctp_output.h>

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

295 /* abandon the upper streams */
296 newcnt = ntohs(init->num_inbound_streams);
297 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
298 if (chk->rec.data.stream_number >= newcnt) {
299 TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next);
300 asoc->send_queue_cnt--;
301 if (chk->data != NULL) {
302 sctp_free_bufspace(stcb, asoc, chk, 1);
303 sctp_ulp_notify(SCTP_NOTIFY_DG_FAIL, stcb,
304 SCTP_NOTIFY_DATAGRAM_UNSENT, chk, SCTP_SO_NOT_LOCKED);
303 sctp_ulp_notify(SCTP_NOTIFY_UNSENT_DG_FAIL, stcb,
304 0, chk, SCTP_SO_NOT_LOCKED);
305 if (chk->data) {
306 sctp_m_freem(chk->data);
307 chk->data = NULL;
308 }
309 }
310 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
311 /* sa_ignore FREED_MEMORY */
312 }
313 }
314 if (asoc->strmout) {
315 for (i = newcnt; i < asoc->pre_open_streams; i++) {
316 outs = &asoc->strmout[i];
317 TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) {
318 TAILQ_REMOVE(&outs->outqueue, sp, next);
319 asoc->stream_queue_cnt--;
320 sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL,
305 if (chk->data) {
306 sctp_m_freem(chk->data);
307 chk->data = NULL;
308 }
309 }
310 sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
311 /* sa_ignore FREED_MEMORY */
312 }
313 }
314 if (asoc->strmout) {
315 for (i = newcnt; i < asoc->pre_open_streams; i++) {
316 outs = &asoc->strmout[i];
317 TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) {
318 TAILQ_REMOVE(&outs->outqueue, sp, next);
319 asoc->stream_queue_cnt--;
320 sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL,
321 stcb, SCTP_NOTIFY_DATAGRAM_UNSENT,
322 sp, SCTP_SO_NOT_LOCKED);
321 stcb, 0, sp, SCTP_SO_NOT_LOCKED);
323 if (sp->data) {
324 sctp_m_freem(sp->data);
325 sp->data = NULL;
326 }
327 if (sp->net) {
328 sctp_free_remote_addr(sp->net);
329 sp->net = NULL;
330 }

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

1001#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
1002 SCTP_SOCKET_UNLOCK(so, 1);
1003#endif
1004 }
1005 /* are the queues empty? */
1006 if (!TAILQ_EMPTY(&asoc->send_queue) ||
1007 !TAILQ_EMPTY(&asoc->sent_queue) ||
1008 !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) {
322 if (sp->data) {
323 sctp_m_freem(sp->data);
324 sp->data = NULL;
325 }
326 if (sp->net) {
327 sctp_free_remote_addr(sp->net);
328 sp->net = NULL;
329 }

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

1000#if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
1001 SCTP_SOCKET_UNLOCK(so, 1);
1002#endif
1003 }
1004 /* are the queues empty? */
1005 if (!TAILQ_EMPTY(&asoc->send_queue) ||
1006 !TAILQ_EMPTY(&asoc->sent_queue) ||
1007 !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) {
1009 sctp_report_all_outbound(stcb, 0, SCTP_SO_NOT_LOCKED);
1008 sctp_report_all_outbound(stcb, 0, 0, SCTP_SO_NOT_LOCKED);
1010 }
1011 /* stop the timer */
1012 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_9);
1013 /* send SHUTDOWN-COMPLETE */
1014 sctp_send_shutdown_complete(stcb, net, 0);
1015 /* notify upper layer protocol */
1016 if (stcb->sctp_socket) {
1017 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||

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

1884 SCTP_TCB_UNLOCK(stcb);
1885 SCTP_INP_INFO_WLOCK();
1886 SCTP_INP_WLOCK(stcb->sctp_ep);
1887 SCTP_TCB_LOCK(stcb);
1888 atomic_add_int(&stcb->asoc.refcnt, -1);
1889 /* send up all the data */
1890 SCTP_TCB_SEND_LOCK(stcb);
1891
1009 }
1010 /* stop the timer */
1011 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_9);
1012 /* send SHUTDOWN-COMPLETE */
1013 sctp_send_shutdown_complete(stcb, net, 0);
1014 /* notify upper layer protocol */
1015 if (stcb->sctp_socket) {
1016 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||

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

1883 SCTP_TCB_UNLOCK(stcb);
1884 SCTP_INP_INFO_WLOCK();
1885 SCTP_INP_WLOCK(stcb->sctp_ep);
1886 SCTP_TCB_LOCK(stcb);
1887 atomic_add_int(&stcb->asoc.refcnt, -1);
1888 /* send up all the data */
1889 SCTP_TCB_SEND_LOCK(stcb);
1890
1892 sctp_report_all_outbound(stcb, 1, SCTP_SO_NOT_LOCKED);
1891 sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_NOT_LOCKED);
1893 for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
1894 stcb->asoc.strmout[i].stream_no = i;
1895 stcb->asoc.strmout[i].next_sequence_sent = 0;
1896 stcb->asoc.strmout[i].last_msg_incomplete = 0;
1897 }
1898 /* process the INIT-ACK info (my info) */
1899 asoc->my_vtag = ntohl(initack_cp->init.initiate_tag);
1900 asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);

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

3171 }
3172 /* notify upper layer protocol */
3173 if (stcb->sctp_socket) {
3174 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED);
3175 /* are the queues empty? they should be */
3176 if (!TAILQ_EMPTY(&asoc->send_queue) ||
3177 !TAILQ_EMPTY(&asoc->sent_queue) ||
3178 !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) {
1892 for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
1893 stcb->asoc.strmout[i].stream_no = i;
1894 stcb->asoc.strmout[i].next_sequence_sent = 0;
1895 stcb->asoc.strmout[i].last_msg_incomplete = 0;
1896 }
1897 /* process the INIT-ACK info (my info) */
1898 asoc->my_vtag = ntohl(initack_cp->init.initiate_tag);
1899 asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);

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

3170 }
3171 /* notify upper layer protocol */
3172 if (stcb->sctp_socket) {
3173 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED);
3174 /* are the queues empty? they should be */
3175 if (!TAILQ_EMPTY(&asoc->send_queue) ||
3176 !TAILQ_EMPTY(&asoc->sent_queue) ||
3177 !stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc)) {
3179 sctp_report_all_outbound(stcb, 0, SCTP_SO_NOT_LOCKED);
3178 sctp_report_all_outbound(stcb, 0, 0, SCTP_SO_NOT_LOCKED);
3180 }
3181 }
3182 /* stop the timer */
3183 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWNACK, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_22);
3184 SCTP_STAT_INCR_COUNTER32(sctps_shutdown);
3185 /* free the TCB */
3186 SCTPDBG(SCTP_DEBUG_INPUT2,
3187 "sctp_handle_shutdown_complete: calls free-asoc\n");

--- 2918 unchanged lines hidden ---
3179 }
3180 }
3181 /* stop the timer */
3182 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWNACK, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_22);
3183 SCTP_STAT_INCR_COUNTER32(sctps_shutdown);
3184 /* free the TCB */
3185 SCTPDBG(SCTP_DEBUG_INPUT2,
3186 "sctp_handle_shutdown_complete: calls free-asoc\n");

--- 2918 unchanged lines hidden ---