sctp_input.c (171133) | sctp_input.c (171158) |
---|---|
1/*- 2 * Copyright (c) 2001-2007, by 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_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2007, by 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_input.c,v 1.27 2005/03/06 16:04:17 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 171133 2007-07-01 11:41:27Z gnn $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 171158 2007-07-02 19:22:22Z rrs $"); |
35 36#include <netinet/sctp_os.h> 37#include <netinet/sctp_var.h> 38#include <netinet/sctp_sysctl.h> 39#include <netinet/sctp_pcb.h> 40#include <netinet/sctp_header.h> 41#include <netinet/sctputil.h> 42#include <netinet/sctp_output.h> --- 116 unchanged lines hidden (view full) --- 159 /* send an INIT-ACK w/cookie */ 160 SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending INIT-ACK\n"); 161 sctp_send_initiate_ack(inp, stcb, m, iphlen, offset, sh, cp, vrf_id); 162} 163 164/* 165 * process peer "INIT/INIT-ACK" chunk returns value < 0 on error 166 */ | 35 36#include <netinet/sctp_os.h> 37#include <netinet/sctp_var.h> 38#include <netinet/sctp_sysctl.h> 39#include <netinet/sctp_pcb.h> 40#include <netinet/sctp_header.h> 41#include <netinet/sctputil.h> 42#include <netinet/sctp_output.h> --- 116 unchanged lines hidden (view full) --- 159 /* send an INIT-ACK w/cookie */ 160 SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending INIT-ACK\n"); 161 sctp_send_initiate_ack(inp, stcb, m, iphlen, offset, sh, cp, vrf_id); 162} 163 164/* 165 * process peer "INIT/INIT-ACK" chunk returns value < 0 on error 166 */ |
167 168int 169sctp_is_there_unsent_data(struct sctp_tcb *stcb) 170{ 171 int unsent_data = 0; 172 struct sctp_stream_queue_pending *sp; 173 struct sctp_stream_out *strq; 174 struct sctp_association *asoc; 175 176 /* 177 * This function returns the number of streams that have true unsent 178 * data on them. Note that as it looks through it will clean up any 179 * places that have old data that has been sent but left at top of 180 * stream queue. 181 */ 182 asoc = &stcb->asoc; 183 SCTP_TCB_SEND_LOCK(stcb); 184 if (!TAILQ_EMPTY(&asoc->out_wheel)) { 185 /* Check to see if some data queued */ 186 TAILQ_FOREACH(strq, &asoc->out_wheel, next_spoke) { 187 /* sa_ignore FREED_MEMORY */ 188 is_there_another: 189 sp = TAILQ_FIRST(&strq->outqueue); 190 if (sp == NULL) { 191 continue; 192 } 193 if ((sp->msg_is_complete) && 194 (sp->length == 0) && 195 (sp->sender_all_done)) { 196 /* 197 * We are doing differed cleanup. Last time 198 * through when we took all the data the 199 * sender_all_done was not set. 200 */ 201 if (sp->put_last_out == 0) { 202 SCTP_PRINTF("Gak, put out entire msg with NO end!-1\n"); 203 SCTP_PRINTF("sender_done:%d len:%d msg_comp:%d put_last_out:%d\n", 204 sp->sender_all_done, 205 sp->length, 206 sp->msg_is_complete, 207 sp->put_last_out); 208 } 209 atomic_subtract_int(&stcb->asoc.stream_queue_cnt, 1); 210 TAILQ_REMOVE(&strq->outqueue, sp, next); 211 sctp_free_remote_addr(sp->net); 212 if (sp->data) { 213 sctp_m_freem(sp->data); 214 sp->data = NULL; 215 } 216 sctp_free_a_strmoq(stcb, sp); 217 goto is_there_another; 218 } else { 219 unsent_data++; 220 continue; 221 } 222 } 223 } 224 SCTP_TCB_SEND_UNLOCK(stcb); 225 return (unsent_data); 226} 227 |
|
167static int 168sctp_process_init(struct sctp_init_chunk *cp, struct sctp_tcb *stcb, 169 struct sctp_nets *net) 170{ 171 struct sctp_init *init; 172 struct sctp_association *asoc; 173 struct sctp_nets *lnet; 174 unsigned int i; --- 73 unchanged lines hidden (view full) --- 248 /* Free the old ones */ 249 struct sctp_queued_to_read *ctl; 250 251 for (i = 0; i < asoc->streamincnt; i++) { 252 ctl = TAILQ_FIRST(&asoc->strmin[i].inqueue); 253 while (ctl) { 254 TAILQ_REMOVE(&asoc->strmin[i].inqueue, ctl, next); 255 sctp_free_remote_addr(ctl->whoFrom); | 228static int 229sctp_process_init(struct sctp_init_chunk *cp, struct sctp_tcb *stcb, 230 struct sctp_nets *net) 231{ 232 struct sctp_init *init; 233 struct sctp_association *asoc; 234 struct sctp_nets *lnet; 235 unsigned int i; --- 73 unchanged lines hidden (view full) --- 309 /* Free the old ones */ 310 struct sctp_queued_to_read *ctl; 311 312 for (i = 0; i < asoc->streamincnt; i++) { 313 ctl = TAILQ_FIRST(&asoc->strmin[i].inqueue); 314 while (ctl) { 315 TAILQ_REMOVE(&asoc->strmin[i].inqueue, ctl, next); 316 sctp_free_remote_addr(ctl->whoFrom); |
317 ctl->whoFrom = NULL; |
|
256 sctp_m_freem(ctl->data); 257 ctl->data = NULL; 258 sctp_free_a_readq(stcb, ctl); 259 ctl = TAILQ_FIRST(&asoc->strmin[i].inqueue); 260 } 261 } 262 SCTP_FREE(asoc->strmin, SCTP_M_STRMI); 263 } --- 300 unchanged lines hidden (view full) --- 564 } 565 if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) { 566 /* 567 * stop the shutdown timer, since we WILL move to 568 * SHUTDOWN-ACK-SENT. 569 */ 570 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_7); 571 } | 318 sctp_m_freem(ctl->data); 319 ctl->data = NULL; 320 sctp_free_a_readq(stcb, ctl); 321 ctl = TAILQ_FIRST(&asoc->strmin[i].inqueue); 322 } 323 } 324 SCTP_FREE(asoc->strmin, SCTP_M_STRMI); 325 } --- 300 unchanged lines hidden (view full) --- 626 } 627 if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) { 628 /* 629 * stop the shutdown timer, since we WILL move to 630 * SHUTDOWN-ACK-SENT. 631 */ 632 sctp_timer_stop(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_7); 633 } |
572 /* Now are we there yet? */ 573 some_on_streamwheel = 0; 574 if (!TAILQ_EMPTY(&asoc->out_wheel)) { 575 /* Check to see if some data queued */ 576 struct sctp_stream_out *outs; | 634 /* Now is there unsent data on a stream somewhere? */ 635 some_on_streamwheel = sctp_is_there_unsent_data(stcb); |
577 | 636 |
578 TAILQ_FOREACH(outs, &asoc->out_wheel, next_spoke) { 579 if (!TAILQ_EMPTY(&outs->outqueue)) { 580 some_on_streamwheel = 1; 581 break; 582 } 583 } 584 } | |
585 if (!TAILQ_EMPTY(&asoc->send_queue) || 586 !TAILQ_EMPTY(&asoc->sent_queue) || 587 some_on_streamwheel) { 588 /* By returning we will push more data out */ 589 return; 590 } else { 591 /* no outstanding data to send, so move on... */ 592 /* send SHUTDOWN-ACK */ --- 1773 unchanged lines hidden (view full) --- 2366 stcb->asoc.ecn_echo_cnt_onq--; 2367 TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, 2368 sctp_next); 2369 if (chk->data) { 2370 sctp_m_freem(chk->data); 2371 chk->data = NULL; 2372 } 2373 stcb->asoc.ctrl_queue_cnt--; | 637 if (!TAILQ_EMPTY(&asoc->send_queue) || 638 !TAILQ_EMPTY(&asoc->sent_queue) || 639 some_on_streamwheel) { 640 /* By returning we will push more data out */ 641 return; 642 } else { 643 /* no outstanding data to send, so move on... */ 644 /* send SHUTDOWN-ACK */ --- 1773 unchanged lines hidden (view full) --- 2418 stcb->asoc.ecn_echo_cnt_onq--; 2419 TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, 2420 sctp_next); 2421 if (chk->data) { 2422 sctp_m_freem(chk->data); 2423 chk->data = NULL; 2424 } 2425 stcb->asoc.ctrl_queue_cnt--; |
2374 sctp_free_remote_addr(chk->whoTo); | |
2375 sctp_free_a_chunk(stcb, chk); 2376 break; 2377 } 2378 } 2379} 2380 2381static void 2382sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp, --- 376 unchanged lines hidden (view full) --- 2759 TAILQ_REMOVE(&asoc->control_send_queue, 2760 chk, 2761 sctp_next); 2762 if (chk->data) { 2763 sctp_m_freem(chk->data); 2764 chk->data = NULL; 2765 } 2766 asoc->ctrl_queue_cnt--; | 2426 sctp_free_a_chunk(stcb, chk); 2427 break; 2428 } 2429 } 2430} 2431 2432static void 2433sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp, --- 376 unchanged lines hidden (view full) --- 2810 TAILQ_REMOVE(&asoc->control_send_queue, 2811 chk, 2812 sctp_next); 2813 if (chk->data) { 2814 sctp_m_freem(chk->data); 2815 chk->data = NULL; 2816 } 2817 asoc->ctrl_queue_cnt--; |
2767 sctp_free_remote_addr(chk->whoTo); 2768 | |
2769 sctp_free_a_chunk(stcb, chk); 2770 stcb->asoc.str_reset = NULL; 2771} 2772 2773 2774static int 2775sctp_handle_stream_reset_response(struct sctp_tcb *stcb, 2776 uint32_t seq, uint32_t action, --- 2154 unchanged lines hidden --- | 2818 sctp_free_a_chunk(stcb, chk); 2819 stcb->asoc.str_reset = NULL; 2820} 2821 2822 2823static int 2824sctp_handle_stream_reset_response(struct sctp_tcb *stcb, 2825 uint32_t seq, uint32_t action, --- 2154 unchanged lines hidden --- |