Lines Matching +full:local +full:- +full:timer +full:- +full:stop
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>
176 __u16 chunk_length = ntohs(chunk->chunk_hdr->length); in sctp_chunk_length_valid()
179 if (unlikely(chunk->pdiscard)) in sctp_chunk_length_valid()
192 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_err_chunk_valid()
194 return (void *)err == (void *)chunk->chunk_end; in sctp_err_chunk_valid()
206 * that it is in SHUTDOWN-ACK-SENT state, if it is not the chunk should be
207 * discarded. If the endpoint is in the SHUTDOWN-ACK-SENT state the endpoint
208 * should stop the T2-shutdown timer and remove all knowledge of the
214 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
222 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
249 if (!chunk->singleton) in sctp_sf_do_4_C()
257 /* RFC 2960 10.2 SCTP-to-ULP in sctp_sf_do_4_C()
271 * will verify that it is in SHUTDOWN-ACK-SENT state, if it is in sctp_sf_do_4_C()
273 * the SHUTDOWN-ACK-SENT state the endpoint should stop the in sctp_sf_do_4_C()
274 * T2-shutdown timer and remove all knowledge of the in sctp_sf_do_4_C()
339 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
353 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1B_init()
361 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
370 if (sctp_sstate(ep->base.sk, CLOSING)) in sctp_sf_do_5_1B_init()
375 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1B_init()
376 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1B_init()
383 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
385 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
405 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1B_init()
408 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1B_init()
415 if (security_sctp_assoc_request(new_asoc, chunk->skb)) { in sctp_sf_do_5_1B_init()
427 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
438 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
458 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
494 * C) Upon reception of the INIT ACK from "Z", "A" shall stop the T1-init
495 * timer and leave COOKIE-WAIT state. "A" shall then send the State
497 * the T1-cookie timer, and enter the COOKIE-ECHOED state.
536 if (!chunk->singleton) in sctp_sf_do_5_1C_ack()
539 /* Make sure that the INIT-ACK chunk has a valid length */ in sctp_sf_do_5_1C_ack()
544 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1C_ack()
548 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1C_ack()
549 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1C_ack()
561 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1C_ack()
563 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1C_ack()
576 /* SCTP-AUTH, Section 6.3: in sctp_sf_do_5_1C_ack()
592 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
598 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1C_ack()
600 initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_sf_do_5_1C_ack()
605 /* Reset init error count upon receipt of INIT-ACK. */ in sctp_sf_do_5_1C_ack()
608 /* 5.1 C) "A" shall stop the T1-init timer and leave in sctp_sf_do_5_1C_ack()
609 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie in sctp_sf_do_5_1C_ack()
610 * timer, and enter the COOKIE-ECHOED state. in sctp_sf_do_5_1C_ack()
619 /* SCTP-AUTH: generate the association shared keys so that in sctp_sf_do_5_1C_ack()
620 * we can potentially sign the COOKIE-ECHO. in sctp_sf_do_5_1C_ack()
641 if (!chunk->auth_chunk) in sctp_auth_chunk_verify()
644 /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo in sctp_auth_chunk_verify()
652 if (!net->sctp.auth_enable || !asoc->peer.auth_capable) in sctp_auth_chunk_verify()
655 /* set-up our fake chunk so that we can process it */ in sctp_auth_chunk_verify()
656 auth.skb = chunk->auth_chunk; in sctp_auth_chunk_verify()
657 auth.asoc = chunk->asoc; in sctp_auth_chunk_verify()
658 auth.sctp_hdr = chunk->sctp_hdr; in sctp_auth_chunk_verify()
660 skb_push(chunk->auth_chunk, in sctp_auth_chunk_verify()
662 skb_pull(chunk->auth_chunk, sizeof(struct sctp_chunkhdr)); in sctp_auth_chunk_verify()
663 auth.transport = chunk->transport; in sctp_auth_chunk_verify()
686 * - When sending a COOKIE ECHO, the endpoint MUST use the value of the
689 * - The receiver of a COOKIE ECHO follows the procedures in Section 5.
721 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1D_ce()
736 * on the TCP-style socket exceed the max backlog, respond with an in sctp_sf_do_5_1D_ce()
739 sk = ep->base.sk; in sctp_sf_do_5_1D_ce()
747 chunk->subh.cookie_hdr = in sctp_sf_do_5_1D_ce()
748 (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_1D_ce()
749 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_1D_ce()
761 * If the re-build failed, what is the proper error path in sctp_sf_do_5_1D_ce()
764 * [We should abort the association. --piggy] in sctp_sf_do_5_1D_ce()
771 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_1D_ce()
774 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_1D_ce()
779 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_1D_ce()
785 if (security_sctp_assoc_request(new_asoc, chunk->head_skb ?: chunk->skb)) { in sctp_sf_do_5_1D_ce()
792 * Re-build the bind address for the association is done in in sctp_sf_do_5_1D_ce()
795 /* This is a brand-new association, so these are not yet side in sctp_sf_do_5_1D_ce()
796 * effects--it is safe to run them here. in sctp_sf_do_5_1D_ce()
798 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_5_1D_ce()
800 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
804 /* SCTP-AUTH: Now that we've populate required fields in in sctp_sf_do_5_1D_ce()
828 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1D_ce()
829 new_asoc->c.sinit_max_instreams, in sctp_sf_do_5_1D_ce()
839 if (new_asoc->peer.adaptation_ind) { in sctp_sf_do_5_1D_ce()
846 if (!new_asoc->peer.auth_capable) { in sctp_sf_do_5_1D_ce()
856 * during side-effect processing and correctly count established in sctp_sf_do_5_1D_ce()
866 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1D_ce()
906 * COOKIE-ECHOED state to the ESTABLISHED state, stopping the T1-cookie
907 * timer. It may also notify its ULP about the successful
935 chunk->head_skb ?: chunk->skb)) in sctp_sf_do_5_1E_ca()
938 /* Verify that the chunk length for the COOKIE-ACK is OK. in sctp_sf_do_5_1E_ca()
945 /* Reset init error count upon receipt of COOKIE-ACK, in sctp_sf_do_5_1E_ca()
948 * from the COOKIE-ECHOED state to the COOKIE-WAIT in sctp_sf_do_5_1E_ca()
956 * from the COOKIE-ECHOED state to the ESTABLISHED state, in sctp_sf_do_5_1E_ca()
957 * stopping the T1-cookie timer. in sctp_sf_do_5_1E_ca()
966 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1E_ca()
975 0, asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1E_ca()
976 asoc->c.sinit_max_instreams, in sctp_sf_do_5_1E_ca()
989 if (asoc->peer.adaptation_ind) { in sctp_sf_do_5_1E_ca()
998 if (!asoc->peer.auth_capable) { in sctp_sf_do_5_1E_ca()
1048 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_sendbeat_8_3()
1060 * The Sender-specific Heartbeat Info field should normally include in sctp_sf_sendbeat_8_3()
1066 if (transport->param_flags & SPP_HB_ENABLE) { in sctp_sf_sendbeat_8_3()
1096 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_send_reconf()
1107 sctp_chunk_hold(asoc->strreset_chunk); in sctp_sf_send_reconf()
1109 SCTP_CHUNK(asoc->strreset_chunk)); in sctp_sf_send_reconf()
1130 reply = sctp_make_heartbeat(asoc, transport, transport->pl.probe_size); in sctp_sf_send_probe()
1188 chunk->subh.hb_hdr = (struct sctp_heartbeathdr *)chunk->skb->data; in sctp_sf_beat_8_3()
1189 param_hdr = (struct sctp_paramhdr *)chunk->subh.hb_hdr; in sctp_sf_beat_8_3()
1190 paylen = ntohs(chunk->chunk_hdr->length) - sizeof(struct sctp_chunkhdr); in sctp_sf_beat_8_3()
1192 if (ntohs(param_hdr->length) > paylen) in sctp_sf_beat_8_3()
1196 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1254 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1260 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1262 if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo)) in sctp_sf_backbeat_8_3()
1265 from_addr = hbinfo->daddr; in sctp_sf_backbeat_8_3()
1284 /* Validate the 64-bit random nonce. */ in sctp_sf_backbeat_8_3()
1285 if (hbinfo->hb_nonce != link->hb_nonce) in sctp_sf_backbeat_8_3()
1288 if (hbinfo->probe_size) { in sctp_sf_backbeat_8_3()
1289 if (hbinfo->probe_size != link->pl.probe_size || in sctp_sf_backbeat_8_3()
1299 max_interval = link->hbinterval + link->rto; in sctp_sf_backbeat_8_3()
1302 if (time_after(hbinfo->sent_at, jiffies) || in sctp_sf_backbeat_8_3()
1303 time_after(jiffies, hbinfo->sent_at + max_interval)) { in sctp_sf_backbeat_8_3()
1328 struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); in sctp_sf_send_restart_abort()
1343 len = af->to_addr_param(ssa, addrparm); in sctp_sf_send_restart_abort()
1346 errhdr->cause = SCTP_ERROR_RESTART; in sctp_sf_send_restart_abort()
1347 errhdr->length = htons(len); in sctp_sf_send_restart_abort()
1350 ep = sctp_sk(net->sctp.ctl_sock)->ep; in sctp_sf_send_restart_abort()
1379 if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr)) in list_has_sctp_addr()
1393 struct net *net = new_asoc->base.net; in sctp_sf_check_restart_addrs()
1397 /* Implementor's Guide - Section 5.2.2 in sctp_sf_check_restart_addrs()
1408 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1410 if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1411 &new_addr->ipaddr)) { in sctp_sf_check_restart_addrs()
1412 sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, in sctp_sf_check_restart_addrs()
1426 * Note: Do not use in CLOSED or SHUTDOWN-ACK-SENT state.
1431 switch (asoc->state) { in sctp_tietags_populate()
1433 /* 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State */ in sctp_tietags_populate()
1436 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1437 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1438 new_asoc->c.peer_ttag = 0; in sctp_tietags_populate()
1442 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1443 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1444 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1447 /* 5.2.2 Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, in sctp_tietags_populate()
1448 * COOKIE-WAIT and SHUTDOWN-ACK-SENT in sctp_tietags_populate()
1451 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1452 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1460 new_asoc->rwnd = asoc->rwnd; in sctp_tietags_populate()
1461 new_asoc->c.sinit_num_ostreams = asoc->c.sinit_num_ostreams; in sctp_tietags_populate()
1462 new_asoc->c.sinit_max_instreams = asoc->c.sinit_max_instreams; in sctp_tietags_populate()
1463 new_asoc->c.initial_tsn = asoc->c.initial_tsn; in sctp_tietags_populate()
1467 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1479 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1480 (asoc->c.peer_vtag != new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1481 (asoc->c.my_vtag == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1482 (asoc->c.peer_vtag == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1486 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1487 ((asoc->c.peer_vtag != new_asoc->c.peer_vtag) || in sctp_tietags_compare()
1488 (0 == asoc->c.peer_vtag))) { in sctp_tietags_compare()
1493 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1494 (asoc->c.peer_vtag == new_asoc->c.peer_vtag)) in sctp_tietags_compare()
1498 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1499 (asoc->c.peer_vtag == new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1500 (0 == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1501 (0 == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1535 if (!chunk->singleton) in sctp_sf_do_unexpected_init()
1545 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_unexpected_init()
1548 if (SCTP_INPUT_CB(chunk->skb)->encap_port != chunk->transport->encap_port) in sctp_sf_do_unexpected_init()
1552 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_unexpected_init()
1555 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_unexpected_init()
1559 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_unexpected_init()
1560 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_unexpected_init()
1567 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1569 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1599 if (security_sctp_assoc_request(new_asoc, chunk->skb)) { in sctp_sf_do_unexpected_init()
1610 * place (local tie-tag and per tie-tag) within the state cookie. in sctp_sf_do_unexpected_init()
1613 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1618 * restart. Do not do this check for COOKIE-WAIT state, in sctp_sf_do_unexpected_init()
1639 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1660 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1697 * Section: 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State (Item B)
1702 * Upon receipt of an INIT in the COOKIE-WAIT or COOKIE-ECHOED state, an
1710 * After that, the endpoint MUST NOT change its state, the T1-init
1711 * timer shall be left running and the corresponding TCB MUST NOT be
1715 * For an endpoint that is in the COOKIE-ECHOED state it MUST populate
1716 * its Tie-Tags with the Tag information of itself and its peer (see
1717 * section 5.2.2 for a description of the Tie-Tags).
1749 * COOKIE-ECHOED and COOKIE-WAIT
1756 * the Peer's-Tie-Tag and the Local-Tie-Tag. The outbound SCTP packet
1768 * Note: Only when a TCB exists and the association is not in a COOKIE-
1769 * WAIT state are the Tie-Tags populated. For a normal association INIT
1770 * (i.e. the endpoint is in a COOKIE-WAIT state), the Tie-Tags MUST be
1801 * Unexpected INIT-ACK handler.
1805 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1818 * endpoint. If this is an OOTB INIT-ACK, treat it as such. in sctp_sf_do_5_2_3_initack()
1820 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) in sctp_sf_do_5_2_3_initack()
1830 struct net *net = asoc->base.net; in sctp_sf_do_assoc_update()
1847 return -ENOMEM; in sctp_sf_do_assoc_update()
1850 /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A')
1869 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_a()
1870 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_a()
1872 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_a()
1890 /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in sctp_sf_do_dupcook_a()
1898 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1913 /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked in sctp_sf_do_dupcook_a()
1921 /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue in sctp_sf_do_dupcook_a()
1922 * and ASCONF-ACK cache. in sctp_sf_do_dupcook_a()
1938 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_a()
1939 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_a()
1947 (sctp_sstate(asoc->base.sk, CLOSING) || in sctp_sf_do_dupcook_a()
1948 sock_flag(asoc->base.sk, SOCK_DEAD))) { in sctp_sf_do_dupcook_a()
1970 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'B')
1975 * after responding to the local endpoint's INIT
1989 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_b()
1990 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_b()
1992 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_b()
2005 if (asoc->state < SCTP_STATE_ESTABLISHED) in sctp_sf_do_dupcook_b()
2025 * Sadly, this needs to be implemented as a side-effect, because in sctp_sf_do_dupcook_b()
2041 if (asoc->peer.adaptation_ind) in sctp_sf_do_dupcook_b()
2044 if (!asoc->peer.auth_capable) in sctp_sf_do_dupcook_b()
2053 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'C')
2056 * C) In this case, the local endpoint's cookie has arrived late.
2057 * Before it arrived, the local endpoint sent an INIT and received an
2058 * INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
2077 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2081 * D) When both local and remote tags match the endpoint should always
2097 * D) When both local and remote tags match the endpoint should in sctp_sf_do_dupcook_d()
2098 * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state. in sctp_sf_do_dupcook_d()
2099 * It should stop any cookie timer that may be running and send in sctp_sf_do_dupcook_d()
2107 if (asoc->state < SCTP_STATE_ESTABLISHED) { in sctp_sf_do_dupcook_d()
2125 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_d()
2126 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_d()
2136 if (asoc->peer.adaptation_ind) { in sctp_sf_do_dupcook_d()
2144 if (!asoc->peer.auth_capable) { in sctp_sf_do_dupcook_d()
2182 * Handle a duplicate COOKIE-ECHO. This usually means a cookie-carrying
2226 chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_2_4_dupcook()
2227 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_2_4_dupcook()
2240 * If the re-build failed, what is the proper error path in sctp_sf_do_5_2_4_dupcook()
2243 * [We should abort the association. --piggy] in sctp_sf_do_5_2_4_dupcook()
2250 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_2_4_dupcook()
2253 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_2_4_dupcook()
2257 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_2_4_dupcook()
2264 new_asoc->temp = 1; in sctp_sf_do_5_2_4_dupcook()
2280 chunk->head_skb ?: chunk->skb)) { in sctp_sf_do_5_2_4_dupcook()
2330 * Process an ABORT. (SHUTDOWN-PENDING state)
2360 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_pending_abort()
2366 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2376 * Process an ABORT. (SHUTDOWN-SENT state)
2406 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_sent_abort()
2412 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2418 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_abort()
2422 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_abort()
2430 * Process an ABORT. (SHUTDOWN-ACK-SENT state)
2442 /* The same T2 timer, so we should be able to use in sctp_sf_shutdown_ack_sent_abort()
2443 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_abort()
2484 /* FUTURE FIXME: When PR-SCTP related and other optional in sctp_sf_cookie_echoed_err()
2488 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2489 if (SCTP_ERROR_STALE_COOKIE == err->cause) in sctp_sf_cookie_echoed_err()
2506 * If the association is in the COOKIE-ECHOED state, the endpoint may elect
2535 int attempts = asoc->init_err_counter + 1; in sctp_sf_do_5_2_6_stale()
2542 if (attempts > asoc->max_init_attempts) { in sctp_sf_do_5_2_6_stale()
2550 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2559 * Suggested Cookie Life-span Increment's unit is msec. in sctp_sf_do_5_2_6_stale()
2574 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_do_5_2_6_stale()
2584 /* Stop pending T3-rtx and heartbeat timers */ in sctp_sf_do_5_2_6_stale()
2588 /* Delete non-primary peer ip addresses since we are transitioning in sctp_sf_do_5_2_6_stale()
2589 * back to the COOKIE-WAIT state in sctp_sf_do_5_2_6_stale()
2593 /* If we've sent any data bundled with COOKIE-ECHO we will need to in sctp_sf_do_5_2_6_stale()
2597 SCTP_TRANSPORT(asoc->peer.primary_path)); in sctp_sf_do_5_2_6_stale()
2630 * - The endpoint shall always fill in the Verification Tag field of the
2634 * - If the ABORT is sent in response to an OOTB packet, the endpoint
2637 * - The receiver MUST accept the packet if the Verification Tag
2676 /* ADD-IP: Special case for ABORT chunks in sctp_sf_do_9_1_abort()
2682 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_do_9_1_abort()
2704 len = ntohs(chunk->chunk_hdr->length); in __sctp_sf_do_9_1_abort()
2706 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in __sctp_sf_do_9_1_abort()
2718 * Process an ABORT. (COOKIE-WAIT state)
2751 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_cookie_wait_abort()
2753 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in sctp_sf_cookie_wait_abort()
2756 chunk->transport); in sctp_sf_cookie_wait_abort()
2760 * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state)
2776 * Process an ABORT. (COOKIE-ECHOED state)
2786 /* There is a single T1 timer, so we should be able to use in sctp_sf_cookie_echoed_abort()
2787 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_abort()
2793 * Stop T1 timer and abort association with "INIT failed".
2824 * - enter the SHUTDOWN-RECEIVED state,
2826 * - stop accepting new data from its SCTP user
2828 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2832 * Once an endpoint as reached the SHUTDOWN-RECEIVED state it MUST NOT
2875 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shutdown()
2876 skb_pull(chunk->skb, sizeof(*sdh)); in sctp_sf_do_9_2_shutdown()
2877 chunk->subh.shutdown_hdr = sdh; in sctp_sf_do_9_2_shutdown()
2878 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shutdown()
2880 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shutdown()
2882 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shutdown()
2891 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shutdown()
2906 * - enter the SHUTDOWN-RECEIVED state, in sctp_sf_do_9_2_shutdown()
2907 * - stop accepting new data from its SCTP user in sctp_sf_do_9_2_shutdown()
2915 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_shutdown()
2923 /* - verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shutdown()
2928 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2937 * Once an endpoint has reached the SHUTDOWN-RECEIVED state,
2962 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2963 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shut_ctsn()
2965 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shut_ctsn()
2967 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shut_ctsn()
2976 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shut_ctsn()
2984 SCTP_BE32(sdh->cum_tsn_ack)); in sctp_sf_do_9_2_shut_ctsn()
2990 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
3019 * the T2-SHUTDOWN timer. in __sctp_sf_do_9_2_reshutack()
3023 /* and restart the T2-shutdown timer. */ in __sctp_sf_do_9_2_reshutack()
3042 if (!chunk->singleton) in sctp_sf_do_9_2_reshutack()
3048 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_9_2_reshutack()
3097 cwr = (struct sctp_cwrhdr *)chunk->skb->data; in sctp_sf_do_ecn_cwr()
3098 skb_pull(chunk->skb, sizeof(*cwr)); in sctp_sf_do_ecn_cwr()
3100 lowest_tsn = ntohl(cwr->lowest_tsn); in sctp_sf_do_ecn_cwr()
3103 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) { in sctp_sf_do_ecn_cwr()
3104 /* Stop sending ECNE. */ in sctp_sf_do_ecn_cwr()
3117 * ECN-Echo
3151 ecne = (struct sctp_ecnehdr *)chunk->skb->data; in sctp_sf_do_ecne()
3152 skb_pull(chunk->skb, sizeof(*ecne)); in sctp_sf_do_ecne()
3156 SCTP_U32(ntohl(ecne->lowest_tsn))); in sctp_sf_do_ecne()
3208 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_6_2()
3228 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_6_2()
3229 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_6_2()
3234 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3237 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_data_6_2()
3264 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3284 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3289 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3299 * (4) In SHUTDOWN-SENT state the endpoint MUST acknowledge any received
3328 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_fast_4_4()
3344 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_fast_4_4()
3345 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_fast_4_4()
3354 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_data_fast_4_4()
3356 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_data_fast_4_4()
3358 if (chunk->end_of_packet) { in sctp_sf_eat_data_fast_4_4()
3378 * Cumulative TSN Ack Point indicates an out-of-order SACK.
3389 * timer is running for the destination address to which the DATA
3390 * chunk was originally transmitted, then T3-rtx is started for
3427 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3428 ctsn = ntohl(sackh->cum_tsn_ack); in sctp_sf_eat_sack_6_2()
3434 if (TSN_lte(asoc->next_tsn, ctsn)) in sctp_sf_eat_sack_6_2()
3443 * Point indicates an out-of-order SACK. in sctp_sf_eat_sack_6_2()
3445 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_eat_sack_6_2()
3447 asoc->ctsn_ack_point); in sctp_sf_eat_sack_6_2()
3470 * packet and set the T-bit in the Chunk Flags to indicate that the
3504 /* Reflect vtag if T-Bit is set */ in sctp_sf_tabort_8_4_8()
3506 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3509 abort->skb->sk = ep->base.sk; in sctp_sf_tabort_8_4_8()
3524 * From Section 4 at draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.
3548 abort->skb->sk = ep->base.sk; in sctp_sf_new_encap_port()
3565 * API 5.3.1.3 - SCTP_REMOTE_ERROR
3586 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_sf_operr_notify()
3587 if ((void *)err != (void *)chunk->chunk_end) in sctp_sf_operr_notify()
3602 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3646 * stop the T2-shutdown timer, in sctp_sf_do_9_2_final()
3671 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3678 * set the T-bit in the Chunk Flags to indicate that the Verification
3685 * packet and set the T-bit in the Chunk Flags to indicate that the
3697 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3709 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3712 if (ntohs(ch->length) < sizeof(*ch)) in sctp_sf_ootb()
3717 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); in sctp_sf_ootb()
3725 if (SCTP_CID_SHUTDOWN_ACK == ch->type) in sctp_sf_ootb()
3733 if (SCTP_CID_ABORT == ch->type) in sctp_sf_ootb()
3741 if (SCTP_CID_COOKIE_ACK == ch->type) in sctp_sf_ootb()
3744 if (SCTP_CID_ERROR == ch->type) { in sctp_sf_ootb()
3746 if (SCTP_ERROR_STALE_COOKIE == err->cause) { in sctp_sf_ootb()
3774 * set the T-bit in the Chunk Flags to indicate that the Verification
3810 /* Reflect vtag if T-Bit is set */ in sctp_sf_shut_8_4_5()
3812 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3815 shut->skb->sk = ep->base.sk; in sctp_sf_shut_8_4_5()
3835 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the
3839 * chunks. --piggy ]
3894 /* ADD-IP: Section 4.1.1 in sctp_sf_do_asconf()
3896 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3898 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf()
3900 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf()
3901 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3904 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3905 serial = ntohl(hdr->serial); in sctp_sf_do_asconf()
3914 * 'Peer-Serial-Number'. in sctp_sf_do_asconf()
3916 if (serial == asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3918 * we can clean our old ASCONF-ACKs. in sctp_sf_do_asconf()
3920 if (!chunk->has_asconf) in sctp_sf_do_asconf()
3925 * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to in sctp_sf_do_asconf()
3929 * Essentially, do V1-V5. in sctp_sf_do_asconf()
3935 } else if (serial < asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3938 * ('Peer- Sequence-Number' + 1), simply skip to the next in sctp_sf_do_asconf()
3940 * any previously cached ASCONF-ACK response that was in sctp_sf_do_asconf()
3942 * ASCONF. Note: It is possible that no cached ASCONF-ACK in sctp_sf_do_asconf()
3945 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3948 asconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial); in sctp_sf_do_asconf()
3956 asconf_ack->transport = NULL; in sctp_sf_do_asconf()
3965 * containing the ASCONF-ACK Chunks MUST be the source address of in sctp_sf_do_asconf()
3973 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
3975 if (asoc->new_transport) { in sctp_sf_do_asconf()
3976 sctp_sf_heartbeat(ep, asoc, type, asoc->new_transport, commands); in sctp_sf_do_asconf()
3977 ((struct sctp_association *)asoc)->new_transport = NULL; in sctp_sf_do_asconf()
3993 if (list_empty(&asoc->addip_chunk_list)) in sctp_send_next_asconf()
3996 entry = asoc->addip_chunk_list.next; in sctp_send_next_asconf()
4001 asoc->addip_last_asconf = asconf; in sctp_send_next_asconf()
4018 struct sctp_chunk *last_asconf = asoc->addip_last_asconf; in sctp_sf_do_asconf_ack()
4037 /* ADD-IP, Section 4.1.2: in sctp_sf_do_asconf_ack()
4039 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf_ack()
4041 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf_ack()
4043 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf_ack()
4044 (!net->sctp.addip_noauth && !asconf_ack->auth)) in sctp_sf_do_asconf_ack()
4047 addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data; in sctp_sf_do_asconf_ack()
4048 rcvd_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4050 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
4056 addip_hdr = last_asconf->subh.addip_hdr; in sctp_sf_do_asconf_ack()
4057 sent_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4059 sent_serial = asoc->addip_serial - 1; in sctp_sf_do_asconf_ack()
4062 /* D0) If an endpoint receives an ASCONF-ACK that is greater than or in sctp_sf_do_asconf_ack()
4065 * sequence number is greater than if it is no more than 2^^31-1 in sctp_sf_do_asconf_ack()
4069 !(asoc->addip_last_asconf)) { in sctp_sf_do_asconf_ack()
4077 /* We are going to ABORT, so we might as well stop in sctp_sf_do_asconf_ack()
4092 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { in sctp_sf_do_asconf_ack()
4109 /* We are going to ABORT, so we might as well stop in sctp_sf_do_asconf_ack()
4125 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
4153 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4158 if (param.p->type == SCTP_PARAM_RESET_OUT_REQUEST) in sctp_sf_do_reconf()
4161 else if (param.p->type == SCTP_PARAM_RESET_IN_REQUEST) in sctp_sf_do_reconf()
4164 else if (param.p->type == SCTP_PARAM_RESET_TSN_REQUEST) in sctp_sf_do_reconf()
4167 else if (param.p->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) in sctp_sf_do_reconf()
4170 else if (param.p->type == SCTP_PARAM_RESET_ADD_IN_STREAMS) in sctp_sf_do_reconf()
4173 else if (param.p->type == SCTP_PARAM_RESET_RESPONSE) in sctp_sf_do_reconf()
4190 * PR-SCTP Section 3.6 Receiver Side Implementation of PR-SCTP
4196 * After the above processing, the data receiver MUST stop reporting any
4221 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn()
4225 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn()
4229 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn()
4230 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn()
4231 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn()
4232 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn()
4233 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn()
4235 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn()
4238 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn()
4241 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn()
4244 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4248 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn()
4253 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_fwd_tsn()
4288 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn_fast()
4292 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn_fast()
4296 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn_fast()
4297 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn_fast()
4298 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn_fast()
4299 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn_fast()
4300 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn_fast()
4302 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn_fast()
4305 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn_fast()
4308 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn_fast()
4311 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4315 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn_fast()
4323 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_fwd_tsn_fast()
4325 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_fwd_tsn_fast()
4336 * SCTP-AUTH Section 6.3 Receiving authenticated chunks
4340 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4369 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_authenticate()
4370 chunk->subh.auth_hdr = auth_hdr; in sctp_sf_authenticate()
4371 skb_pull(chunk->skb, sizeof(*auth_hdr)); in sctp_sf_authenticate()
4376 if (!sctp_auth_asoc_verify_hmac_id(asoc, auth_hdr->hmac_id)) in sctp_sf_authenticate()
4382 key_id = ntohs(auth_hdr->shkey_id); in sctp_sf_authenticate()
4383 if (key_id != asoc->active_key_id) { in sctp_sf_authenticate()
4392 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4394 hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); in sctp_sf_authenticate()
4395 if (sig_len != hmac->hmac_len) in sctp_sf_authenticate()
4406 skb_pull(chunk->skb, sig_len); in sctp_sf_authenticate()
4414 sctp_auth_calculate_hmac(asoc, chunk->skb, in sctp_sf_authenticate()
4415 (struct sctp_auth_chunk *)chunk->chunk_hdr, in sctp_sf_authenticate()
4425 chunk->auth = 1; in sctp_sf_authenticate()
4444 if (!asoc->peer.auth_capable) in sctp_sf_eat_auth()
4458 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4467 &auth_hdr->hmac_id, in sctp_sf_eat_auth()
4489 if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { in sctp_sf_eat_auth()
4492 ev = sctp_ulpevent_make_authkey(asoc, ntohs(auth_hdr->shkey_id), in sctp_sf_eat_auth()
4510 * Chunk Types are encoded such that the highest-order two bits specify
4514 * 00 - Stop processing this SCTP packet and discard it, do not process
4517 * 01 - Stop processing this SCTP packet and discard it, do not process
4521 * 10 - Skip this chunk and continue processing.
4523 * 11 - Skip this chunk and continue processing, but report in an ERROR
4558 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4561 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4576 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4579 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4714 /* SCTP-AUTH, Section 6.3: in sctp_sf_abort_violation()
4734 /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ in sctp_sf_abort_violation()
4735 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4736 !asoc->peer.i.init_tag) { in sctp_sf_abort_violation()
4739 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4741 abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T; in sctp_sf_abort_violation()
4745 inittag = ntohl(initack->init_hdr.init_tag); in sctp_sf_abort_violation()
4754 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { in sctp_sf_abort_violation()
4775 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4777 abort->skb->sk = ep->base.sk; in sctp_sf_abort_violation()
4896 * when we have an association and we receive bundled INIT-ACK, or
4897 * SHUTDOWN-COMPLETE, our peer is clearly violating the "MUST NOT bundle"
4920 * Section: 10.1 ULP-to-SCTP
4923 * Format: ASSOCIATE(local SCTP instance name, destination transport addr,
4925 * -> association id [,destination transport addr list] [,outbound stream
4932 * which defines the endpoint (see Section 1.4). If the local SCTP
4939 * An association id, which is a local handle to the SCTP association,
4948 * outbound stream count of the local endpoint. One of the transport
4950 * the local endpoint as default primary path for sending SCTP packets
4954 * stuff happens when the INIT ACK arrives. This is a NON-BLOCKING
4959 * o local SCTP instance name - obtained from the INITIALIZE operation.
4961 * o destination transport addr - specified as one of the transport
4964 * [This is asoc->peer.active_path.]
4965 * o outbound stream count - the number of outbound streams the ULP
4984 /* The comment below says that we enter COOKIE-WAIT AFTER in sctp_sf_do_prm_asoc()
4999 repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); in sctp_sf_do_prm_asoc()
5013 /* After sending the INIT, "A" starts the T1-init timer and in sctp_sf_do_prm_asoc()
5014 * enters the COOKIE-WAIT state. in sctp_sf_do_prm_asoc()
5028 * Section: 10.1 ULP-to-SCTP
5033 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
5034 * -> result
5040 * o association id - local handle to the SCTP association
5042 * o buffer address - the location where the user message to be
5045 * o byte count - The size of the user data in number of bytes;
5049 * o context - an optional 32 bit integer that will be carried in the
5053 * o stream id - to indicate which stream to send the data on. If not
5056 * o life time - specifies the life time of the user data. The user data
5065 * o destination transport address - specified as one of the destination
5071 * o unorder flag - this flag, if present, indicates that the user
5076 * o no-bundle flag - instructs SCTP not to bundle this user data with
5080 * o payload protocol-id - A 32 bit unsigned integer that is to be
5106 * -> result
5117 * o association id - local handle to the SCTP association
5137 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_do_9_2_prm_shutdown()
5147 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_prm_shutdown()
5162 * -> result
5172 * o association id - local handle to the SCTP association
5176 * o cause code - reason of the abort to be passed to the peer
5227 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_ERROR, SCTP_ERROR(-EINVAL)); in sctp_sf_error_closed()
5243 SCTP_ERROR(-ESHUTDOWN)); in sctp_sf_error_shutdown()
5304 /* There is a single T1 timer, so we should be able to use in sctp_sf_cookie_echoed_prm_shutdown()
5305 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_shutdown()
5334 /* Stop T1-init timer */ in sctp_sf_cookie_wait_prm_abort()
5381 /* There is a single T1 timer, so we should be able to use in sctp_sf_cookie_echoed_prm_abort()
5382 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_abort()
5394 * state table when someone issues an abort while in SHUTDOWN-PENDING state.
5407 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_pending_prm_abort()
5421 * state table when someone issues an abort while in SHUTDOWN-SENT state.
5434 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_prm_abort()
5438 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_prm_abort()
5465 /* The same T2 timer, so we should be able to use in sctp_sf_shutdown_ack_sent_prm_abort()
5466 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_prm_abort()
5474 * 10.1 ULP-to-SCTP
5479 * -> result
5481 * Instructs the local endpoint to perform a HeartBeat on the specified
5488 * o association id - local handle to the SCTP association
5490 * o destination transport address - the transport address of the
5508 * D) Request an on-demand HEARTBEAT on a specific destination in sctp_sf_do_prm_requestheartbeat()
5542 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5611 * It shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT
5612 * state. If the timer expires, the endpoint must re-send the SHUTDOWN
5637 * T2-shutdown timer. in sctp_sf_do_9_2_start_shutdown()
5641 /* It shall then start the T2-shutdown timer */ in sctp_sf_do_9_2_start_shutdown()
5646 * The sender of the SHUTDOWN MAY also start an overall guard timer in sctp_sf_do_9_2_start_shutdown()
5647 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. in sctp_sf_do_9_2_start_shutdown()
5652 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_start_shutdown()
5656 /* and enter the SHUTDOWN-SENT state. */ in sctp_sf_do_9_2_start_shutdown()
5660 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_start_shutdown()
5663 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_start_shutdown()
5681 * shall send a SHUTDOWN ACK and start a T2-shutdown timer of its own,
5682 * entering the SHUTDOWN-ACK-SENT state. If the timer expires, the
5683 * endpoint must re-send the SHUTDOWN ACK.
5725 * the T2-shutdown timer. in sctp_sf_do_9_2_shutdown_ack()
5729 /* and start/restart a T2-shutdown timer of its own, */ in sctp_sf_do_9_2_shutdown_ack()
5733 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_shutdown_ack()
5737 /* Enter the SHUTDOWN-ACK-SENT state. */ in sctp_sf_do_9_2_shutdown_ack()
5741 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_shutdown_ack()
5744 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_shutdown_ack()
5781 * Section: 6.3.3 Handle T3-rtx Expiration
5783 * Whenever the retransmission timer T3-rtx expires for a destination
5800 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_do_6_3_3_rtx()
5801 if (asoc->peer.zero_window_announced && in sctp_sf_do_6_3_3_rtx()
5802 asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { in sctp_sf_do_6_3_3_rtx()
5808 * shutdown guard timer to give the receiver one last in sctp_sf_do_6_3_3_rtx()
5826 /* E1) For the destination address for which the timer in sctp_sf_do_6_3_3_rtx()
5828 * 7.2.3 and set the cwnd <- MTU. in sctp_sf_do_6_3_3_rtx()
5831 /* E2) For the destination address for which the timer in sctp_sf_do_6_3_3_rtx()
5832 * expires, set RTO <- RTO * 2 ("back off the timer"). The in sctp_sf_do_6_3_3_rtx()
5839 * T3-rtx has expired will fit into a single packet, subject in sctp_sf_do_6_3_3_rtx()
5843 * which the timer expires [see Section 6.4]). Call this in sctp_sf_do_6_3_3_rtx()
5848 * which the T3-rtx timer expired but did not fit in one MTU in sctp_sf_do_6_3_3_rtx()
5898 * 2) If the T1-init timer expires, the endpoint MUST retransmit INIT
5899 * and re-start the T1-init timer without changing state. This MUST
5916 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_init_timer_expire()
5920 pr_debug("%s: timer T1 expired (INIT)\n", __func__); in sctp_sf_t1_init_timer_expire()
5924 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_init_timer_expire()
5925 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_t1_init_timer_expire()
5942 asoc->max_init_attempts); in sctp_sf_t1_init_timer_expire()
5963 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
5964 * COOKIE ECHO and re-start the T1-cookie timer without changing
5981 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_cookie_timer_expire()
5984 pr_debug("%s: timer T1 expired (COOKIE-ECHO)\n", __func__); in sctp_sf_t1_cookie_timer_expire()
5988 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_cookie_timer_expire()
6011 /* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
6021 * the T2-Shutdown timer, giving its peer ample opportunity to transmit
6034 pr_debug("%s: timer T2 expired\n", __func__); in sctp_sf_t2_timer_expire()
6038 ((struct sctp_association *)asoc)->shutdown_retries++; in sctp_sf_t2_timer_expire()
6040 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t2_timer_expire()
6051 switch (asoc->state) { in sctp_sf_t2_timer_expire()
6072 if (asoc->shutdown_last_sent_to) in sctp_sf_t2_timer_expire()
6074 SCTP_TRANSPORT(asoc->shutdown_last_sent_to)); in sctp_sf_t2_timer_expire()
6077 * the T2-shutdown timer. in sctp_sf_t2_timer_expire()
6081 /* Restart the T2-shutdown timer. */ in sctp_sf_t2_timer_expire()
6093 * If the T4 RTO timer expires the endpoint should do B1 to B5
6103 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire()
6104 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
6116 /* Reconfig T4 timer and transport. */ in sctp_sf_t4_timer_expire()
6124 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t4_timer_expire()
6136 /* ADDIP 4.1 B3) Back-off the destination address RTO value to which in sctp_sf_t4_timer_expire()
6137 * the ASCONF chunk was sent by doubling the RTO timer value. in sctp_sf_t4_timer_expire()
6141 /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible in sctp_sf_t4_timer_expire()
6147 sctp_chunk_hold(asoc->addip_last_asconf); in sctp_sf_t4_timer_expire()
6149 SCTP_CHUNK(asoc->addip_last_asconf)); in sctp_sf_t4_timer_expire()
6151 /* ADDIP 4.1 B5) Restart the T-4 RTO timer. Note that if a different in sctp_sf_t4_timer_expire()
6161 /* sctpimpguide-05 Section 2.12.2
6162 * The sender of the SHUTDOWN MAY also start an overall guard timer
6163 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
6164 * At the expiration of this timer the sender SHOULD abort the association
6177 pr_debug("%s: timer T5 expired\n", __func__); in sctp_sf_t5_timer_expire()
6199 /* Handle expiration of AUTOCLOSE timer. When the autoclose timer expires,
6218 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_autoclose_timer_expire()
6228 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_autoclose_timer_expire()
6275 * This table entry represents the firing of a timer in the wrong state.
6276 * Since timer deletion cannot be guaranteed a timer 'may' end up firing
6278 * be ignored, so as to prevent any rearming of the timer.
6292 pr_debug("%s: timer %d ignored\n", __func__, type.chunk); in sctp_sf_timer_ignore()
6312 sack = (struct sctp_sackhdr *) chunk->skb->data; in sctp_sm_pull_sack()
6314 num_blocks = ntohs(sack->num_gap_ack_blocks); in sctp_sm_pull_sack()
6315 num_dup_tsns = ntohs(sack->num_dup_tsns); in sctp_sm_pull_sack()
6318 if (len > chunk->skb->len) in sctp_sm_pull_sack()
6321 skb_pull(chunk->skb, len); in sctp_sm_pull_sack()
6351 /* Reflect vtag if T-Bit is set */ in sctp_abort_pkt_new()
6353 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6361 abort->skb->sk = ep->base.sk; in sctp_abort_pkt_new()
6382 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6383 dport = ntohs(chunk->sctp_hdr->source); in sctp_ootb_pkt_new()
6385 /* The V-tag is going to be the same as the inbound packet if no in sctp_ootb_pkt_new()
6389 /* Special case the INIT-ACK as there is no peer's vtag in sctp_ootb_pkt_new()
6392 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6398 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6399 vtag = ntohl(initack->init_hdr.init_tag); in sctp_ootb_pkt_new()
6403 vtag = asoc->peer.i.init_tag; in sctp_ootb_pkt_new()
6410 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6415 init = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6416 vtag = ntohl(init->init_hdr.init_tag); in sctp_ootb_pkt_new()
6420 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6430 transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_ootb_pkt_new()
6435 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6436 sctp_sk(net->sctp.ctl_sock)); in sctp_ootb_pkt_new()
6438 packet = &transport->packet; in sctp_ootb_pkt_new()
6451 sctp_transport_free(packet->transport); in sctp_ootb_pkt_free()
6470 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6471 packet->vtag = cookie->c.peer_vtag; in sctp_send_stale_cookie_err()
6474 err_chunk->skb->sk = ep->base.sk; in sctp_send_stale_cookie_err()
6490 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_eat_data()
6491 struct sock *sk = asoc->base.sk; in sctp_eat_data()
6500 data_hdr = (struct sctp_datahdr *)chunk->skb->data; in sctp_eat_data()
6501 chunk->subh.data_hdr = data_hdr; in sctp_eat_data()
6502 skb_pull(chunk->skb, sctp_datahdr_len(&asoc->stream)); in sctp_eat_data()
6504 tsn = ntohl(data_hdr->tsn); in sctp_eat_data()
6507 /* ASSERT: Now skb->data is really the user data. */ in sctp_eat_data()
6519 if (asoc->peer.ecn_capable && !chunk->ecn_ce_done) { in sctp_eat_data()
6520 struct sctp_af *af = SCTP_INPUT_CB(chunk->skb)->af; in sctp_eat_data()
6521 chunk->ecn_ce_done = 1; in sctp_eat_data()
6523 if (af->is_ce(sctp_gso_headskb(chunk->skb))) { in sctp_eat_data()
6530 tmp = sctp_tsnmap_check(&asoc->peer.tsn_map, tsn); in sctp_eat_data()
6532 /* The TSN is too high--silently discard the chunk and in sctp_eat_data()
6535 if (chunk->asoc) in sctp_eat_data()
6536 chunk->asoc->stats.outofseqtsns++; in sctp_eat_data()
6549 datalen = ntohs(chunk->chunk_hdr->length); in sctp_eat_data()
6550 datalen -= sctp_datachk_len(&asoc->stream); in sctp_eat_data()
6555 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) { in sctp_eat_data()
6568 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6569 (datalen > asoc->rwnd + asoc->frag_point))) { in sctp_eat_data()
6583 __func__, tsn, datalen, asoc->rwnd); in sctp_eat_data()
6609 * --------------- in sctp_eat_data()
6619 /* We are going to ABORT, so we might as well stop in sctp_eat_data()
6632 chunk->data_accepted = 1; in sctp_eat_data()
6637 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_eat_data()
6639 if (chunk->asoc) in sctp_eat_data()
6640 chunk->asoc->stats.iuodchunks++; in sctp_eat_data()
6643 if (chunk->asoc) in sctp_eat_data()
6644 chunk->asoc->stats.iodchunks++; in sctp_eat_data()
6655 if (ntohs(data_hdr->stream) >= asoc->stream.incnt) { in sctp_eat_data()
6660 &data_hdr->stream, in sctp_eat_data()
6661 sizeof(data_hdr->stream), in sctp_eat_data()
6676 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()