Lines Matching +full:tsn +full:- +full:capable

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (c) 1999-2000 Cisco, Inc.
5 * Copyright (c) 1999-2001 Motorola, Inc.
6 * Copyright (c) 2001-2002 Intel Corp.
15 * lksctp developers <linux-sctp@vger.kernel.org>
162 __u16 chunk_length = ntohs(chunk->chunk_hdr->length); in sctp_chunk_length_valid()
165 if (unlikely(chunk->pdiscard)) in sctp_chunk_length_valid()
178 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_err_chunk_valid()
180 return (void *)err == (void *)chunk->chunk_end; in sctp_err_chunk_valid()
192 * that it is in SHUTDOWN-ACK-SENT state, if it is not the chunk should be
193 * discarded. If the endpoint is in the SHUTDOWN-ACK-SENT state the endpoint
194 * should stop the T2-shutdown timer and remove all knowledge of the
200 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
208 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
235 if (!chunk->singleton) in sctp_sf_do_4_C()
243 /* RFC 2960 10.2 SCTP-to-ULP in sctp_sf_do_4_C()
257 * will verify that it is in SHUTDOWN-ACK-SENT state, if it is in sctp_sf_do_4_C()
259 * the SHUTDOWN-ACK-SENT state the endpoint should stop the in sctp_sf_do_4_C()
260 * T2-shutdown timer and remove all knowledge of the in sctp_sf_do_4_C()
318 chunk->skb)) in sctp_sf_do_5_1B_init()
330 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
336 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1B_init()
344 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
361 if (sctp_sstate(ep->base.sk, CLOSING)) in sctp_sf_do_5_1B_init()
366 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1B_init()
367 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1B_init()
374 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
376 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
396 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1B_init()
399 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1B_init()
412 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
423 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
443 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
479 * C) Upon reception of the INIT ACK from "Z", "A" shall stop the T1-init
480 * timer and leave COOKIE-WAIT state. "A" shall then send the State
482 * the T1-cookie timer, and enter the COOKIE-ECHOED state.
521 if (!chunk->singleton) in sctp_sf_do_5_1C_ack()
524 /* Make sure that the INIT-ACK chunk has a valid length */ in sctp_sf_do_5_1C_ack()
529 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1C_ack()
533 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1C_ack()
534 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1C_ack()
546 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1C_ack()
548 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1C_ack()
561 /* SCTP-AUTH, Section 6.3: in sctp_sf_do_5_1C_ack()
577 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
583 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1C_ack()
585 initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_sf_do_5_1C_ack()
590 /* Reset init error count upon receipt of INIT-ACK. */ in sctp_sf_do_5_1C_ack()
593 /* 5.1 C) "A" shall stop the T1-init timer and leave in sctp_sf_do_5_1C_ack()
594 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie in sctp_sf_do_5_1C_ack()
595 * timer, and enter the COOKIE-ECHOED state. in sctp_sf_do_5_1C_ack()
604 /* SCTP-AUTH: genereate the assocition shared keys so that in sctp_sf_do_5_1C_ack()
605 * we can potentially signe the COOKIE-ECHO. in sctp_sf_do_5_1C_ack()
626 if (!chunk->auth_chunk) in sctp_auth_chunk_verify()
629 /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo in sctp_auth_chunk_verify()
636 /* Make sure that we and the peer are AUTH capable */ in sctp_auth_chunk_verify()
637 if (!net->sctp.auth_enable || !asoc->peer.auth_capable) in sctp_auth_chunk_verify()
640 /* set-up our fake chunk so that we can process it */ in sctp_auth_chunk_verify()
641 auth.skb = chunk->auth_chunk; in sctp_auth_chunk_verify()
642 auth.asoc = chunk->asoc; in sctp_auth_chunk_verify()
643 auth.sctp_hdr = chunk->sctp_hdr; in sctp_auth_chunk_verify()
645 skb_push(chunk->auth_chunk, in sctp_auth_chunk_verify()
647 skb_pull(chunk->auth_chunk, sizeof(struct sctp_chunkhdr)); in sctp_auth_chunk_verify()
648 auth.transport = chunk->transport; in sctp_auth_chunk_verify()
671 * - When sending a COOKIE ECHO, the endpoint MUST use the value of the
674 * - The receiver of a COOKIE ECHO follows the procedures in Section 5.
703 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1D_ce()
717 * on the TCP-style socket exceed the max backlog, respond with an in sctp_sf_do_5_1D_ce()
720 sk = ep->base.sk; in sctp_sf_do_5_1D_ce()
728 chunk->subh.cookie_hdr = in sctp_sf_do_5_1D_ce()
729 (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_1D_ce()
730 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_1D_ce()
742 * If the re-build failed, what is the proper error path in sctp_sf_do_5_1D_ce()
745 * [We should abort the association. --piggy] in sctp_sf_do_5_1D_ce()
752 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_1D_ce()
755 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_1D_ce()
760 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_1D_ce()
769 * Re-build the bind address for the association is done in in sctp_sf_do_5_1D_ce()
772 /* This is a brand-new association, so these are not yet side in sctp_sf_do_5_1D_ce()
773 * effects--it is safe to run them here. in sctp_sf_do_5_1D_ce()
775 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_5_1D_ce()
778 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
782 /* SCTP-AUTH: Now that we've populate required fields in in sctp_sf_do_5_1D_ce()
806 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1D_ce()
807 new_asoc->c.sinit_max_instreams, in sctp_sf_do_5_1D_ce()
817 if (new_asoc->peer.adaptation_ind) { in sctp_sf_do_5_1D_ce()
824 if (!new_asoc->peer.auth_capable) { in sctp_sf_do_5_1D_ce()
834 * during side-effect processing and correclty count established in sctp_sf_do_5_1D_ce()
844 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1D_ce()
884 * COOKIE-ECHOED state to the ESTABLISHED state, stopping the T1-cookie
911 /* Verify that the chunk length for the COOKIE-ACK is OK. in sctp_sf_do_5_1E_ca()
918 /* Reset init error count upon receipt of COOKIE-ACK, in sctp_sf_do_5_1E_ca()
921 * from the COOKIE-ECHOED state to the COOKIE-WAIT in sctp_sf_do_5_1E_ca()
927 security_inet_conn_established(ep->base.sk, chunk->skb); in sctp_sf_do_5_1E_ca()
932 * from the COOKIE-ECHOED state to the ESTABLISHED state, in sctp_sf_do_5_1E_ca()
933 * stopping the T1-cookie timer. in sctp_sf_do_5_1E_ca()
942 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1E_ca()
951 0, asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1E_ca()
952 asoc->c.sinit_max_instreams, in sctp_sf_do_5_1E_ca()
965 if (asoc->peer.adaptation_ind) { in sctp_sf_do_5_1E_ca()
974 if (!asoc->peer.auth_capable) { in sctp_sf_do_5_1E_ca()
1024 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_sendbeat_8_3()
1036 * The Sender-specific Heartbeat Info field should normally include in sctp_sf_sendbeat_8_3()
1042 if (transport->param_flags & SPP_HB_ENABLE) { in sctp_sf_sendbeat_8_3()
1072 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_send_reconf()
1083 sctp_chunk_hold(asoc->strreset_chunk); in sctp_sf_send_reconf()
1085 SCTP_CHUNK(asoc->strreset_chunk)); in sctp_sf_send_reconf()
1139 chunk->subh.hb_hdr = (struct sctp_heartbeathdr *)chunk->skb->data; in sctp_sf_beat_8_3()
1140 param_hdr = (struct sctp_paramhdr *)chunk->subh.hb_hdr; in sctp_sf_beat_8_3()
1141 paylen = ntohs(chunk->chunk_hdr->length) - sizeof(struct sctp_chunkhdr); in sctp_sf_beat_8_3()
1143 if (ntohs(param_hdr->length) > paylen) in sctp_sf_beat_8_3()
1147 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1205 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1211 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1213 if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo)) in sctp_sf_backbeat_8_3()
1216 from_addr = hbinfo->daddr; in sctp_sf_backbeat_8_3()
1235 /* Validate the 64-bit random nonce. */ in sctp_sf_backbeat_8_3()
1236 if (hbinfo->hb_nonce != link->hb_nonce) in sctp_sf_backbeat_8_3()
1239 max_interval = link->hbinterval + link->rto; in sctp_sf_backbeat_8_3()
1242 if (time_after(hbinfo->sent_at, jiffies) || in sctp_sf_backbeat_8_3()
1243 time_after(jiffies, hbinfo->sent_at + max_interval)) { in sctp_sf_backbeat_8_3()
1268 struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); in sctp_sf_send_restart_abort()
1280 addrparm = (union sctp_addr_param *)errhdr->variable; in sctp_sf_send_restart_abort()
1283 len = af->to_addr_param(ssa, addrparm); in sctp_sf_send_restart_abort()
1286 errhdr->cause = SCTP_ERROR_RESTART; in sctp_sf_send_restart_abort()
1287 errhdr->length = htons(len); in sctp_sf_send_restart_abort()
1290 ep = sctp_sk(net->sctp.ctl_sock)->ep; in sctp_sf_send_restart_abort()
1319 if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr)) in list_has_sctp_addr()
1333 struct net *net = new_asoc->base.net; in sctp_sf_check_restart_addrs()
1337 /* Implementor's Guide - Section 5.2.2 in sctp_sf_check_restart_addrs()
1348 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1350 if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1351 &new_addr->ipaddr)) { in sctp_sf_check_restart_addrs()
1352 sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, in sctp_sf_check_restart_addrs()
1366 * Note: Do not use in CLOSED or SHUTDOWN-ACK-SENT state.
1371 switch (asoc->state) { in sctp_tietags_populate()
1373 /* 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State */ in sctp_tietags_populate()
1376 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1377 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1378 new_asoc->c.peer_ttag = 0; in sctp_tietags_populate()
1382 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1383 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1384 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1387 /* 5.2.2 Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, in sctp_tietags_populate()
1388 * COOKIE-WAIT and SHUTDOWN-ACK-SENT in sctp_tietags_populate()
1391 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1392 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1400 new_asoc->rwnd = asoc->rwnd; in sctp_tietags_populate()
1401 new_asoc->c.sinit_num_ostreams = asoc->c.sinit_num_ostreams; in sctp_tietags_populate()
1402 new_asoc->c.sinit_max_instreams = asoc->c.sinit_max_instreams; in sctp_tietags_populate()
1403 new_asoc->c.initial_tsn = asoc->c.initial_tsn; in sctp_tietags_populate()
1407 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1419 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1420 (asoc->c.peer_vtag != new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1421 (asoc->c.my_vtag == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1422 (asoc->c.peer_vtag == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1426 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1427 ((asoc->c.peer_vtag != new_asoc->c.peer_vtag) || in sctp_tietags_compare()
1428 (0 == asoc->c.peer_vtag))) { in sctp_tietags_compare()
1433 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1434 (asoc->c.peer_vtag == new_asoc->c.peer_vtag)) in sctp_tietags_compare()
1438 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1439 (asoc->c.peer_vtag == new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1440 (0 == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1441 (0 == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1468 chunk->skb)) in sctp_sf_do_unexpected_init()
1480 if (!chunk->singleton) in sctp_sf_do_unexpected_init()
1486 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_unexpected_init()
1497 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_unexpected_init()
1500 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_unexpected_init()
1504 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_unexpected_init()
1505 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_unexpected_init()
1512 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1514 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1549 * place (local tie-tag and per tie-tag) within the state cookie. in sctp_sf_do_unexpected_init()
1552 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1557 * restart. Do not do this check for COOKIE-WAIT state, in sctp_sf_do_unexpected_init()
1578 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1599 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1636 * Section: 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State (Item B)
1641 * Upon receipt of an INIT in the COOKIE-WAIT or COOKIE-ECHOED state, an
1649 * After that, the endpoint MUST NOT change its state, the T1-init
1654 * For an endpoint that is in the COOKIE-ECHOED state it MUST populate
1655 * its Tie-Tags with the Tag information of itself and its peer (see
1656 * section 5.2.2 for a description of the Tie-Tags).
1688 * COOKIE-ECHOED and COOKIE-WAIT
1695 * the Peer's-Tie-Tag and the Local-Tie-Tag. The outbound SCTP packet
1707 * Note: Only when a TCB exists and the association is not in a COOKIE-
1708 * WAIT state are the Tie-Tags populated. For a normal association INIT
1709 * (i.e. the endpoint is in a COOKIE-WAIT state), the Tie-Tags MUST be
1740 * Unexpected INIT-ACK handler.
1744 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1757 * endpoint. If this is an OOTB INIT-ACK, treat it as such. in sctp_sf_do_5_2_3_initack()
1759 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) in sctp_sf_do_5_2_3_initack()
1765 /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A')
1784 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_a()
1785 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_a()
1787 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_dupcook_a()
1806 /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in sctp_sf_do_dupcook_a()
1814 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1829 /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked in sctp_sf_do_dupcook_a()
1837 /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue in sctp_sf_do_dupcook_a()
1838 * and ASCONF-ACK cache. in sctp_sf_do_dupcook_a()
1850 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_a()
1851 new_asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_a()
1861 (sctp_sstate(asoc->base.sk, CLOSING) || in sctp_sf_do_dupcook_a()
1862 sock_flag(asoc->base.sk, SOCK_DEAD))) { in sctp_sf_do_dupcook_a()
1884 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'B')
1903 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_b()
1904 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_b()
1906 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_dupcook_b()
1936 * Sadly, this needs to be implemented as a side-effect, because in sctp_sf_do_dupcook_b()
1952 if (asoc->peer.adaptation_ind) in sctp_sf_do_dupcook_b()
1955 if (!asoc->peer.auth_capable) in sctp_sf_do_dupcook_b()
1964 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'C')
1969 * INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
1988 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2009 * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state. in sctp_sf_do_dupcook_d()
2018 if (asoc->state < SCTP_STATE_ESTABLISHED) { in sctp_sf_do_dupcook_d()
2036 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_d()
2037 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_d()
2047 if (asoc->peer.adaptation_ind) { in sctp_sf_do_dupcook_d()
2055 if (!asoc->peer.auth_capable) { in sctp_sf_do_dupcook_d()
2093 * Handle a duplicate COOKIE-ECHO. This usually means a cookie-carrying
2135 chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_2_4_dupcook()
2136 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_2_4_dupcook()
2149 * If the re-build failed, what is the proper error path in sctp_sf_do_5_2_4_dupcook()
2152 * [We should abort the association. --piggy] in sctp_sf_do_5_2_4_dupcook()
2159 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_2_4_dupcook()
2162 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_2_4_dupcook()
2166 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_2_4_dupcook()
2174 chunk->skb)) { in sctp_sf_do_5_2_4_dupcook()
2180 new_asoc->temp = 1; in sctp_sf_do_5_2_4_dupcook()
2230 * Process an ABORT. (SHUTDOWN-PENDING state)
2260 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_pending_abort()
2266 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2276 * Process an ABORT. (SHUTDOWN-SENT state)
2306 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_sent_abort()
2312 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2318 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_abort()
2322 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_abort()
2330 * Process an ABORT. (SHUTDOWN-ACK-SENT state)
2343 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_abort()
2384 /* FUTURE FIXME: When PR-SCTP related and other optional in sctp_sf_cookie_echoed_err()
2388 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2389 if (SCTP_ERROR_STALE_COOKIE == err->cause) in sctp_sf_cookie_echoed_err()
2406 * If the association is in the COOKIE-ECHOED state, the endpoint may elect
2435 int attempts = asoc->init_err_counter + 1; in sctp_sf_do_5_2_6_stale()
2442 if (attempts > asoc->max_init_attempts) { in sctp_sf_do_5_2_6_stale()
2450 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2459 * Suggested Cookie Life-span Increment's unit is msec. in sctp_sf_do_5_2_6_stale()
2474 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_do_5_2_6_stale()
2484 /* Stop pending T3-rtx and heartbeat timers */ in sctp_sf_do_5_2_6_stale()
2488 /* Delete non-primary peer ip addresses since we are transitioning in sctp_sf_do_5_2_6_stale()
2489 * back to the COOKIE-WAIT state in sctp_sf_do_5_2_6_stale()
2493 /* If we've sent any data bundled with COOKIE-ECHO we will need to in sctp_sf_do_5_2_6_stale()
2497 SCTP_TRANSPORT(asoc->peer.primary_path)); in sctp_sf_do_5_2_6_stale()
2530 * - The endpoint shall always fill in the Verification Tag field of the
2534 * - If the ABORT is sent in response to an OOTB packet, the endpoint
2537 * - The receiver MUST accept the packet if the Verification Tag
2576 /* ADD-IP: Special case for ABORT chunks in sctp_sf_do_9_1_abort()
2582 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_do_9_1_abort()
2604 len = ntohs(chunk->chunk_hdr->length); in __sctp_sf_do_9_1_abort()
2606 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in __sctp_sf_do_9_1_abort()
2618 * Process an ABORT. (COOKIE-WAIT state)
2651 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_cookie_wait_abort()
2653 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in sctp_sf_cookie_wait_abort()
2656 chunk->transport); in sctp_sf_cookie_wait_abort()
2660 * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state)
2676 * Process an ABORT. (COOKIE-ECHOED state)
2687 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_abort()
2724 * - enter the SHUTDOWN-RECEIVED state,
2726 * - stop accepting new data from its SCTP user
2728 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2732 * Once an endpoint as reached the SHUTDOWN-RECEIVED state it MUST NOT
2775 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shutdown()
2776 skb_pull(chunk->skb, sizeof(*sdh)); in sctp_sf_do_9_2_shutdown()
2777 chunk->subh.shutdown_hdr = sdh; in sctp_sf_do_9_2_shutdown()
2778 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shutdown()
2780 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shutdown()
2782 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shutdown()
2787 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shutdown()
2791 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shutdown()
2806 * - enter the SHUTDOWN-RECEIVED state, in sctp_sf_do_9_2_shutdown()
2807 * - stop accepting new data from its SCTP user in sctp_sf_do_9_2_shutdown()
2815 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_shutdown()
2823 /* - verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shutdown()
2828 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2837 * Once an endpoint has reached the SHUTDOWN-RECEIVED state,
2839 * The Cumulative TSN Ack of the received SHUTDOWN chunk
2862 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2863 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shut_ctsn()
2865 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shut_ctsn()
2867 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shut_ctsn()
2872 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shut_ctsn()
2876 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shut_ctsn()
2879 /* verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shut_ctsn()
2884 SCTP_BE32(sdh->cum_tsn_ack)); in sctp_sf_do_9_2_shut_ctsn()
2890 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
2921 * the T2-SHUTDOWN timer. in sctp_sf_do_9_2_reshutack()
2925 /* and restart the T2-shutdown timer. */ in sctp_sf_do_9_2_reshutack()
2947 * This chunk contains one data element, i.e. the TSN number that
2949 * TSN number in the datagram that was originally marked with the
2979 cwr = (struct sctp_cwrhdr *)chunk->skb->data; in sctp_sf_do_ecn_cwr()
2980 skb_pull(chunk->skb, sizeof(*cwr)); in sctp_sf_do_ecn_cwr()
2982 lowest_tsn = ntohl(cwr->lowest_tsn); in sctp_sf_do_ecn_cwr()
2985 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) { in sctp_sf_do_ecn_cwr()
2999 * ECN-Echo
3005 * contains one data element, i.e. the lowest TSN associated with the IP
3033 ecne = (struct sctp_ecnehdr *)chunk->skb->data; in sctp_sf_do_ecne()
3034 skb_pull(chunk->skb, sizeof(*ecne)); in sctp_sf_do_ecne()
3038 SCTP_U32(ntohl(ecne->lowest_tsn))); in sctp_sf_do_ecne()
3090 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_6_2()
3110 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_6_2()
3111 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_6_2()
3116 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3119 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_data_6_2()
3146 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3160 * and the peer's RTO has expired. The duplicate TSN number(s) in sctp_sf_eat_data_6_2()
3166 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3171 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3181 * (4) In SHUTDOWN-SENT state the endpoint MUST acknowledge any received
3210 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_fast_4_4()
3226 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_fast_4_4()
3227 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_fast_4_4()
3236 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_data_fast_4_4()
3238 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_data_fast_4_4()
3240 if (chunk->end_of_packet) { in sctp_sf_eat_data_fast_4_4()
3242 * TSN has not been updated yet. in sctp_sf_eat_data_fast_4_4()
3257 * i) If Cumulative TSN Ack is less than the Cumulative TSN Ack Point,
3258 * then drop the SACK. Since Cumulative TSN Ack is monotonically
3259 * increasing, a SACK whose Cumulative TSN Ack is less than the
3260 * Cumulative TSN Ack Point indicates an out-of-order SACK.
3263 * of bytes still outstanding after processing the Cumulative TSN Ack
3266 * iii) If the SACK is missing a TSN that was previously
3272 * chunk was originally transmitted, then T3-rtx is started for
3309 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3310 ctsn = ntohl(sackh->cum_tsn_ack); in sctp_sf_eat_sack_6_2()
3312 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_eat_sack_6_2()
3316 if (TSN_lte(asoc->next_tsn, ctsn)) in sctp_sf_eat_sack_6_2()
3321 /* i) If Cumulative TSN Ack is less than the Cumulative TSN in sctp_sf_eat_sack_6_2()
3322 * Ack Point, then drop the SACK. Since Cumulative TSN in sctp_sf_eat_sack_6_2()
3324 * Cumulative TSN Ack is less than the Cumulative TSN Ack in sctp_sf_eat_sack_6_2()
3325 * Point indicates an out-of-order SACK. in sctp_sf_eat_sack_6_2()
3327 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_eat_sack_6_2()
3329 asoc->ctsn_ack_point); in sctp_sf_eat_sack_6_2()
3352 * packet and set the T-bit in the Chunk Flags to indicate that the
3386 /* Reflect vtag if T-Bit is set */ in sctp_sf_tabort_8_4_8()
3388 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3391 abort->skb->sk = ep->base.sk; in sctp_sf_tabort_8_4_8()
3408 * API 5.3.1.3 - SCTP_REMOTE_ERROR
3429 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_sf_operr_notify()
3430 if ((void *)err != (void *)chunk->chunk_end) in sctp_sf_operr_notify()
3445 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3489 * stop the T2-shutdown timer, in sctp_sf_do_9_2_final()
3514 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3521 * set the T-bit in the Chunk Flags to indicate that the Verification
3528 * packet and set the T-bit in the Chunk Flags to indicate that the
3540 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3549 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3552 if (ntohs(ch->length) < sizeof(*ch)) in sctp_sf_ootb()
3557 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); in sctp_sf_ootb()
3565 if (SCTP_CID_SHUTDOWN_ACK == ch->type) in sctp_sf_ootb()
3573 if (SCTP_CID_ABORT == ch->type) in sctp_sf_ootb()
3581 if (SCTP_CID_COOKIE_ACK == ch->type) in sctp_sf_ootb()
3584 if (SCTP_CID_ERROR == ch->type) { in sctp_sf_ootb()
3586 if (SCTP_ERROR_STALE_COOKIE == err->cause) { in sctp_sf_ootb()
3614 * set the T-bit in the Chunk Flags to indicate that the Verification
3650 /* Reflect vtag if T-Bit is set */ in sctp_sf_shut_8_4_5()
3652 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3655 shut->skb->sk = ep->base.sk; in sctp_sf_shut_8_4_5()
3681 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the
3685 * chunks. --piggy ]
3732 /* ADD-IP: Section 4.1.1 in sctp_sf_do_asconf()
3734 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3736 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf()
3738 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf()
3739 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3748 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3749 serial = ntohl(hdr->serial); in sctp_sf_do_asconf()
3758 * 'Peer-Serial-Number'. in sctp_sf_do_asconf()
3760 if (serial == asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3762 * we can clean our old ASCONF-ACKs. in sctp_sf_do_asconf()
3764 if (!chunk->has_asconf) in sctp_sf_do_asconf()
3769 * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to in sctp_sf_do_asconf()
3773 * Essentially, do V1-V5. in sctp_sf_do_asconf()
3779 } else if (serial < asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3782 * ('Peer- Sequence-Number' + 1), simply skip to the next in sctp_sf_do_asconf()
3784 * any previously cached ASCONF-ACK response that was in sctp_sf_do_asconf()
3786 * ASCONF. Note: It is possible that no cached ASCONF-ACK in sctp_sf_do_asconf()
3789 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3792 asconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial); in sctp_sf_do_asconf()
3800 asconf_ack->transport = NULL; in sctp_sf_do_asconf()
3809 * containing the ASCONF-ACK Chunks MUST be the source address of in sctp_sf_do_asconf()
3817 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
3819 if (asoc->new_transport) { in sctp_sf_do_asconf()
3820 sctp_sf_heartbeat(ep, asoc, type, asoc->new_transport, commands); in sctp_sf_do_asconf()
3821 ((struct sctp_association *)asoc)->new_transport = NULL; in sctp_sf_do_asconf()
3837 if (list_empty(&asoc->addip_chunk_list)) in sctp_send_next_asconf()
3840 entry = asoc->addip_chunk_list.next; in sctp_send_next_asconf()
3845 asoc->addip_last_asconf = asconf; in sctp_send_next_asconf()
3862 struct sctp_chunk *last_asconf = asoc->addip_last_asconf; in sctp_sf_do_asconf_ack()
3875 /* ADD-IP, Section 4.1.2: in sctp_sf_do_asconf_ack()
3877 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf_ack()
3879 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf_ack()
3881 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf_ack()
3882 (!net->sctp.addip_noauth && !asconf_ack->auth)) in sctp_sf_do_asconf_ack()
3892 addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data; in sctp_sf_do_asconf_ack()
3893 rcvd_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
3895 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
3901 addip_hdr = (struct sctp_addiphdr *)last_asconf->subh.addip_hdr; in sctp_sf_do_asconf_ack()
3902 sent_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
3904 sent_serial = asoc->addip_serial - 1; in sctp_sf_do_asconf_ack()
3907 /* D0) If an endpoint receives an ASCONF-ACK that is greater than or in sctp_sf_do_asconf_ack()
3910 * sequence number is greater than if it is no more than 2^^31-1 in sctp_sf_do_asconf_ack()
3914 !(asoc->addip_last_asconf)) { in sctp_sf_do_asconf_ack()
3937 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { in sctp_sf_do_asconf_ack()
3970 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
3998 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4003 if (param.p->type == SCTP_PARAM_RESET_OUT_REQUEST) in sctp_sf_do_reconf()
4006 else if (param.p->type == SCTP_PARAM_RESET_IN_REQUEST) in sctp_sf_do_reconf()
4009 else if (param.p->type == SCTP_PARAM_RESET_TSN_REQUEST) in sctp_sf_do_reconf()
4012 else if (param.p->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) in sctp_sf_do_reconf()
4015 else if (param.p->type == SCTP_PARAM_RESET_ADD_IN_STREAMS) in sctp_sf_do_reconf()
4018 else if (param.p->type == SCTP_PARAM_RESET_RESPONSE) in sctp_sf_do_reconf()
4035 * PR-SCTP Section 3.6 Receiver Side Implementation of PR-SCTP
4037 * When a FORWARD TSN chunk arrives, the data receiver MUST first update
4038 * its cumulative TSN point to the value carried in the FORWARD TSN
4039 * chunk, and then MUST further advance its cumulative TSN point locally
4042 * missing TSNs earlier than or equal to the new cumulative TSN point.
4058 __u32 tsn; in sctp_sf_eat_fwd_tsn() local
4066 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn()
4070 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn()
4074 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn()
4075 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn()
4076 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn()
4077 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn()
4078 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn()
4080 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn()
4081 pr_debug("%s: TSN 0x%x\n", __func__, tsn); in sctp_sf_eat_fwd_tsn()
4083 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn()
4086 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn()
4089 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4092 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_FWDTSN, SCTP_U32(tsn)); in sctp_sf_eat_fwd_tsn()
4093 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn()
4098 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_fwd_tsn()
4125 __u32 tsn; in sctp_sf_eat_fwd_tsn_fast() local
4133 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn_fast()
4137 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn_fast()
4141 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn_fast()
4142 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn_fast()
4143 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn_fast()
4144 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn_fast()
4145 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn_fast()
4147 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn_fast()
4148 pr_debug("%s: TSN 0x%x\n", __func__, tsn); in sctp_sf_eat_fwd_tsn_fast()
4150 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn_fast()
4153 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn_fast()
4156 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4159 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_FWDTSN, SCTP_U32(tsn)); in sctp_sf_eat_fwd_tsn_fast()
4160 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn_fast()
4168 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_fwd_tsn_fast()
4170 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_fwd_tsn_fast()
4181 * SCTP-AUTH Section 6.3 Receiving authenticated chukns
4185 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4214 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_authenticate()
4215 chunk->subh.auth_hdr = auth_hdr; in sctp_sf_authenticate()
4216 skb_pull(chunk->skb, sizeof(*auth_hdr)); in sctp_sf_authenticate()
4221 if (!sctp_auth_asoc_verify_hmac_id(asoc, auth_hdr->hmac_id)) in sctp_sf_authenticate()
4227 key_id = ntohs(auth_hdr->shkey_id); in sctp_sf_authenticate()
4228 if (key_id != asoc->active_key_id) { in sctp_sf_authenticate()
4237 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4239 hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); in sctp_sf_authenticate()
4240 if (sig_len != hmac->hmac_len) in sctp_sf_authenticate()
4250 digest = auth_hdr->hmac; in sctp_sf_authenticate()
4251 skb_pull(chunk->skb, sig_len); in sctp_sf_authenticate()
4259 sctp_auth_calculate_hmac(asoc, chunk->skb, in sctp_sf_authenticate()
4260 (struct sctp_auth_chunk *)chunk->chunk_hdr, in sctp_sf_authenticate()
4270 chunk->auth = 1; in sctp_sf_authenticate()
4288 /* Make sure that the peer has AUTH capable */ in sctp_sf_eat_auth()
4289 if (!asoc->peer.auth_capable) in sctp_sf_eat_auth()
4303 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4312 &auth_hdr->hmac_id, in sctp_sf_eat_auth()
4334 if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { in sctp_sf_eat_auth()
4337 ev = sctp_ulpevent_make_authkey(asoc, ntohs(auth_hdr->shkey_id), in sctp_sf_eat_auth()
4341 return -ENOMEM; in sctp_sf_eat_auth()
4355 * Chunk Types are encoded such that the highest-order two bits specify
4359 * 00 - Stop processing this SCTP packet and discard it, do not process
4362 * 01 - Stop processing this SCTP packet and discard it, do not process
4366 * 10 - Skip this chunk and continue processing.
4368 * 11 - Skip this chunk and continue processing, but report in an ERROR
4403 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4406 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4421 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4424 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4553 /* SCTP-AUTH, Section 6.3: in sctp_sf_abort_violation()
4573 /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ in sctp_sf_abort_violation()
4574 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4575 !asoc->peer.i.init_tag) { in sctp_sf_abort_violation()
4578 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4580 abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T; in sctp_sf_abort_violation()
4584 inittag = ntohl(initack->init_hdr.init_tag); in sctp_sf_abort_violation()
4593 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { in sctp_sf_abort_violation()
4614 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4616 abort->skb->sk = ep->base.sk; in sctp_sf_abort_violation()
4715 * cumulative tsn ack to a point beyond the max tsn currently sent.
4728 static const char err_str[] = "The cumulative tsn ack beyond the max tsn currently sent:"; in sctp_sf_violation_ctsn()
4735 * when we have an association and we receive bundled INIT-ACK, or
4736 * SHUDOWN-COMPLETE, our peer is clearly violationg the "MUST NOT bundle"
4762 * Section: 10.1 ULP-to-SCTP
4767 * -> association id [,destination transport addr list] [,outbound stream
4796 * stuff happens when the INIT ACK arrives. This is a NON-BLOCKING
4801 * o local SCTP instance name - obtained from the INITIALIZE operation.
4803 * o destination transport addr - specified as one of the transport
4806 * [This is asoc->peer.active_path.]
4807 * o outbound stream count - the number of outbound streams the ULP
4826 /* The comment below says that we enter COOKIE-WAIT AFTER in sctp_sf_do_prm_asoc()
4841 repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); in sctp_sf_do_prm_asoc()
4855 /* After sending the INIT, "A" starts the T1-init timer and in sctp_sf_do_prm_asoc()
4856 * enters the COOKIE-WAIT state. in sctp_sf_do_prm_asoc()
4870 * Section: 10.1 ULP-to-SCTP
4875 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
4876 * -> result
4882 * o association id - local handle to the SCTP association
4884 * o buffer address - the location where the user message to be
4887 * o byte count - The size of the user data in number of bytes;
4891 * o context - an optional 32 bit integer that will be carried in the
4895 * o stream id - to indicate which stream to send the data on. If not
4898 * o life time - specifies the life time of the user data. The user data
4907 * o destination transport address - specified as one of the destination
4913 * o unorder flag - this flag, if present, indicates that the user
4918 * o no-bundle flag - instructs SCTP not to bundle this user data with
4922 * o payload protocol-id - A 32 bit unsigned integer that is to be
4948 * -> result
4959 * o association id - local handle to the SCTP association
4979 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_do_9_2_prm_shutdown()
4989 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_prm_shutdown()
5004 * -> result
5014 * o association id - local handle to the SCTP association
5018 * o cause code - reason of the abort to be passed to the peer
5069 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_ERROR, SCTP_ERROR(-EINVAL)); in sctp_sf_error_closed()
5085 SCTP_ERROR(-ESHUTDOWN)); in sctp_sf_error_shutdown()
5147 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_shutdown()
5176 /* Stop T1-init timer */ in sctp_sf_cookie_wait_prm_abort()
5224 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_abort()
5236 * state table when someone issues an abort while in SHUTDOWN-PENDING state.
5249 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_pending_prm_abort()
5263 * state table when someone issues an abort while in SHUTDOWN-SENT state.
5276 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_prm_abort()
5280 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_prm_abort()
5308 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_prm_abort()
5316 * 10.1 ULP-to-SCTP
5321 * -> result
5330 * o association id - local handle to the SCTP association
5332 * o destination transport address - the transport address of the
5350 * D) Request an on-demand HEARTBEAT on a specific destination in sctp_sf_do_prm_requestheartbeat()
5384 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5452 * TSN Ack field the last sequential TSN it has received from the peer.
5453 * It shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT
5454 * state. If the timer expires, the endpoint must re-send the SHUTDOWN
5455 * with the updated last sequential TSN received from its peer.
5471 * in the Cumulative TSN Ack field the last sequential TSN it in sctp_sf_do_9_2_start_shutdown()
5479 * T2-shutdown timer. in sctp_sf_do_9_2_start_shutdown()
5483 /* It shall then start the T2-shutdown timer */ in sctp_sf_do_9_2_start_shutdown()
5489 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. in sctp_sf_do_9_2_start_shutdown()
5494 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_start_shutdown()
5498 /* and enter the SHUTDOWN-SENT state. */ in sctp_sf_do_9_2_start_shutdown()
5502 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_start_shutdown()
5505 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_start_shutdown()
5523 * shall send a SHUTDOWN ACK and start a T2-shutdown timer of its own,
5524 * entering the SHUTDOWN-ACK-SENT state. If the timer expires, the
5525 * endpoint must re-send the SHUTDOWN ACK.
5567 * the T2-shutdown timer. in sctp_sf_do_9_2_shutdown_ack()
5571 /* and start/restart a T2-shutdown timer of its own, */ in sctp_sf_do_9_2_shutdown_ack()
5575 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_shutdown_ack()
5579 /* Enter the SHUTDOWN-ACK-SENT state. */ in sctp_sf_do_9_2_shutdown_ack()
5583 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_shutdown_ack()
5586 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_shutdown_ack()
5623 * Section: 6.3.3 Handle T3-rtx Expiration
5625 * Whenever the retransmission timer T3-rtx expires for a destination
5642 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_do_6_3_3_rtx()
5643 if (asoc->peer.zero_window_announced && in sctp_sf_do_6_3_3_rtx()
5644 asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { in sctp_sf_do_6_3_3_rtx()
5670 * 7.2.3 and set the cwnd <- MTU. in sctp_sf_do_6_3_3_rtx()
5674 * expires, set RTO <- RTO * 2 ("back off the timer"). The in sctp_sf_do_6_3_3_rtx()
5679 /* E3) Determine how many of the earliest (i.e., lowest TSN) in sctp_sf_do_6_3_3_rtx()
5681 * T3-rtx has expired will fit into a single packet, subject in sctp_sf_do_6_3_3_rtx()
5690 * which the T3-rtx timer expired but did not fit in one MTU in sctp_sf_do_6_3_3_rtx()
5740 * 2) If the T1-init timer expires, the endpoint MUST retransmit INIT
5741 * and re-start the T1-init timer without changing state. This MUST
5758 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_init_timer_expire()
5766 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_init_timer_expire()
5767 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_t1_init_timer_expire()
5784 asoc->max_init_attempts); in sctp_sf_t1_init_timer_expire()
5805 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
5806 * COOKIE ECHO and re-start the T1-cookie timer without changing
5823 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_cookie_timer_expire()
5826 pr_debug("%s: timer T1 expired (COOKIE-ECHO)\n", __func__); in sctp_sf_t1_cookie_timer_expire()
5830 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_cookie_timer_expire()
5853 /* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
5854 * with the updated last sequential TSN received from its peer.
5863 * the T2-Shutdown timer, giving its peer ample opportunity to transmit
5880 ((struct sctp_association *)asoc)->shutdown_retries++; in sctp_sf_t2_timer_expire()
5882 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t2_timer_expire()
5893 switch (asoc->state) { in sctp_sf_t2_timer_expire()
5914 if (asoc->shutdown_last_sent_to) in sctp_sf_t2_timer_expire()
5916 SCTP_TRANSPORT(asoc->shutdown_last_sent_to)); in sctp_sf_t2_timer_expire()
5919 * the T2-shutdown timer. in sctp_sf_t2_timer_expire()
5923 /* Restart the T2-shutdown timer. */ in sctp_sf_t2_timer_expire()
5945 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire()
5946 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
5966 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t4_timer_expire()
5978 /* ADDIP 4.1 B3) Back-off the destination address RTO value to which in sctp_sf_t4_timer_expire()
5983 /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible in sctp_sf_t4_timer_expire()
5989 sctp_chunk_hold(asoc->addip_last_asconf); in sctp_sf_t4_timer_expire()
5991 SCTP_CHUNK(asoc->addip_last_asconf)); in sctp_sf_t4_timer_expire()
5993 /* ADDIP 4.1 B5) Restart the T-4 RTO timer. Note that if a different in sctp_sf_t4_timer_expire()
6003 /* sctpimpguide-05 Section 2.12.2
6005 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
6060 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_autoclose_timer_expire()
6070 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_autoclose_timer_expire()
6154 sack = (struct sctp_sackhdr *) chunk->skb->data; in sctp_sm_pull_sack()
6156 num_blocks = ntohs(sack->num_gap_ack_blocks); in sctp_sm_pull_sack()
6157 num_dup_tsns = ntohs(sack->num_dup_tsns); in sctp_sm_pull_sack()
6160 if (len > chunk->skb->len) in sctp_sm_pull_sack()
6163 skb_pull(chunk->skb, len); in sctp_sm_pull_sack()
6193 /* Reflect vtag if T-Bit is set */ in sctp_abort_pkt_new()
6195 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6203 abort->skb->sk = ep->base.sk; in sctp_abort_pkt_new()
6224 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6225 dport = ntohs(chunk->sctp_hdr->source); in sctp_ootb_pkt_new()
6227 /* The V-tag is going to be the same as the inbound packet if no in sctp_ootb_pkt_new()
6231 /* Special case the INIT-ACK as there is no peer's vtag in sctp_ootb_pkt_new()
6234 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6239 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6240 vtag = ntohl(initack->init_hdr.init_tag); in sctp_ootb_pkt_new()
6244 vtag = asoc->peer.i.init_tag; in sctp_ootb_pkt_new()
6251 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6256 init = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6257 vtag = ntohl(init->init_hdr.init_tag); in sctp_ootb_pkt_new()
6261 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6274 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6275 sctp_sk(net->sctp.ctl_sock)); in sctp_ootb_pkt_new()
6277 packet = &transport->packet; in sctp_ootb_pkt_new()
6290 sctp_transport_free(packet->transport); in sctp_ootb_pkt_free()
6309 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6310 packet->vtag = cookie->c.peer_vtag; in sctp_send_stale_cookie_err()
6313 err_chunk->skb->sk = ep->base.sk; in sctp_send_stale_cookie_err()
6329 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_eat_data()
6330 struct sock *sk = asoc->base.sk; in sctp_eat_data()
6336 __u32 tsn; in sctp_eat_data() local
6339 data_hdr = (struct sctp_datahdr *)chunk->skb->data; in sctp_eat_data()
6340 chunk->subh.data_hdr = data_hdr; in sctp_eat_data()
6341 skb_pull(chunk->skb, sctp_datahdr_len(&asoc->stream)); in sctp_eat_data()
6343 tsn = ntohl(data_hdr->tsn); in sctp_eat_data()
6344 pr_debug("%s: TSN 0x%x\n", __func__, tsn); in sctp_eat_data()
6346 /* ASSERT: Now skb->data is really the user data. */ in sctp_eat_data()
6358 if (asoc->peer.ecn_capable && !chunk->ecn_ce_done) { in sctp_eat_data()
6359 struct sctp_af *af = SCTP_INPUT_CB(chunk->skb)->af; in sctp_eat_data()
6360 chunk->ecn_ce_done = 1; in sctp_eat_data()
6362 if (af->is_ce(sctp_gso_headskb(chunk->skb))) { in sctp_eat_data()
6365 SCTP_U32(tsn)); in sctp_eat_data()
6369 tmp = sctp_tsnmap_check(&asoc->peer.tsn_map, tsn); in sctp_eat_data()
6371 /* The TSN is too high--silently discard the chunk and in sctp_eat_data()
6374 if (chunk->asoc) in sctp_eat_data()
6375 chunk->asoc->stats.outofseqtsns++; in sctp_eat_data()
6379 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_DUP, SCTP_U32(tsn)); in sctp_eat_data()
6383 /* This is a new TSN. */ in sctp_eat_data()
6388 datalen = ntohs(chunk->chunk_hdr->length); in sctp_eat_data()
6389 datalen -= sctp_datachk_len(&asoc->stream); in sctp_eat_data()
6394 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) { in sctp_eat_data()
6407 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6408 (datalen > asoc->rwnd + asoc->frag_point))) { in sctp_eat_data()
6410 /* If this is the next TSN, consider reneging to make in sctp_eat_data()
6417 (sctp_tsnmap_get_ctsn(map) + 1) == tsn) { in sctp_eat_data()
6418 pr_debug("%s: reneging for tsn:%u\n", __func__, tsn); in sctp_eat_data()
6421 pr_debug("%s: discard tsn:%u len:%zu, rwnd:%d\n", in sctp_eat_data()
6422 __func__, tsn, datalen, asoc->rwnd); in sctp_eat_data()
6437 (sctp_tsnmap_get_ctsn(map) + 1) == tsn) { in sctp_eat_data()
6438 pr_debug("%s: under pressure, reneging for tsn:%u\n", in sctp_eat_data()
6439 __func__, tsn); in sctp_eat_data()
6450 * --------------- in sctp_eat_data()
6455 err = sctp_make_abort_no_data(asoc, chunk, tsn); in sctp_eat_data()
6473 chunk->data_accepted = 1; in sctp_eat_data()
6478 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_eat_data()
6480 if (chunk->asoc) in sctp_eat_data()
6481 chunk->asoc->stats.iuodchunks++; in sctp_eat_data()
6484 if (chunk->asoc) in sctp_eat_data()
6485 chunk->asoc->stats.iodchunks++; in sctp_eat_data()
6496 if (ntohs(data_hdr->stream) >= asoc->stream.incnt) { in sctp_eat_data()
6497 /* Mark tsn as received even though we drop it */ in sctp_eat_data()
6498 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_TSN, SCTP_U32(tsn)); in sctp_eat_data()
6501 &data_hdr->stream, in sctp_eat_data()
6502 sizeof(data_hdr->stream), in sctp_eat_data()
6510 /* Check to see if the SSN is possible for this TSN. in sctp_eat_data()
6513 * wrap and for a valid TSN. We can simply check if the current in sctp_eat_data()
6517 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()