Lines Matching +full:max +full:- +full:heartbeat +full:- +full:sec
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>
175 __u16 chunk_length = ntohs(chunk->chunk_hdr->length); in sctp_chunk_length_valid()
178 if (unlikely(chunk->pdiscard)) in sctp_chunk_length_valid()
191 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_err_chunk_valid()
193 return (void *)err == (void *)chunk->chunk_end; in sctp_err_chunk_valid()
205 * that it is in SHUTDOWN-ACK-SENT state, if it is not the chunk should be
206 * discarded. If the endpoint is in the SHUTDOWN-ACK-SENT state the endpoint
207 * should stop the T2-shutdown timer and remove all knowledge of the
213 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
221 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
248 if (!chunk->singleton) in sctp_sf_do_4_C()
256 /* RFC 2960 10.2 SCTP-to-ULP in sctp_sf_do_4_C()
270 * will verify that it is in SHUTDOWN-ACK-SENT state, if it is in sctp_sf_do_4_C()
272 * the SHUTDOWN-ACK-SENT state the endpoint should stop the in sctp_sf_do_4_C()
273 * T2-shutdown timer and remove all knowledge of the in sctp_sf_do_4_C()
338 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
352 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1B_init()
360 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
369 if (sctp_sstate(ep->base.sk, CLOSING)) in sctp_sf_do_5_1B_init()
374 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1B_init()
375 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1B_init()
382 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
384 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
404 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1B_init()
407 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1B_init()
414 if (security_sctp_assoc_request(new_asoc, chunk->skb)) { in sctp_sf_do_5_1B_init()
426 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
437 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
457 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
493 * C) Upon reception of the INIT ACK from "Z", "A" shall stop the T1-init
494 * timer and leave COOKIE-WAIT state. "A" shall then send the State
496 * the T1-cookie timer, and enter the COOKIE-ECHOED state.
535 if (!chunk->singleton) in sctp_sf_do_5_1C_ack()
538 /* Make sure that the INIT-ACK chunk has a valid length */ in sctp_sf_do_5_1C_ack()
543 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1C_ack()
547 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1C_ack()
548 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1C_ack()
560 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1C_ack()
562 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1C_ack()
575 /* SCTP-AUTH, Section 6.3: in sctp_sf_do_5_1C_ack()
591 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
597 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1C_ack()
599 initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_sf_do_5_1C_ack()
604 /* Reset init error count upon receipt of INIT-ACK. */ in sctp_sf_do_5_1C_ack()
607 /* 5.1 C) "A" shall stop the T1-init timer and leave in sctp_sf_do_5_1C_ack()
608 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie in sctp_sf_do_5_1C_ack()
609 * timer, and enter the COOKIE-ECHOED state. in sctp_sf_do_5_1C_ack()
618 /* SCTP-AUTH: generate the association shared keys so that in sctp_sf_do_5_1C_ack()
619 * we can potentially sign the COOKIE-ECHO. in sctp_sf_do_5_1C_ack()
640 if (!chunk->auth_chunk) in sctp_auth_chunk_verify()
643 /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo in sctp_auth_chunk_verify()
651 if (!net->sctp.auth_enable || !asoc->peer.auth_capable) in sctp_auth_chunk_verify()
654 /* set-up our fake chunk so that we can process it */ in sctp_auth_chunk_verify()
655 auth.skb = chunk->auth_chunk; in sctp_auth_chunk_verify()
656 auth.asoc = chunk->asoc; in sctp_auth_chunk_verify()
657 auth.sctp_hdr = chunk->sctp_hdr; in sctp_auth_chunk_verify()
659 skb_push(chunk->auth_chunk, in sctp_auth_chunk_verify()
661 skb_pull(chunk->auth_chunk, sizeof(struct sctp_chunkhdr)); in sctp_auth_chunk_verify()
662 auth.transport = chunk->transport; in sctp_auth_chunk_verify()
685 * - When sending a COOKIE ECHO, the endpoint MUST use the value of the
688 * - The receiver of a COOKIE ECHO follows the procedures in Section 5.
720 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1D_ce()
735 * on the TCP-style socket exceed the max backlog, respond with an in sctp_sf_do_5_1D_ce()
738 sk = ep->base.sk; in sctp_sf_do_5_1D_ce()
746 chunk->subh.cookie_hdr = in sctp_sf_do_5_1D_ce()
747 (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_1D_ce()
748 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_1D_ce()
760 * If the re-build failed, what is the proper error path in sctp_sf_do_5_1D_ce()
763 * [We should abort the association. --piggy] in sctp_sf_do_5_1D_ce()
770 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_1D_ce()
773 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_1D_ce()
778 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_1D_ce()
784 if (security_sctp_assoc_request(new_asoc, chunk->head_skb ?: chunk->skb)) { in sctp_sf_do_5_1D_ce()
791 * Re-build the bind address for the association is done in in sctp_sf_do_5_1D_ce()
794 /* This is a brand-new association, so these are not yet side in sctp_sf_do_5_1D_ce()
795 * effects--it is safe to run them here. in sctp_sf_do_5_1D_ce()
797 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_5_1D_ce()
799 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
803 /* SCTP-AUTH: Now that we've populate required fields in in sctp_sf_do_5_1D_ce()
827 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1D_ce()
828 new_asoc->c.sinit_max_instreams, in sctp_sf_do_5_1D_ce()
838 if (new_asoc->peer.adaptation_ind) { in sctp_sf_do_5_1D_ce()
845 if (!new_asoc->peer.auth_capable) { in sctp_sf_do_5_1D_ce()
855 * during side-effect processing and correctly count established in sctp_sf_do_5_1D_ce()
865 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1D_ce()
905 * COOKIE-ECHOED state to the ESTABLISHED state, stopping the T1-cookie
934 chunk->head_skb ?: chunk->skb)) in sctp_sf_do_5_1E_ca()
937 /* Verify that the chunk length for the COOKIE-ACK is OK. in sctp_sf_do_5_1E_ca()
944 /* Reset init error count upon receipt of COOKIE-ACK, in sctp_sf_do_5_1E_ca()
947 * from the COOKIE-ECHOED state to the COOKIE-WAIT in sctp_sf_do_5_1E_ca()
955 * from the COOKIE-ECHOED state to the ESTABLISHED state, in sctp_sf_do_5_1E_ca()
956 * stopping the T1-cookie timer. in sctp_sf_do_5_1E_ca()
965 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1E_ca()
974 0, asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1E_ca()
975 asoc->c.sinit_max_instreams, in sctp_sf_do_5_1E_ca()
988 if (asoc->peer.adaptation_ind) { in sctp_sf_do_5_1E_ca()
997 if (!asoc->peer.auth_capable) { in sctp_sf_do_5_1E_ca()
1011 /* Generate and sendout a heartbeat packet. */
1022 /* Send a heartbeat to our peer. */ in sctp_sf_heartbeat()
1028 * is started with this heartbeat chunk. in sctp_sf_heartbeat()
1037 /* Generate a HEARTBEAT packet on the given transport. */
1047 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_sendbeat_8_3()
1059 * The Sender-specific Heartbeat Info field should normally include in sctp_sf_sendbeat_8_3()
1060 * information about the sender's current time when this HEARTBEAT in sctp_sf_sendbeat_8_3()
1062 * HEARTBEAT is sent (see Section 8.3). in sctp_sf_sendbeat_8_3()
1065 if (transport->param_flags & SPP_HB_ENABLE) { in sctp_sf_sendbeat_8_3()
1072 * when sending heartbeat. in sctp_sf_sendbeat_8_3()
1095 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_send_reconf()
1106 sctp_chunk_hold(asoc->strreset_chunk); in sctp_sf_send_reconf()
1108 SCTP_CHUNK(asoc->strreset_chunk)); in sctp_sf_send_reconf()
1129 reply = sctp_make_heartbeat(asoc, transport, transport->pl.probe_size); in sctp_sf_send_probe()
1140 * Process an heartbeat request.
1142 * Section: 8.3 Path Heartbeat
1143 * The receiver of the HEARTBEAT should immediately respond with a
1144 * HEARTBEAT ACK that contains the Heartbeat Information field copied
1145 * from the received HEARTBEAT chunk.
1177 /* Make sure that the HEARTBEAT chunk has a valid length. */ in sctp_sf_beat_8_3()
1183 /* 8.3 The receiver of the HEARTBEAT should immediately in sctp_sf_beat_8_3()
1184 * respond with a HEARTBEAT ACK that contains the Heartbeat in sctp_sf_beat_8_3()
1185 * Information field copied from the received HEARTBEAT chunk. in sctp_sf_beat_8_3()
1187 chunk->subh.hb_hdr = (struct sctp_heartbeathdr *)chunk->skb->data; in sctp_sf_beat_8_3()
1188 param_hdr = (struct sctp_paramhdr *)chunk->subh.hb_hdr; in sctp_sf_beat_8_3()
1189 paylen = ntohs(chunk->chunk_hdr->length) - sizeof(struct sctp_chunkhdr); in sctp_sf_beat_8_3()
1191 if (ntohs(param_hdr->length) > paylen) in sctp_sf_beat_8_3()
1195 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1210 * Process the returning HEARTBEAT ACK.
1212 * Section: 8.3 Path Heartbeat
1213 * Upon the receipt of the HEARTBEAT ACK, the sender of the HEARTBEAT
1215 * address to which the HEARTBEAT was sent, and mark the destination
1219 * HEARTBEAT ACK. The receiver of the HEARTBEAT ACK must also
1223 * The receiver of the HEARTBEAT ACK should also perform an RTT
1225 * value carried in the HEARTBEAT ACK chunk.
1253 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1259 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1261 if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo)) in sctp_sf_backbeat_8_3()
1264 from_addr = hbinfo->daddr; in sctp_sf_backbeat_8_3()
1283 /* Validate the 64-bit random nonce. */ in sctp_sf_backbeat_8_3()
1284 if (hbinfo->hb_nonce != link->hb_nonce) in sctp_sf_backbeat_8_3()
1287 if (hbinfo->probe_size) { in sctp_sf_backbeat_8_3()
1288 if (hbinfo->probe_size != link->pl.probe_size || in sctp_sf_backbeat_8_3()
1298 max_interval = link->hbinterval + link->rto; in sctp_sf_backbeat_8_3()
1301 if (time_after(hbinfo->sent_at, jiffies) || in sctp_sf_backbeat_8_3()
1302 time_after(jiffies, hbinfo->sent_at + max_interval)) { in sctp_sf_backbeat_8_3()
1303 pr_debug("%s: HEARTBEAT ACK with invalid timestamp received " in sctp_sf_backbeat_8_3()
1309 /* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of in sctp_sf_backbeat_8_3()
1310 * the HEARTBEAT should clear the error counter of the in sctp_sf_backbeat_8_3()
1311 * destination transport address to which the HEARTBEAT was in sctp_sf_backbeat_8_3()
1327 struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); in sctp_sf_send_restart_abort()
1342 len = af->to_addr_param(ssa, addrparm); in sctp_sf_send_restart_abort()
1345 errhdr->cause = SCTP_ERROR_RESTART; in sctp_sf_send_restart_abort()
1346 errhdr->length = htons(len); in sctp_sf_send_restart_abort()
1349 ep = sctp_sk(net->sctp.ctl_sock)->ep; in sctp_sf_send_restart_abort()
1378 if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr)) in list_has_sctp_addr()
1392 struct net *net = new_asoc->base.net; in sctp_sf_check_restart_addrs()
1396 /* Implementor's Guide - Section 5.2.2 in sctp_sf_check_restart_addrs()
1407 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1409 if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1410 &new_addr->ipaddr)) { in sctp_sf_check_restart_addrs()
1411 sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, in sctp_sf_check_restart_addrs()
1425 * Note: Do not use in CLOSED or SHUTDOWN-ACK-SENT state.
1430 switch (asoc->state) { in sctp_tietags_populate()
1432 /* 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State */ in sctp_tietags_populate()
1435 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1436 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1437 new_asoc->c.peer_ttag = 0; in sctp_tietags_populate()
1441 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1442 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1443 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1446 /* 5.2.2 Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, in sctp_tietags_populate()
1447 * COOKIE-WAIT and SHUTDOWN-ACK-SENT in sctp_tietags_populate()
1450 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1451 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1459 new_asoc->rwnd = asoc->rwnd; in sctp_tietags_populate()
1460 new_asoc->c.sinit_num_ostreams = asoc->c.sinit_num_ostreams; in sctp_tietags_populate()
1461 new_asoc->c.sinit_max_instreams = asoc->c.sinit_max_instreams; in sctp_tietags_populate()
1462 new_asoc->c.initial_tsn = asoc->c.initial_tsn; in sctp_tietags_populate()
1466 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1478 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1479 (asoc->c.peer_vtag != new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1480 (asoc->c.my_vtag == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1481 (asoc->c.peer_vtag == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1485 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1486 ((asoc->c.peer_vtag != new_asoc->c.peer_vtag) || in sctp_tietags_compare()
1487 (0 == asoc->c.peer_vtag))) { in sctp_tietags_compare()
1492 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1493 (asoc->c.peer_vtag == new_asoc->c.peer_vtag)) in sctp_tietags_compare()
1497 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1498 (asoc->c.peer_vtag == new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1499 (0 == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1500 (0 == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1534 if (!chunk->singleton) in sctp_sf_do_unexpected_init()
1544 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_unexpected_init()
1547 if (SCTP_INPUT_CB(chunk->skb)->encap_port != chunk->transport->encap_port) in sctp_sf_do_unexpected_init()
1551 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_unexpected_init()
1554 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_unexpected_init()
1558 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_unexpected_init()
1559 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_unexpected_init()
1566 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1568 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1598 if (security_sctp_assoc_request(new_asoc, chunk->skb)) { in sctp_sf_do_unexpected_init()
1609 * place (local tie-tag and per tie-tag) within the state cookie. in sctp_sf_do_unexpected_init()
1612 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1617 * restart. Do not do this check for COOKIE-WAIT state, in sctp_sf_do_unexpected_init()
1638 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1659 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1696 * Section: 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State (Item B)
1701 * Upon receipt of an INIT in the COOKIE-WAIT or COOKIE-ECHOED state, an
1709 * After that, the endpoint MUST NOT change its state, the T1-init
1714 * For an endpoint that is in the COOKIE-ECHOED state it MUST populate
1715 * its Tie-Tags with the Tag information of itself and its peer (see
1716 * section 5.2.2 for a description of the Tie-Tags).
1748 * COOKIE-ECHOED and COOKIE-WAIT
1755 * the Peer's-Tie-Tag and the Local-Tie-Tag. The outbound SCTP packet
1767 * Note: Only when a TCB exists and the association is not in a COOKIE-
1768 * WAIT state are the Tie-Tags populated. For a normal association INIT
1769 * (i.e. the endpoint is in a COOKIE-WAIT state), the Tie-Tags MUST be
1800 * Unexpected INIT-ACK handler.
1804 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1817 * endpoint. If this is an OOTB INIT-ACK, treat it as such. in sctp_sf_do_5_2_3_initack()
1819 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) in sctp_sf_do_5_2_3_initack()
1829 struct net *net = asoc->base.net; in sctp_sf_do_assoc_update()
1846 return -ENOMEM; in sctp_sf_do_assoc_update()
1849 /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A')
1868 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_a()
1869 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_a()
1871 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_a()
1889 /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in sctp_sf_do_dupcook_a()
1897 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1912 /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked in sctp_sf_do_dupcook_a()
1920 /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue in sctp_sf_do_dupcook_a()
1921 * and ASCONF-ACK cache. in sctp_sf_do_dupcook_a()
1937 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_a()
1938 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_a()
1946 (sctp_sstate(asoc->base.sk, CLOSING) || in sctp_sf_do_dupcook_a()
1947 sock_flag(asoc->base.sk, SOCK_DEAD))) { in sctp_sf_do_dupcook_a()
1969 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'B')
1988 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_b()
1989 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_b()
1991 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_b()
2004 if (asoc->state < SCTP_STATE_ESTABLISHED) in sctp_sf_do_dupcook_b()
2024 * Sadly, this needs to be implemented as a side-effect, because in sctp_sf_do_dupcook_b()
2040 if (asoc->peer.adaptation_ind) in sctp_sf_do_dupcook_b()
2043 if (!asoc->peer.auth_capable) in sctp_sf_do_dupcook_b()
2052 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'C')
2057 * INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
2076 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2097 * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state. in sctp_sf_do_dupcook_d()
2106 if (asoc->state < SCTP_STATE_ESTABLISHED) { in sctp_sf_do_dupcook_d()
2124 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_d()
2125 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_d()
2135 if (asoc->peer.adaptation_ind) { in sctp_sf_do_dupcook_d()
2143 if (!asoc->peer.auth_capable) { in sctp_sf_do_dupcook_d()
2181 * Handle a duplicate COOKIE-ECHO. This usually means a cookie-carrying
2225 chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_2_4_dupcook()
2226 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_2_4_dupcook()
2239 * If the re-build failed, what is the proper error path in sctp_sf_do_5_2_4_dupcook()
2242 * [We should abort the association. --piggy] in sctp_sf_do_5_2_4_dupcook()
2249 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_2_4_dupcook()
2252 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_2_4_dupcook()
2256 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_2_4_dupcook()
2263 new_asoc->temp = 1; in sctp_sf_do_5_2_4_dupcook()
2279 chunk->head_skb ?: chunk->skb)) { in sctp_sf_do_5_2_4_dupcook()
2329 * Process an ABORT. (SHUTDOWN-PENDING state)
2359 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_pending_abort()
2365 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2375 * Process an ABORT. (SHUTDOWN-SENT state)
2405 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_sent_abort()
2411 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2417 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_abort()
2421 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_abort()
2429 * Process an ABORT. (SHUTDOWN-ACK-SENT state)
2442 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_abort()
2483 /* FUTURE FIXME: When PR-SCTP related and other optional in sctp_sf_cookie_echoed_err()
2487 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2488 if (SCTP_ERROR_STALE_COOKIE == err->cause) in sctp_sf_cookie_echoed_err()
2505 * If the association is in the COOKIE-ECHOED state, the endpoint may elect
2534 int attempts = asoc->init_err_counter + 1; in sctp_sf_do_5_2_6_stale()
2541 if (attempts > asoc->max_init_attempts) { in sctp_sf_do_5_2_6_stale()
2549 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2557 * Measure of Staleness's unit is usec. (1/1000000 sec) in sctp_sf_do_5_2_6_stale()
2558 * Suggested Cookie Life-span Increment's unit is msec. in sctp_sf_do_5_2_6_stale()
2559 * (1/1000 sec) in sctp_sf_do_5_2_6_stale()
2573 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_do_5_2_6_stale()
2583 /* Stop pending T3-rtx and heartbeat timers */ in sctp_sf_do_5_2_6_stale()
2587 /* Delete non-primary peer ip addresses since we are transitioning in sctp_sf_do_5_2_6_stale()
2588 * back to the COOKIE-WAIT state in sctp_sf_do_5_2_6_stale()
2592 /* If we've sent any data bundled with COOKIE-ECHO we will need to in sctp_sf_do_5_2_6_stale()
2596 SCTP_TRANSPORT(asoc->peer.primary_path)); in sctp_sf_do_5_2_6_stale()
2629 * - The endpoint shall always fill in the Verification Tag field of the
2633 * - If the ABORT is sent in response to an OOTB packet, the endpoint
2636 * - The receiver MUST accept the packet if the Verification Tag
2675 /* ADD-IP: Special case for ABORT chunks in sctp_sf_do_9_1_abort()
2681 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_do_9_1_abort()
2703 len = ntohs(chunk->chunk_hdr->length); in __sctp_sf_do_9_1_abort()
2705 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in __sctp_sf_do_9_1_abort()
2717 * Process an ABORT. (COOKIE-WAIT state)
2750 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_cookie_wait_abort()
2752 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in sctp_sf_cookie_wait_abort()
2755 chunk->transport); in sctp_sf_cookie_wait_abort()
2759 * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state)
2775 * Process an ABORT. (COOKIE-ECHOED state)
2786 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_abort()
2823 * - enter the SHUTDOWN-RECEIVED state,
2825 * - stop accepting new data from its SCTP user
2827 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2831 * Once an endpoint as reached the SHUTDOWN-RECEIVED state it MUST NOT
2874 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shutdown()
2875 skb_pull(chunk->skb, sizeof(*sdh)); in sctp_sf_do_9_2_shutdown()
2876 chunk->subh.shutdown_hdr = sdh; in sctp_sf_do_9_2_shutdown()
2877 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shutdown()
2879 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shutdown()
2881 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shutdown()
2886 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shutdown()
2890 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shutdown()
2905 * - enter the SHUTDOWN-RECEIVED state, in sctp_sf_do_9_2_shutdown()
2906 * - stop accepting new data from its SCTP user in sctp_sf_do_9_2_shutdown()
2914 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_shutdown()
2922 /* - verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shutdown()
2927 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2936 * Once an endpoint has reached the SHUTDOWN-RECEIVED state,
2961 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2962 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shut_ctsn()
2964 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shut_ctsn()
2966 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shut_ctsn()
2971 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shut_ctsn()
2975 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shut_ctsn()
2983 SCTP_BE32(sdh->cum_tsn_ack)); in sctp_sf_do_9_2_shut_ctsn()
2989 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
3018 * the T2-SHUTDOWN timer. in __sctp_sf_do_9_2_reshutack()
3022 /* and restart the T2-shutdown timer. */ in __sctp_sf_do_9_2_reshutack()
3041 if (!chunk->singleton) in sctp_sf_do_9_2_reshutack()
3047 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_9_2_reshutack()
3096 cwr = (struct sctp_cwrhdr *)chunk->skb->data; in sctp_sf_do_ecn_cwr()
3097 skb_pull(chunk->skb, sizeof(*cwr)); in sctp_sf_do_ecn_cwr()
3099 lowest_tsn = ntohl(cwr->lowest_tsn); in sctp_sf_do_ecn_cwr()
3102 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) { in sctp_sf_do_ecn_cwr()
3116 * ECN-Echo
3150 ecne = (struct sctp_ecnehdr *)chunk->skb->data; in sctp_sf_do_ecne()
3151 skb_pull(chunk->skb, sizeof(*ecne)); in sctp_sf_do_ecne()
3155 SCTP_U32(ntohl(ecne->lowest_tsn))); in sctp_sf_do_ecne()
3207 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_6_2()
3227 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_6_2()
3228 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_6_2()
3233 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3236 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_data_6_2()
3263 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3283 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3288 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3298 * (4) In SHUTDOWN-SENT state the endpoint MUST acknowledge any received
3327 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_fast_4_4()
3343 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_fast_4_4()
3344 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_fast_4_4()
3353 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_data_fast_4_4()
3355 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_data_fast_4_4()
3357 if (chunk->end_of_packet) { in sctp_sf_eat_data_fast_4_4()
3377 * Cumulative TSN Ack Point indicates an out-of-order SACK.
3389 * chunk was originally transmitted, then T3-rtx is started for
3426 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3427 ctsn = ntohl(sackh->cum_tsn_ack); in sctp_sf_eat_sack_6_2()
3429 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_eat_sack_6_2()
3433 if (TSN_lte(asoc->next_tsn, ctsn)) in sctp_sf_eat_sack_6_2()
3442 * Point indicates an out-of-order SACK. in sctp_sf_eat_sack_6_2()
3444 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_eat_sack_6_2()
3446 asoc->ctsn_ack_point); in sctp_sf_eat_sack_6_2()
3469 * packet and set the T-bit in the Chunk Flags to indicate that the
3503 /* Reflect vtag if T-Bit is set */ in sctp_sf_tabort_8_4_8()
3505 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3508 abort->skb->sk = ep->base.sk; in sctp_sf_tabort_8_4_8()
3523 * From Section 4 at draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.
3547 abort->skb->sk = ep->base.sk; in sctp_sf_new_encap_port()
3564 * API 5.3.1.3 - SCTP_REMOTE_ERROR
3585 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_sf_operr_notify()
3586 if ((void *)err != (void *)chunk->chunk_end) in sctp_sf_operr_notify()
3601 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3645 * stop the T2-shutdown timer, in sctp_sf_do_9_2_final()
3670 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3677 * set the T-bit in the Chunk Flags to indicate that the Verification
3684 * packet and set the T-bit in the Chunk Flags to indicate that the
3696 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3708 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3711 if (ntohs(ch->length) < sizeof(*ch)) in sctp_sf_ootb()
3716 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); in sctp_sf_ootb()
3724 if (SCTP_CID_SHUTDOWN_ACK == ch->type) in sctp_sf_ootb()
3732 if (SCTP_CID_ABORT == ch->type) in sctp_sf_ootb()
3740 if (SCTP_CID_COOKIE_ACK == ch->type) in sctp_sf_ootb()
3743 if (SCTP_CID_ERROR == ch->type) { in sctp_sf_ootb()
3745 if (SCTP_ERROR_STALE_COOKIE == err->cause) { in sctp_sf_ootb()
3773 * set the T-bit in the Chunk Flags to indicate that the Verification
3809 /* Reflect vtag if T-Bit is set */ in sctp_sf_shut_8_4_5()
3811 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3814 shut->skb->sk = ep->base.sk; in sctp_sf_shut_8_4_5()
3834 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the
3838 * chunks. --piggy ]
3893 /* ADD-IP: Section 4.1.1 in sctp_sf_do_asconf()
3895 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3897 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf()
3899 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf()
3900 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3903 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3904 serial = ntohl(hdr->serial); in sctp_sf_do_asconf()
3913 * 'Peer-Serial-Number'. in sctp_sf_do_asconf()
3915 if (serial == asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3917 * we can clean our old ASCONF-ACKs. in sctp_sf_do_asconf()
3919 if (!chunk->has_asconf) in sctp_sf_do_asconf()
3924 * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to in sctp_sf_do_asconf()
3928 * Essentially, do V1-V5. in sctp_sf_do_asconf()
3934 } else if (serial < asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3937 * ('Peer- Sequence-Number' + 1), simply skip to the next in sctp_sf_do_asconf()
3939 * any previously cached ASCONF-ACK response that was in sctp_sf_do_asconf()
3941 * ASCONF. Note: It is possible that no cached ASCONF-ACK in sctp_sf_do_asconf()
3944 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3947 asconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial); in sctp_sf_do_asconf()
3955 asconf_ack->transport = NULL; in sctp_sf_do_asconf()
3964 * containing the ASCONF-ACK Chunks MUST be the source address of in sctp_sf_do_asconf()
3972 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
3974 if (asoc->new_transport) { in sctp_sf_do_asconf()
3975 sctp_sf_heartbeat(ep, asoc, type, asoc->new_transport, commands); in sctp_sf_do_asconf()
3976 ((struct sctp_association *)asoc)->new_transport = NULL; in sctp_sf_do_asconf()
3992 if (list_empty(&asoc->addip_chunk_list)) in sctp_send_next_asconf()
3995 entry = asoc->addip_chunk_list.next; in sctp_send_next_asconf()
4000 asoc->addip_last_asconf = asconf; in sctp_send_next_asconf()
4017 struct sctp_chunk *last_asconf = asoc->addip_last_asconf; in sctp_sf_do_asconf_ack()
4036 /* ADD-IP, Section 4.1.2: in sctp_sf_do_asconf_ack()
4038 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf_ack()
4040 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf_ack()
4042 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf_ack()
4043 (!net->sctp.addip_noauth && !asconf_ack->auth)) in sctp_sf_do_asconf_ack()
4046 addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data; in sctp_sf_do_asconf_ack()
4047 rcvd_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4049 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
4055 addip_hdr = last_asconf->subh.addip_hdr; in sctp_sf_do_asconf_ack()
4056 sent_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4058 sent_serial = asoc->addip_serial - 1; in sctp_sf_do_asconf_ack()
4061 /* D0) If an endpoint receives an ASCONF-ACK that is greater than or in sctp_sf_do_asconf_ack()
4064 * sequence number is greater than if it is no more than 2^^31-1 in sctp_sf_do_asconf_ack()
4068 !(asoc->addip_last_asconf)) { in sctp_sf_do_asconf_ack()
4091 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { in sctp_sf_do_asconf_ack()
4124 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
4152 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4157 if (param.p->type == SCTP_PARAM_RESET_OUT_REQUEST) in sctp_sf_do_reconf()
4160 else if (param.p->type == SCTP_PARAM_RESET_IN_REQUEST) in sctp_sf_do_reconf()
4163 else if (param.p->type == SCTP_PARAM_RESET_TSN_REQUEST) in sctp_sf_do_reconf()
4166 else if (param.p->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) in sctp_sf_do_reconf()
4169 else if (param.p->type == SCTP_PARAM_RESET_ADD_IN_STREAMS) in sctp_sf_do_reconf()
4172 else if (param.p->type == SCTP_PARAM_RESET_RESPONSE) in sctp_sf_do_reconf()
4189 * PR-SCTP Section 3.6 Receiver Side Implementation of PR-SCTP
4220 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn()
4224 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn()
4228 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn()
4229 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn()
4230 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn()
4231 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn()
4232 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn()
4234 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn()
4237 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn()
4240 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn()
4243 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4247 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn()
4252 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_fwd_tsn()
4287 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn_fast()
4291 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn_fast()
4295 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn_fast()
4296 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn_fast()
4297 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn_fast()
4298 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn_fast()
4299 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn_fast()
4301 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn_fast()
4304 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn_fast()
4307 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn_fast()
4310 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4314 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn_fast()
4322 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_fwd_tsn_fast()
4324 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_fwd_tsn_fast()
4335 * SCTP-AUTH Section 6.3 Receiving authenticated chunks
4339 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4368 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_authenticate()
4369 chunk->subh.auth_hdr = auth_hdr; in sctp_sf_authenticate()
4370 skb_pull(chunk->skb, sizeof(*auth_hdr)); in sctp_sf_authenticate()
4375 if (!sctp_auth_asoc_verify_hmac_id(asoc, auth_hdr->hmac_id)) in sctp_sf_authenticate()
4381 key_id = ntohs(auth_hdr->shkey_id); in sctp_sf_authenticate()
4382 if (key_id != asoc->active_key_id) { in sctp_sf_authenticate()
4391 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4393 hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); in sctp_sf_authenticate()
4394 if (sig_len != hmac->hmac_len) in sctp_sf_authenticate()
4405 skb_pull(chunk->skb, sig_len); in sctp_sf_authenticate()
4413 sctp_auth_calculate_hmac(asoc, chunk->skb, in sctp_sf_authenticate()
4414 (struct sctp_auth_chunk *)chunk->chunk_hdr, in sctp_sf_authenticate()
4424 chunk->auth = 1; in sctp_sf_authenticate()
4443 if (!asoc->peer.auth_capable) in sctp_sf_eat_auth()
4457 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4466 &auth_hdr->hmac_id, in sctp_sf_eat_auth()
4488 if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { in sctp_sf_eat_auth()
4491 ev = sctp_ulpevent_make_authkey(asoc, ntohs(auth_hdr->shkey_id), in sctp_sf_eat_auth()
4509 * Chunk Types are encoded such that the highest-order two bits specify
4513 * 00 - Stop processing this SCTP packet and discard it, do not process
4516 * 01 - Stop processing this SCTP packet and discard it, do not process
4520 * 10 - Skip this chunk and continue processing.
4522 * 11 - Skip this chunk and continue processing, but report in an ERROR
4557 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4560 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4575 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4578 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4713 /* SCTP-AUTH, Section 6.3: in sctp_sf_abort_violation()
4733 /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ in sctp_sf_abort_violation()
4734 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4735 !asoc->peer.i.init_tag) { in sctp_sf_abort_violation()
4738 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4740 abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T; in sctp_sf_abort_violation()
4744 inittag = ntohl(initack->init_hdr.init_tag); in sctp_sf_abort_violation()
4753 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { in sctp_sf_abort_violation()
4774 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4776 abort->skb->sk = ep->base.sk; in sctp_sf_abort_violation()
4875 * cumulative tsn ack to a point beyond the max tsn currently sent.
4888 static const char err_str[] = "The cumulative tsn ack beyond the max tsn currently sent:"; in sctp_sf_violation_ctsn()
4895 * when we have an association and we receive bundled INIT-ACK, or
4896 * SHUTDOWN-COMPLETE, our peer is clearly violating the "MUST NOT bundle"
4919 * Section: 10.1 ULP-to-SCTP
4924 * -> association id [,destination transport addr list] [,outbound stream
4953 * stuff happens when the INIT ACK arrives. This is a NON-BLOCKING
4958 * o local SCTP instance name - obtained from the INITIALIZE operation.
4960 * o destination transport addr - specified as one of the transport
4963 * [This is asoc->peer.active_path.]
4964 * o outbound stream count - the number of outbound streams the ULP
4983 /* The comment below says that we enter COOKIE-WAIT AFTER in sctp_sf_do_prm_asoc()
4998 repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); in sctp_sf_do_prm_asoc()
5012 /* After sending the INIT, "A" starts the T1-init timer and in sctp_sf_do_prm_asoc()
5013 * enters the COOKIE-WAIT state. in sctp_sf_do_prm_asoc()
5027 * Section: 10.1 ULP-to-SCTP
5032 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
5033 * -> result
5039 * o association id - local handle to the SCTP association
5041 * o buffer address - the location where the user message to be
5044 * o byte count - The size of the user data in number of bytes;
5048 * o context - an optional 32 bit integer that will be carried in the
5052 * o stream id - to indicate which stream to send the data on. If not
5055 * o life time - specifies the life time of the user data. The user data
5064 * o destination transport address - specified as one of the destination
5070 * o unorder flag - this flag, if present, indicates that the user
5075 * o no-bundle flag - instructs SCTP not to bundle this user data with
5079 * o payload protocol-id - A 32 bit unsigned integer that is to be
5105 * -> result
5116 * o association id - local handle to the SCTP association
5136 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_do_9_2_prm_shutdown()
5146 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_prm_shutdown()
5161 * -> result
5171 * o association id - local handle to the SCTP association
5175 * o cause code - reason of the abort to be passed to the peer
5226 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_ERROR, SCTP_ERROR(-EINVAL)); in sctp_sf_error_closed()
5242 SCTP_ERROR(-ESHUTDOWN)); in sctp_sf_error_shutdown()
5304 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_shutdown()
5333 /* Stop T1-init timer */ in sctp_sf_cookie_wait_prm_abort()
5381 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_abort()
5393 * state table when someone issues an abort while in SHUTDOWN-PENDING state.
5406 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_pending_prm_abort()
5420 * state table when someone issues an abort while in SHUTDOWN-SENT state.
5433 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_prm_abort()
5437 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_prm_abort()
5465 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_prm_abort()
5473 * 10.1 ULP-to-SCTP
5474 * J) Request Heartbeat
5478 * -> result
5480 * Instructs the local endpoint to perform a HeartBeat on the specified
5482 * result should indicate whether the transmission of the HEARTBEAT
5487 * o association id - local handle to the SCTP association
5489 * o destination transport address - the transport address of the
5490 * association on which a heartbeat should be issued.
5507 * D) Request an on-demand HEARTBEAT on a specific destination in sctp_sf_do_prm_requestheartbeat()
5511 * the destination transport address each time a HEARTBEAT is sent in sctp_sf_do_prm_requestheartbeat()
5541 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5610 * It shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT
5611 * state. If the timer expires, the endpoint must re-send the SHUTDOWN
5636 * T2-shutdown timer. in sctp_sf_do_9_2_start_shutdown()
5640 /* It shall then start the T2-shutdown timer */ in sctp_sf_do_9_2_start_shutdown()
5646 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. in sctp_sf_do_9_2_start_shutdown()
5651 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_start_shutdown()
5655 /* and enter the SHUTDOWN-SENT state. */ in sctp_sf_do_9_2_start_shutdown()
5659 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_start_shutdown()
5661 * HEARTBEAT ... is discontinued after sending either SHUTDOWN in sctp_sf_do_9_2_start_shutdown()
5662 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_start_shutdown()
5680 * shall send a SHUTDOWN ACK and start a T2-shutdown timer of its own,
5681 * entering the SHUTDOWN-ACK-SENT state. If the timer expires, the
5682 * endpoint must re-send the SHUTDOWN ACK.
5724 * the T2-shutdown timer. in sctp_sf_do_9_2_shutdown_ack()
5728 /* and start/restart a T2-shutdown timer of its own, */ in sctp_sf_do_9_2_shutdown_ack()
5732 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_shutdown_ack()
5736 /* Enter the SHUTDOWN-ACK-SENT state. */ in sctp_sf_do_9_2_shutdown_ack()
5740 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_shutdown_ack()
5742 * HEARTBEAT ... is discontinued after sending either SHUTDOWN in sctp_sf_do_9_2_shutdown_ack()
5743 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_shutdown_ack()
5780 * Section: 6.3.3 Handle T3-rtx Expiration
5782 * Whenever the retransmission timer T3-rtx expires for a destination
5799 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_do_6_3_3_rtx()
5800 if (asoc->peer.zero_window_announced && in sctp_sf_do_6_3_3_rtx()
5801 asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { in sctp_sf_do_6_3_3_rtx()
5827 * 7.2.3 and set the cwnd <- MTU. in sctp_sf_do_6_3_3_rtx()
5831 * expires, set RTO <- RTO * 2 ("back off the timer"). The in sctp_sf_do_6_3_3_rtx()
5832 * maximum value discussed in rule C7 above (RTO.max) may be in sctp_sf_do_6_3_3_rtx()
5838 * T3-rtx has expired will fit into a single packet, subject in sctp_sf_do_6_3_3_rtx()
5847 * which the T3-rtx timer expired but did not fit in one MTU in sctp_sf_do_6_3_3_rtx()
5897 * 2) If the T1-init timer expires, the endpoint MUST retransmit INIT
5898 * and re-start the T1-init timer without changing state. This MUST
5899 * be repeated up to 'Max.Init.Retransmits' times. After that, the
5915 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_init_timer_expire()
5923 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_init_timer_expire()
5924 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_t1_init_timer_expire()
5941 asoc->max_init_attempts); in sctp_sf_t1_init_timer_expire()
5962 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
5963 * COOKIE ECHO and re-start the T1-cookie timer without changing
5964 * state. This MUST be repeated up to 'Max.Init.Retransmits' times.
5980 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_cookie_timer_expire()
5983 pr_debug("%s: timer T1 expired (COOKIE-ECHO)\n", __func__); in sctp_sf_t1_cookie_timer_expire()
5987 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_cookie_timer_expire()
6010 /* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
6014 * SHUTDOWN chunk to the protocol parameter 'Association.Max.Retrans'.
6020 * the T2-Shutdown timer, giving its peer ample opportunity to transmit
6037 ((struct sctp_association *)asoc)->shutdown_retries++; in sctp_sf_t2_timer_expire()
6039 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t2_timer_expire()
6050 switch (asoc->state) { in sctp_sf_t2_timer_expire()
6071 if (asoc->shutdown_last_sent_to) in sctp_sf_t2_timer_expire()
6073 SCTP_TRANSPORT(asoc->shutdown_last_sent_to)); in sctp_sf_t2_timer_expire()
6076 * the T2-shutdown timer. in sctp_sf_t2_timer_expire()
6080 /* Restart the T2-shutdown timer. */ in sctp_sf_t2_timer_expire()
6102 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire()
6103 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
6123 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t4_timer_expire()
6135 /* ADDIP 4.1 B3) Back-off the destination address RTO value to which in sctp_sf_t4_timer_expire()
6140 /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible in sctp_sf_t4_timer_expire()
6146 sctp_chunk_hold(asoc->addip_last_asconf); in sctp_sf_t4_timer_expire()
6148 SCTP_CHUNK(asoc->addip_last_asconf)); in sctp_sf_t4_timer_expire()
6150 /* ADDIP 4.1 B5) Restart the T-4 RTO timer. Note that if a different in sctp_sf_t4_timer_expire()
6160 /* sctpimpguide-05 Section 2.12.2
6162 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
6217 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_autoclose_timer_expire()
6227 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_autoclose_timer_expire()
6311 sack = (struct sctp_sackhdr *) chunk->skb->data; in sctp_sm_pull_sack()
6313 num_blocks = ntohs(sack->num_gap_ack_blocks); in sctp_sm_pull_sack()
6314 num_dup_tsns = ntohs(sack->num_dup_tsns); in sctp_sm_pull_sack()
6317 if (len > chunk->skb->len) in sctp_sm_pull_sack()
6320 skb_pull(chunk->skb, len); in sctp_sm_pull_sack()
6350 /* Reflect vtag if T-Bit is set */ in sctp_abort_pkt_new()
6352 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6360 abort->skb->sk = ep->base.sk; in sctp_abort_pkt_new()
6381 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6382 dport = ntohs(chunk->sctp_hdr->source); in sctp_ootb_pkt_new()
6384 /* The V-tag is going to be the same as the inbound packet if no in sctp_ootb_pkt_new()
6388 /* Special case the INIT-ACK as there is no peer's vtag in sctp_ootb_pkt_new()
6391 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6397 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6398 vtag = ntohl(initack->init_hdr.init_tag); in sctp_ootb_pkt_new()
6402 vtag = asoc->peer.i.init_tag; in sctp_ootb_pkt_new()
6409 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6414 init = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6415 vtag = ntohl(init->init_hdr.init_tag); in sctp_ootb_pkt_new()
6419 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6429 transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_ootb_pkt_new()
6434 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6435 sctp_sk(net->sctp.ctl_sock)); in sctp_ootb_pkt_new()
6437 packet = &transport->packet; in sctp_ootb_pkt_new()
6450 sctp_transport_free(packet->transport); in sctp_ootb_pkt_free()
6469 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6470 packet->vtag = cookie->c.peer_vtag; in sctp_send_stale_cookie_err()
6473 err_chunk->skb->sk = ep->base.sk; in sctp_send_stale_cookie_err()
6489 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_eat_data()
6490 struct sock *sk = asoc->base.sk; in sctp_eat_data()
6499 data_hdr = (struct sctp_datahdr *)chunk->skb->data; in sctp_eat_data()
6500 chunk->subh.data_hdr = data_hdr; in sctp_eat_data()
6501 skb_pull(chunk->skb, sctp_datahdr_len(&asoc->stream)); in sctp_eat_data()
6503 tsn = ntohl(data_hdr->tsn); in sctp_eat_data()
6506 /* ASSERT: Now skb->data is really the user data. */ in sctp_eat_data()
6518 if (asoc->peer.ecn_capable && !chunk->ecn_ce_done) { in sctp_eat_data()
6519 struct sctp_af *af = SCTP_INPUT_CB(chunk->skb)->af; in sctp_eat_data()
6520 chunk->ecn_ce_done = 1; in sctp_eat_data()
6522 if (af->is_ce(sctp_gso_headskb(chunk->skb))) { in sctp_eat_data()
6529 tmp = sctp_tsnmap_check(&asoc->peer.tsn_map, tsn); in sctp_eat_data()
6531 /* The TSN is too high--silently discard the chunk and in sctp_eat_data()
6534 if (chunk->asoc) in sctp_eat_data()
6535 chunk->asoc->stats.outofseqtsns++; in sctp_eat_data()
6548 datalen = ntohs(chunk->chunk_hdr->length); in sctp_eat_data()
6549 datalen -= sctp_datachk_len(&asoc->stream); in sctp_eat_data()
6554 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) { in sctp_eat_data()
6567 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6568 (datalen > asoc->rwnd + asoc->frag_point))) { in sctp_eat_data()
6582 __func__, tsn, datalen, asoc->rwnd); in sctp_eat_data()
6608 * --------------- in sctp_eat_data()
6631 chunk->data_accepted = 1; in sctp_eat_data()
6636 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_eat_data()
6638 if (chunk->asoc) in sctp_eat_data()
6639 chunk->asoc->stats.iuodchunks++; in sctp_eat_data()
6642 if (chunk->asoc) in sctp_eat_data()
6643 chunk->asoc->stats.iodchunks++; in sctp_eat_data()
6654 if (ntohs(data_hdr->stream) >= asoc->stream.incnt) { in sctp_eat_data()
6659 &data_hdr->stream, in sctp_eat_data()
6660 sizeof(data_hdr->stream), in sctp_eat_data()
6675 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()