Deleted Added
full compact
sctp_input.c (205627) sctp_input.c (206137)
1/*-
2 * Copyright (c) 2001-2008, 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-2008, 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 205627 2010-03-24 19:45:36Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 206137 2010-04-03 15:40:14Z tuexen $");
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>

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

338 asoc->highest_tsn_inside_nr_map = asoc->highest_tsn_inside_map;
339 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
340 sctp_log_map(0, 5, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
341 }
342 /* This is the next one we expect */
343 asoc->str_reset_seq_in = asoc->asconf_seq_in + 1;
344
345 asoc->mapping_array_base_tsn = ntohl(init->initial_tsn);
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>

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

338 asoc->highest_tsn_inside_nr_map = asoc->highest_tsn_inside_map;
339 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
340 sctp_log_map(0, 5, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
341 }
342 /* This is the next one we expect */
343 asoc->str_reset_seq_in = asoc->asconf_seq_in + 1;
344
345 asoc->mapping_array_base_tsn = ntohl(init->initial_tsn);
346 /*
347 * EY 05/13/08 - nr_sack: initialize nr_mapping array's base tsn
348 * like above
349 */
350 asoc->nr_mapping_array_base_tsn = ntohl(init->initial_tsn);
351 asoc->tsn_last_delivered = asoc->cumulative_tsn = asoc->asconf_seq_in;
352 asoc->last_echo_tsn = asoc->asconf_seq_in;
353 asoc->advanced_peer_ack_point = asoc->last_acked_seq;
354 /* open the requested streams */
355
356 if (asoc->strmin != NULL) {
357 /* Free the old ones */
358 struct sctp_queued_to_read *ctl;

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

1857
1858 asoc->advanced_peer_ack_point = asoc->last_acked_seq;
1859 if (asoc->mapping_array) {
1860 memset(asoc->mapping_array, 0,
1861 asoc->mapping_array_size);
1862 }
1863 if (asoc->nr_mapping_array) {
1864 memset(asoc->nr_mapping_array, 0,
346 asoc->tsn_last_delivered = asoc->cumulative_tsn = asoc->asconf_seq_in;
347 asoc->last_echo_tsn = asoc->asconf_seq_in;
348 asoc->advanced_peer_ack_point = asoc->last_acked_seq;
349 /* open the requested streams */
350
351 if (asoc->strmin != NULL) {
352 /* Free the old ones */
353 struct sctp_queued_to_read *ctl;

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

1852
1853 asoc->advanced_peer_ack_point = asoc->last_acked_seq;
1854 if (asoc->mapping_array) {
1855 memset(asoc->mapping_array, 0,
1856 asoc->mapping_array_size);
1857 }
1858 if (asoc->nr_mapping_array) {
1859 memset(asoc->nr_mapping_array, 0,
1865 asoc->nr_mapping_array_size);
1860 asoc->mapping_array_size);
1866 }
1867 SCTP_TCB_UNLOCK(stcb);
1868 SCTP_INP_INFO_WLOCK();
1869 SCTP_INP_WLOCK(stcb->sctp_ep);
1870 SCTP_TCB_LOCK(stcb);
1871 atomic_add_int(&stcb->asoc.refcnt, -1);
1872 /* send up all the data */
1873 SCTP_TCB_SEND_LOCK(stcb);

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

2022 */
2023
2024 /*
2025 * Here we do a trick, we set in NULL for the proc/thread argument.
2026 * We do this since in effect we only use the p argument when the
2027 * socket is unbound and we must do an implicit bind. Since we are
2028 * getting a cookie, we cannot be unbound.
2029 */
1861 }
1862 SCTP_TCB_UNLOCK(stcb);
1863 SCTP_INP_INFO_WLOCK();
1864 SCTP_INP_WLOCK(stcb->sctp_ep);
1865 SCTP_TCB_LOCK(stcb);
1866 atomic_add_int(&stcb->asoc.refcnt, -1);
1867 /* send up all the data */
1868 SCTP_TCB_SEND_LOCK(stcb);

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

2017 */
2018
2019 /*
2020 * Here we do a trick, we set in NULL for the proc/thread argument.
2021 * We do this since in effect we only use the p argument when the
2022 * socket is unbound and we must do an implicit bind. Since we are
2023 * getting a cookie, we cannot be unbound.
2024 */
2030 stcb = sctp_aloc_assoc(inp, init_src, 0, &error,
2025 stcb = sctp_aloc_assoc(inp, init_src, &error,
2031 ntohl(initack_cp->init.initiate_tag), vrf_id,
2032 (struct thread *)NULL
2033 );
2034 if (stcb == NULL) {
2035 struct mbuf *op_err;
2036
2037 /* memory problem? */
2038 SCTPDBG(SCTP_DEBUG_INPUT1,

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

3231 * this, otherwise we let the timer fire.
3232 */
3233 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, stcb->sctp_ep,
3234 stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_25);
3235 sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
3236 }
3237 break;
3238 case SCTP_SELECTIVE_ACK:
2026 ntohl(initack_cp->init.initiate_tag), vrf_id,
2027 (struct thread *)NULL
2028 );
2029 if (stcb == NULL) {
2030 struct mbuf *op_err;
2031
2032 /* memory problem? */
2033 SCTPDBG(SCTP_DEBUG_INPUT1,

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

3226 * this, otherwise we let the timer fire.
3227 */
3228 sctp_timer_stop(SCTP_TIMER_TYPE_INIT, stcb->sctp_ep,
3229 stcb, net, SCTP_FROM_SCTP_INPUT + SCTP_LOC_25);
3230 sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
3231 }
3232 break;
3233 case SCTP_SELECTIVE_ACK:
3234 case SCTP_NR_SELECTIVE_ACK:
3239 /* resend the sack */
3240 sctp_send_sack(stcb);
3241 break;
3235 /* resend the sack */
3236 sctp_send_sack(stcb);
3237 break;
3242 /* EY for nr_sacks */
3243 case SCTP_NR_SELECTIVE_ACK:
3244 sctp_send_nr_sack(stcb); /* EY resend the nr-sack */
3245 break;
3246 case SCTP_HEARTBEAT_REQUEST:
3247 /* resend a demand HB */
3248 if ((stcb->asoc.overall_error_count + 3) < stcb->asoc.max_send_times) {
3249 /*
3250 * Only retransmit if we KNOW we wont destroy the
3251 * tcb
3252 */
3253 (void)sctp_send_hb(stcb, 1, net);

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

3509 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
3510 sctp_log_map(0, 7, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
3511 }
3512 stcb->asoc.tsn_last_delivered = stcb->asoc.cumulative_tsn = stcb->asoc.highest_tsn_inside_map;
3513 stcb->asoc.mapping_array_base_tsn = ntohl(resp->senders_next_tsn);
3514 memset(stcb->asoc.mapping_array, 0, stcb->asoc.mapping_array_size);
3515
3516 stcb->asoc.highest_tsn_inside_nr_map = stcb->asoc.highest_tsn_inside_map;
3238 case SCTP_HEARTBEAT_REQUEST:
3239 /* resend a demand HB */
3240 if ((stcb->asoc.overall_error_count + 3) < stcb->asoc.max_send_times) {
3241 /*
3242 * Only retransmit if we KNOW we wont destroy the
3243 * tcb
3244 */
3245 (void)sctp_send_hb(stcb, 1, net);

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

3501 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
3502 sctp_log_map(0, 7, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
3503 }
3504 stcb->asoc.tsn_last_delivered = stcb->asoc.cumulative_tsn = stcb->asoc.highest_tsn_inside_map;
3505 stcb->asoc.mapping_array_base_tsn = ntohl(resp->senders_next_tsn);
3506 memset(stcb->asoc.mapping_array, 0, stcb->asoc.mapping_array_size);
3507
3508 stcb->asoc.highest_tsn_inside_nr_map = stcb->asoc.highest_tsn_inside_map;
3517 stcb->asoc.nr_mapping_array_base_tsn = stcb->asoc.mapping_array_base_tsn;
3518 memset(stcb->asoc.nr_mapping_array, 0, stcb->asoc.nr_mapping_array_size);
3509 memset(stcb->asoc.nr_mapping_array, 0, stcb->asoc.mapping_array_size);
3519
3520 stcb->asoc.sending_seq = ntohl(resp->receivers_next_tsn);
3521 stcb->asoc.last_acked_seq = stcb->asoc.cumulative_tsn;
3522
3523 sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL);
3524 sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL);
3525
3526 }

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

3619 stcb->asoc.highest_tsn_inside_map += SCTP_STREAM_RESET_TSN_DELTA;
3620 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
3621 sctp_log_map(0, 10, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
3622 }
3623 stcb->asoc.tsn_last_delivered = stcb->asoc.cumulative_tsn = stcb->asoc.highest_tsn_inside_map;
3624 stcb->asoc.mapping_array_base_tsn = stcb->asoc.highest_tsn_inside_map + 1;
3625 memset(stcb->asoc.mapping_array, 0, stcb->asoc.mapping_array_size);
3626 stcb->asoc.highest_tsn_inside_nr_map = stcb->asoc.highest_tsn_inside_map;
3510
3511 stcb->asoc.sending_seq = ntohl(resp->receivers_next_tsn);
3512 stcb->asoc.last_acked_seq = stcb->asoc.cumulative_tsn;
3513
3514 sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL);
3515 sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL);
3516
3517 }

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

3610 stcb->asoc.highest_tsn_inside_map += SCTP_STREAM_RESET_TSN_DELTA;
3611 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
3612 sctp_log_map(0, 10, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
3613 }
3614 stcb->asoc.tsn_last_delivered = stcb->asoc.cumulative_tsn = stcb->asoc.highest_tsn_inside_map;
3615 stcb->asoc.mapping_array_base_tsn = stcb->asoc.highest_tsn_inside_map + 1;
3616 memset(stcb->asoc.mapping_array, 0, stcb->asoc.mapping_array_size);
3617 stcb->asoc.highest_tsn_inside_nr_map = stcb->asoc.highest_tsn_inside_map;
3627 stcb->asoc.nr_mapping_array_base_tsn = stcb->asoc.highest_tsn_inside_map + 1;
3628 memset(stcb->asoc.nr_mapping_array, 0, stcb->asoc.nr_mapping_array_size);
3618 memset(stcb->asoc.nr_mapping_array, 0, stcb->asoc.mapping_array_size);
3629 atomic_add_int(&stcb->asoc.sending_seq, 1);
3630 /* save off historical data for retrans */
3631 stcb->asoc.last_sending_seq[1] = stcb->asoc.last_sending_seq[0];
3632 stcb->asoc.last_sending_seq[0] = stcb->asoc.sending_seq;
3633 stcb->asoc.last_base_tsnsent[1] = stcb->asoc.last_base_tsnsent[0];
3634 stcb->asoc.last_base_tsnsent[0] = stcb->asoc.mapping_array_base_tsn;
3635
3636 sctp_add_stream_reset_result_tsn(chk,

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

5631 int was_a_gap = 0;
5632
5633 if (compare_with_wrap(stcb->asoc.highest_tsn_inside_map,
5634 stcb->asoc.cumulative_tsn, MAX_TSN)) {
5635 /* there was a gap before this data was processed */
5636 was_a_gap = 1;
5637 }
5638 stcb->asoc.send_sack = 1;
3619 atomic_add_int(&stcb->asoc.sending_seq, 1);
3620 /* save off historical data for retrans */
3621 stcb->asoc.last_sending_seq[1] = stcb->asoc.last_sending_seq[0];
3622 stcb->asoc.last_sending_seq[0] = stcb->asoc.sending_seq;
3623 stcb->asoc.last_base_tsnsent[1] = stcb->asoc.last_base_tsnsent[0];
3624 stcb->asoc.last_base_tsnsent[0] = stcb->asoc.mapping_array_base_tsn;
3625
3626 sctp_add_stream_reset_result_tsn(chk,

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

5621 int was_a_gap = 0;
5622
5623 if (compare_with_wrap(stcb->asoc.highest_tsn_inside_map,
5624 stcb->asoc.cumulative_tsn, MAX_TSN)) {
5625 /* there was a gap before this data was processed */
5626 was_a_gap = 1;
5627 }
5628 stcb->asoc.send_sack = 1;
5639 sctp_sack_check(stcb, 1, was_a_gap, &abort_flag);
5629 sctp_sack_check(stcb, was_a_gap, &abort_flag);
5640 if (abort_flag) {
5641 /* Again, we aborted so NO UNLOCK needed */
5642 goto out_now;
5643 }
5644 } else if (fwd_tsn_seen) {
5645 stcb->asoc.send_sack = 1;
5646 }
5647 /* trigger send of any chunks in queue... */

--- 292 unchanged lines hidden ---
5630 if (abort_flag) {
5631 /* Again, we aborted so NO UNLOCK needed */
5632 goto out_now;
5633 }
5634 } else if (fwd_tsn_seen) {
5635 stcb->asoc.send_sack = 1;
5636 }
5637 /* trigger send of any chunks in queue... */

--- 292 unchanged lines hidden ---