Lines Matching +full:tsn +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (c) 1999-2000 Cisco, Inc.
5 * Copyright (c) 1999-2001 Motorola, Inc.
6 * Copyright (c) 2001-2002 Intel Corp.
15 * lksctp developers <linux-sctp@vger.kernel.org>
168 __u16 chunk_length = ntohs(chunk->chunk_hdr->length); in sctp_chunk_length_valid()
171 if (unlikely(chunk->pdiscard)) in sctp_chunk_length_valid()
184 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_err_chunk_valid()
186 return (void *)err == (void *)chunk->chunk_end; in sctp_err_chunk_valid()
198 * that it is in SHUTDOWN-ACK-SENT state, if it is not the chunk should be
199 * discarded. If the endpoint is in the SHUTDOWN-ACK-SENT state the endpoint
200 * should stop the T2-shutdown timer and remove all knowledge of the
206 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
214 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
241 if (!chunk->singleton) in sctp_sf_do_4_C()
249 /* RFC 2960 10.2 SCTP-to-ULP in sctp_sf_do_4_C()
263 * will verify that it is in SHUTDOWN-ACK-SENT state, if it is in sctp_sf_do_4_C()
265 * the SHUTDOWN-ACK-SENT state the endpoint should stop the in sctp_sf_do_4_C()
266 * T2-shutdown timer and remove all knowledge of the in sctp_sf_do_4_C()
324 chunk->skb)) in sctp_sf_do_5_1B_init()
336 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
350 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1B_init()
358 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
367 if (sctp_sstate(ep->base.sk, CLOSING)) in sctp_sf_do_5_1B_init()
372 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1B_init()
373 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1B_init()
380 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
382 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
402 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1B_init()
405 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1B_init()
418 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
429 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
449 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
485 * C) Upon reception of the INIT ACK from "Z", "A" shall stop the T1-init
486 * timer and leave COOKIE-WAIT state. "A" shall then send the State
488 * the T1-cookie timer, and enter the COOKIE-ECHOED state.
527 if (!chunk->singleton) in sctp_sf_do_5_1C_ack()
530 /* Make sure that the INIT-ACK chunk has a valid length */ in sctp_sf_do_5_1C_ack()
535 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1C_ack()
539 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1C_ack()
540 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1C_ack()
552 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1C_ack()
554 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1C_ack()
567 /* SCTP-AUTH, Section 6.3: in sctp_sf_do_5_1C_ack()
583 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
589 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1C_ack()
591 initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_sf_do_5_1C_ack()
596 /* Reset init error count upon receipt of INIT-ACK. */ in sctp_sf_do_5_1C_ack()
599 /* 5.1 C) "A" shall stop the T1-init timer and leave in sctp_sf_do_5_1C_ack()
600 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie in sctp_sf_do_5_1C_ack()
601 * timer, and enter the COOKIE-ECHOED state. in sctp_sf_do_5_1C_ack()
610 /* SCTP-AUTH: genereate the assocition shared keys so that in sctp_sf_do_5_1C_ack()
611 * we can potentially signe the COOKIE-ECHO. in sctp_sf_do_5_1C_ack()
632 if (!chunk->auth_chunk) in sctp_auth_chunk_verify()
635 /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo in sctp_auth_chunk_verify()
642 /* Make sure that we and the peer are AUTH capable */ in sctp_auth_chunk_verify()
643 if (!net->sctp.auth_enable || !asoc->peer.auth_capable) in sctp_auth_chunk_verify()
646 /* set-up our fake chunk so that we can process it */ in sctp_auth_chunk_verify()
647 auth.skb = chunk->auth_chunk; in sctp_auth_chunk_verify()
648 auth.asoc = chunk->asoc; in sctp_auth_chunk_verify()
649 auth.sctp_hdr = chunk->sctp_hdr; in sctp_auth_chunk_verify()
651 skb_push(chunk->auth_chunk, in sctp_auth_chunk_verify()
653 skb_pull(chunk->auth_chunk, sizeof(struct sctp_chunkhdr)); in sctp_auth_chunk_verify()
654 auth.transport = chunk->transport; in sctp_auth_chunk_verify()
677 * - When sending a COOKIE ECHO, the endpoint MUST use the value of the
680 * - The receiver of a COOKIE ECHO follows the procedures in Section 5.
712 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1D_ce()
727 * on the TCP-style socket exceed the max backlog, respond with an in sctp_sf_do_5_1D_ce()
730 sk = ep->base.sk; in sctp_sf_do_5_1D_ce()
738 chunk->subh.cookie_hdr = in sctp_sf_do_5_1D_ce()
739 (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_1D_ce()
740 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_1D_ce()
752 * If the re-build failed, what is the proper error path in sctp_sf_do_5_1D_ce()
755 * [We should abort the association. --piggy] in sctp_sf_do_5_1D_ce()
762 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_1D_ce()
765 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_1D_ce()
770 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_1D_ce()
779 * Re-build the bind address for the association is done in in sctp_sf_do_5_1D_ce()
782 /* This is a brand-new association, so these are not yet side in sctp_sf_do_5_1D_ce()
783 * effects--it is safe to run them here. in sctp_sf_do_5_1D_ce()
785 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_5_1D_ce()
788 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
792 /* SCTP-AUTH: Now that we've populate required fields in in sctp_sf_do_5_1D_ce()
816 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1D_ce()
817 new_asoc->c.sinit_max_instreams, in sctp_sf_do_5_1D_ce()
827 if (new_asoc->peer.adaptation_ind) { in sctp_sf_do_5_1D_ce()
834 if (!new_asoc->peer.auth_capable) { in sctp_sf_do_5_1D_ce()
844 * during side-effect processing and correclty count established in sctp_sf_do_5_1D_ce()
854 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1D_ce()
894 * COOKIE-ECHOED state to the ESTABLISHED state, stopping the T1-cookie
921 /* Verify that the chunk length for the COOKIE-ACK is OK. in sctp_sf_do_5_1E_ca()
928 /* Reset init error count upon receipt of COOKIE-ACK, in sctp_sf_do_5_1E_ca()
931 * from the COOKIE-ECHOED state to the COOKIE-WAIT in sctp_sf_do_5_1E_ca()
937 security_inet_conn_established(ep->base.sk, chunk->skb); in sctp_sf_do_5_1E_ca()
942 * from the COOKIE-ECHOED state to the ESTABLISHED state, in sctp_sf_do_5_1E_ca()
943 * stopping the T1-cookie timer. in sctp_sf_do_5_1E_ca()
952 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1E_ca()
961 0, asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1E_ca()
962 asoc->c.sinit_max_instreams, in sctp_sf_do_5_1E_ca()
975 if (asoc->peer.adaptation_ind) { in sctp_sf_do_5_1E_ca()
984 if (!asoc->peer.auth_capable) { in sctp_sf_do_5_1E_ca()
1034 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_sendbeat_8_3()
1046 * The Sender-specific Heartbeat Info field should normally include in sctp_sf_sendbeat_8_3()
1052 if (transport->param_flags & SPP_HB_ENABLE) { in sctp_sf_sendbeat_8_3()
1082 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_send_reconf()
1093 sctp_chunk_hold(asoc->strreset_chunk); in sctp_sf_send_reconf()
1095 SCTP_CHUNK(asoc->strreset_chunk)); in sctp_sf_send_reconf()
1149 chunk->subh.hb_hdr = (struct sctp_heartbeathdr *)chunk->skb->data; in sctp_sf_beat_8_3()
1150 param_hdr = (struct sctp_paramhdr *)chunk->subh.hb_hdr; in sctp_sf_beat_8_3()
1151 paylen = ntohs(chunk->chunk_hdr->length) - sizeof(struct sctp_chunkhdr); in sctp_sf_beat_8_3()
1153 if (ntohs(param_hdr->length) > paylen) in sctp_sf_beat_8_3()
1157 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1215 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1221 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1223 if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo)) in sctp_sf_backbeat_8_3()
1226 from_addr = hbinfo->daddr; in sctp_sf_backbeat_8_3()
1245 /* Validate the 64-bit random nonce. */ in sctp_sf_backbeat_8_3()
1246 if (hbinfo->hb_nonce != link->hb_nonce) in sctp_sf_backbeat_8_3()
1249 max_interval = link->hbinterval + link->rto; in sctp_sf_backbeat_8_3()
1252 if (time_after(hbinfo->sent_at, jiffies) || in sctp_sf_backbeat_8_3()
1253 time_after(jiffies, hbinfo->sent_at + max_interval)) { in sctp_sf_backbeat_8_3()
1278 struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); in sctp_sf_send_restart_abort()
1290 addrparm = (union sctp_addr_param *)errhdr->variable; in sctp_sf_send_restart_abort()
1293 len = af->to_addr_param(ssa, addrparm); in sctp_sf_send_restart_abort()
1296 errhdr->cause = SCTP_ERROR_RESTART; in sctp_sf_send_restart_abort()
1297 errhdr->length = htons(len); in sctp_sf_send_restart_abort()
1300 ep = sctp_sk(net->sctp.ctl_sock)->ep; in sctp_sf_send_restart_abort()
1329 if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr)) in list_has_sctp_addr()
1343 struct net *net = new_asoc->base.net; in sctp_sf_check_restart_addrs()
1347 /* Implementor's Guide - Section 5.2.2 in sctp_sf_check_restart_addrs()
1358 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1360 if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1361 &new_addr->ipaddr)) { in sctp_sf_check_restart_addrs()
1362 sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, in sctp_sf_check_restart_addrs()
1376 * Note: Do not use in CLOSED or SHUTDOWN-ACK-SENT state.
1381 switch (asoc->state) { in sctp_tietags_populate()
1383 /* 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State */ in sctp_tietags_populate()
1386 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1387 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1388 new_asoc->c.peer_ttag = 0; in sctp_tietags_populate()
1392 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1393 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1394 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1397 /* 5.2.2 Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, in sctp_tietags_populate()
1398 * COOKIE-WAIT and SHUTDOWN-ACK-SENT in sctp_tietags_populate()
1401 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1402 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1410 new_asoc->rwnd = asoc->rwnd; in sctp_tietags_populate()
1411 new_asoc->c.sinit_num_ostreams = asoc->c.sinit_num_ostreams; in sctp_tietags_populate()
1412 new_asoc->c.sinit_max_instreams = asoc->c.sinit_max_instreams; in sctp_tietags_populate()
1413 new_asoc->c.initial_tsn = asoc->c.initial_tsn; in sctp_tietags_populate()
1417 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1429 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1430 (asoc->c.peer_vtag != new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1431 (asoc->c.my_vtag == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1432 (asoc->c.peer_vtag == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1436 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1437 ((asoc->c.peer_vtag != new_asoc->c.peer_vtag) || in sctp_tietags_compare()
1438 (0 == asoc->c.peer_vtag))) { in sctp_tietags_compare()
1443 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1444 (asoc->c.peer_vtag == new_asoc->c.peer_vtag)) in sctp_tietags_compare()
1448 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1449 (asoc->c.peer_vtag == new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1450 (0 == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1451 (0 == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1478 chunk->skb)) in sctp_sf_do_unexpected_init()
1490 if (!chunk->singleton) in sctp_sf_do_unexpected_init()
1500 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_unexpected_init()
1504 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_unexpected_init()
1507 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_unexpected_init()
1511 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_unexpected_init()
1512 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_unexpected_init()
1519 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1521 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1556 * place (local tie-tag and per tie-tag) within the state cookie. in sctp_sf_do_unexpected_init()
1559 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1564 * restart. Do not do this check for COOKIE-WAIT state, in sctp_sf_do_unexpected_init()
1585 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1606 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1643 * Section: 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State (Item B)
1648 * Upon receipt of an INIT in the COOKIE-WAIT or COOKIE-ECHOED state, an
1656 * After that, the endpoint MUST NOT change its state, the T1-init
1661 * For an endpoint that is in the COOKIE-ECHOED state it MUST populate
1662 * its Tie-Tags with the Tag information of itself and its peer (see
1663 * section 5.2.2 for a description of the Tie-Tags).
1695 * COOKIE-ECHOED and COOKIE-WAIT
1702 * the Peer's-Tie-Tag and the Local-Tie-Tag. The outbound SCTP packet
1714 * Note: Only when a TCB exists and the association is not in a COOKIE-
1715 * WAIT state are the Tie-Tags populated. For a normal association INIT
1716 * (i.e. the endpoint is in a COOKIE-WAIT state), the Tie-Tags MUST be
1747 * Unexpected INIT-ACK handler.
1751 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1764 * endpoint. If this is an OOTB INIT-ACK, treat it as such. in sctp_sf_do_5_2_3_initack()
1766 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) in sctp_sf_do_5_2_3_initack()
1772 /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A')
1791 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_a()
1792 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_a()
1794 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_dupcook_a()
1813 /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in sctp_sf_do_dupcook_a()
1821 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1836 /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked in sctp_sf_do_dupcook_a()
1844 /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue in sctp_sf_do_dupcook_a()
1845 * and ASCONF-ACK cache. in sctp_sf_do_dupcook_a()
1874 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_a()
1875 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_a()
1883 (sctp_sstate(asoc->base.sk, CLOSING) || in sctp_sf_do_dupcook_a()
1884 sock_flag(asoc->base.sk, SOCK_DEAD))) { in sctp_sf_do_dupcook_a()
1906 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'B')
1925 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_b()
1926 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_b()
1928 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_dupcook_b()
1943 if (asoc->state < SCTP_STATE_ESTABLISHED) in sctp_sf_do_dupcook_b()
1959 * Sadly, this needs to be implemented as a side-effect, because in sctp_sf_do_dupcook_b()
1975 if (asoc->peer.adaptation_ind) in sctp_sf_do_dupcook_b()
1978 if (!asoc->peer.auth_capable) in sctp_sf_do_dupcook_b()
1987 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'C')
1992 * INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
2011 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2032 * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state. in sctp_sf_do_dupcook_d()
2041 if (asoc->state < SCTP_STATE_ESTABLISHED) { in sctp_sf_do_dupcook_d()
2059 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_d()
2060 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_d()
2070 if (asoc->peer.adaptation_ind) { in sctp_sf_do_dupcook_d()
2078 if (!asoc->peer.auth_capable) { in sctp_sf_do_dupcook_d()
2116 * Handle a duplicate COOKIE-ECHO. This usually means a cookie-carrying
2160 chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_2_4_dupcook()
2161 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_2_4_dupcook()
2174 * If the re-build failed, what is the proper error path in sctp_sf_do_5_2_4_dupcook()
2177 * [We should abort the association. --piggy] in sctp_sf_do_5_2_4_dupcook()
2184 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_2_4_dupcook()
2187 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_2_4_dupcook()
2191 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_2_4_dupcook()
2199 chunk->skb)) { in sctp_sf_do_5_2_4_dupcook()
2205 new_asoc->temp = 1; in sctp_sf_do_5_2_4_dupcook()
2255 * Process an ABORT. (SHUTDOWN-PENDING state)
2285 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_pending_abort()
2291 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2301 * Process an ABORT. (SHUTDOWN-SENT state)
2331 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_sent_abort()
2337 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2343 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_abort()
2347 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_abort()
2355 * Process an ABORT. (SHUTDOWN-ACK-SENT state)
2368 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_abort()
2409 /* FUTURE FIXME: When PR-SCTP related and other optional in sctp_sf_cookie_echoed_err()
2413 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2414 if (SCTP_ERROR_STALE_COOKIE == err->cause) in sctp_sf_cookie_echoed_err()
2431 * If the association is in the COOKIE-ECHOED state, the endpoint may elect
2460 int attempts = asoc->init_err_counter + 1; in sctp_sf_do_5_2_6_stale()
2467 if (attempts > asoc->max_init_attempts) { in sctp_sf_do_5_2_6_stale()
2475 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2484 * Suggested Cookie Life-span Increment's unit is msec. in sctp_sf_do_5_2_6_stale()
2499 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_do_5_2_6_stale()
2509 /* Stop pending T3-rtx and heartbeat timers */ in sctp_sf_do_5_2_6_stale()
2513 /* Delete non-primary peer ip addresses since we are transitioning in sctp_sf_do_5_2_6_stale()
2514 * back to the COOKIE-WAIT state in sctp_sf_do_5_2_6_stale()
2518 /* If we've sent any data bundled with COOKIE-ECHO we will need to in sctp_sf_do_5_2_6_stale()
2522 SCTP_TRANSPORT(asoc->peer.primary_path)); in sctp_sf_do_5_2_6_stale()
2555 * - The endpoint shall always fill in the Verification Tag field of the
2559 * - If the ABORT is sent in response to an OOTB packet, the endpoint
2562 * - The receiver MUST accept the packet if the Verification Tag
2601 /* ADD-IP: Special case for ABORT chunks in sctp_sf_do_9_1_abort()
2607 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_do_9_1_abort()
2629 len = ntohs(chunk->chunk_hdr->length); in __sctp_sf_do_9_1_abort()
2631 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in __sctp_sf_do_9_1_abort()
2643 * Process an ABORT. (COOKIE-WAIT state)
2676 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_cookie_wait_abort()
2678 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in sctp_sf_cookie_wait_abort()
2681 chunk->transport); in sctp_sf_cookie_wait_abort()
2685 * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state)
2701 * Process an ABORT. (COOKIE-ECHOED state)
2712 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_abort()
2749 * - enter the SHUTDOWN-RECEIVED state,
2751 * - stop accepting new data from its SCTP user
2753 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2757 * Once an endpoint as reached the SHUTDOWN-RECEIVED state it MUST NOT
2800 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shutdown()
2801 skb_pull(chunk->skb, sizeof(*sdh)); in sctp_sf_do_9_2_shutdown()
2802 chunk->subh.shutdown_hdr = sdh; in sctp_sf_do_9_2_shutdown()
2803 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shutdown()
2805 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shutdown()
2807 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shutdown()
2812 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shutdown()
2816 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shutdown()
2831 * - enter the SHUTDOWN-RECEIVED state, in sctp_sf_do_9_2_shutdown()
2832 * - stop accepting new data from its SCTP user in sctp_sf_do_9_2_shutdown()
2840 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_shutdown()
2848 /* - verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shutdown()
2853 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2862 * Once an endpoint has reached the SHUTDOWN-RECEIVED state,
2864 * The Cumulative TSN Ack of the received SHUTDOWN chunk
2887 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2888 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shut_ctsn()
2890 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shut_ctsn()
2892 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shut_ctsn()
2897 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shut_ctsn()
2901 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shut_ctsn()
2904 /* verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shut_ctsn()
2909 SCTP_BE32(sdh->cum_tsn_ack)); in sctp_sf_do_9_2_shut_ctsn()
2915 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
2944 * the T2-SHUTDOWN timer. in __sctp_sf_do_9_2_reshutack()
2948 /* and restart the T2-shutdown timer. */ in __sctp_sf_do_9_2_reshutack()
2967 if (!chunk->singleton) in sctp_sf_do_9_2_reshutack()
2973 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_9_2_reshutack()
2990 * This chunk contains one data element, i.e. the TSN number that
2992 * TSN number in the datagram that was originally marked with the
3022 cwr = (struct sctp_cwrhdr *)chunk->skb->data; in sctp_sf_do_ecn_cwr()
3023 skb_pull(chunk->skb, sizeof(*cwr)); in sctp_sf_do_ecn_cwr()
3025 lowest_tsn = ntohl(cwr->lowest_tsn); in sctp_sf_do_ecn_cwr()
3028 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) { in sctp_sf_do_ecn_cwr()
3042 * ECN-Echo
3048 * contains one data element, i.e. the lowest TSN associated with the IP
3076 ecne = (struct sctp_ecnehdr *)chunk->skb->data; in sctp_sf_do_ecne()
3077 skb_pull(chunk->skb, sizeof(*ecne)); in sctp_sf_do_ecne()
3081 SCTP_U32(ntohl(ecne->lowest_tsn))); in sctp_sf_do_ecne()
3133 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_6_2()
3153 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_6_2()
3154 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_6_2()
3159 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3162 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_data_6_2()
3189 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3203 * and the peer's RTO has expired. The duplicate TSN number(s) in sctp_sf_eat_data_6_2()
3209 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3214 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3224 * (4) In SHUTDOWN-SENT state the endpoint MUST acknowledge any received
3253 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_fast_4_4()
3269 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_fast_4_4()
3270 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_fast_4_4()
3279 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_data_fast_4_4()
3281 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_data_fast_4_4()
3283 if (chunk->end_of_packet) { in sctp_sf_eat_data_fast_4_4()
3285 * TSN has not been updated yet. in sctp_sf_eat_data_fast_4_4()
3300 * i) If Cumulative TSN Ack is less than the Cumulative TSN Ack Point,
3301 * then drop the SACK. Since Cumulative TSN Ack is monotonically
3302 * increasing, a SACK whose Cumulative TSN Ack is less than the
3303 * Cumulative TSN Ack Point indicates an out-of-order SACK.
3306 * of bytes still outstanding after processing the Cumulative TSN Ack
3309 * iii) If the SACK is missing a TSN that was previously
3315 * chunk was originally transmitted, then T3-rtx is started for
3352 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3353 ctsn = ntohl(sackh->cum_tsn_ack); in sctp_sf_eat_sack_6_2()
3355 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_eat_sack_6_2()
3359 if (TSN_lte(asoc->next_tsn, ctsn)) in sctp_sf_eat_sack_6_2()
3364 /* i) If Cumulative TSN Ack is less than the Cumulative TSN in sctp_sf_eat_sack_6_2()
3365 * Ack Point, then drop the SACK. Since Cumulative TSN in sctp_sf_eat_sack_6_2()
3367 * Cumulative TSN Ack is less than the Cumulative TSN Ack in sctp_sf_eat_sack_6_2()
3368 * Point indicates an out-of-order SACK. in sctp_sf_eat_sack_6_2()
3370 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_eat_sack_6_2()
3372 asoc->ctsn_ack_point); in sctp_sf_eat_sack_6_2()
3395 * packet and set the T-bit in the Chunk Flags to indicate that the
3429 /* Reflect vtag if T-Bit is set */ in sctp_sf_tabort_8_4_8()
3431 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3434 abort->skb->sk = ep->base.sk; in sctp_sf_tabort_8_4_8()
3451 * API 5.3.1.3 - SCTP_REMOTE_ERROR
3472 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_sf_operr_notify()
3473 if ((void *)err != (void *)chunk->chunk_end) in sctp_sf_operr_notify()
3488 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3532 * stop the T2-shutdown timer, in sctp_sf_do_9_2_final()
3557 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3564 * set the T-bit in the Chunk Flags to indicate that the Verification
3571 * packet and set the T-bit in the Chunk Flags to indicate that the
3583 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3595 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3598 if (ntohs(ch->length) < sizeof(*ch)) in sctp_sf_ootb()
3603 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); in sctp_sf_ootb()
3611 if (SCTP_CID_SHUTDOWN_ACK == ch->type) in sctp_sf_ootb()
3619 if (SCTP_CID_ABORT == ch->type) in sctp_sf_ootb()
3627 if (SCTP_CID_COOKIE_ACK == ch->type) in sctp_sf_ootb()
3630 if (SCTP_CID_ERROR == ch->type) { in sctp_sf_ootb()
3632 if (SCTP_ERROR_STALE_COOKIE == err->cause) { in sctp_sf_ootb()
3660 * set the T-bit in the Chunk Flags to indicate that the Verification
3696 /* Reflect vtag if T-Bit is set */ in sctp_sf_shut_8_4_5()
3698 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3701 shut->skb->sk = ep->base.sk; in sctp_sf_shut_8_4_5()
3721 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the
3725 * chunks. --piggy ]
3780 /* ADD-IP: Section 4.1.1 in sctp_sf_do_asconf()
3782 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3784 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf()
3786 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf()
3787 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3790 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3791 serial = ntohl(hdr->serial); in sctp_sf_do_asconf()
3800 * 'Peer-Serial-Number'. in sctp_sf_do_asconf()
3802 if (serial == asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3804 * we can clean our old ASCONF-ACKs. in sctp_sf_do_asconf()
3806 if (!chunk->has_asconf) in sctp_sf_do_asconf()
3811 * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to in sctp_sf_do_asconf()
3815 * Essentially, do V1-V5. in sctp_sf_do_asconf()
3821 } else if (serial < asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3824 * ('Peer- Sequence-Number' + 1), simply skip to the next in sctp_sf_do_asconf()
3826 * any previously cached ASCONF-ACK response that was in sctp_sf_do_asconf()
3828 * ASCONF. Note: It is possible that no cached ASCONF-ACK in sctp_sf_do_asconf()
3831 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3834 asconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial); in sctp_sf_do_asconf()
3842 asconf_ack->transport = NULL; in sctp_sf_do_asconf()
3851 * containing the ASCONF-ACK Chunks MUST be the source address of in sctp_sf_do_asconf()
3859 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
3861 if (asoc->new_transport) { in sctp_sf_do_asconf()
3862 sctp_sf_heartbeat(ep, asoc, type, asoc->new_transport, commands); in sctp_sf_do_asconf()
3863 ((struct sctp_association *)asoc)->new_transport = NULL; in sctp_sf_do_asconf()
3879 if (list_empty(&asoc->addip_chunk_list)) in sctp_send_next_asconf()
3882 entry = asoc->addip_chunk_list.next; in sctp_send_next_asconf()
3887 asoc->addip_last_asconf = asconf; in sctp_send_next_asconf()
3904 struct sctp_chunk *last_asconf = asoc->addip_last_asconf; in sctp_sf_do_asconf_ack()
3923 /* ADD-IP, Section 4.1.2: in sctp_sf_do_asconf_ack()
3925 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf_ack()
3927 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf_ack()
3929 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf_ack()
3930 (!net->sctp.addip_noauth && !asconf_ack->auth)) in sctp_sf_do_asconf_ack()
3933 addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data; in sctp_sf_do_asconf_ack()
3934 rcvd_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
3936 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
3942 addip_hdr = (struct sctp_addiphdr *)last_asconf->subh.addip_hdr; in sctp_sf_do_asconf_ack()
3943 sent_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
3945 sent_serial = asoc->addip_serial - 1; in sctp_sf_do_asconf_ack()
3948 /* D0) If an endpoint receives an ASCONF-ACK that is greater than or in sctp_sf_do_asconf_ack()
3951 * sequence number is greater than if it is no more than 2^^31-1 in sctp_sf_do_asconf_ack()
3955 !(asoc->addip_last_asconf)) { in sctp_sf_do_asconf_ack()
3978 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { in sctp_sf_do_asconf_ack()
4011 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
4039 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4044 if (param.p->type == SCTP_PARAM_RESET_OUT_REQUEST) in sctp_sf_do_reconf()
4047 else if (param.p->type == SCTP_PARAM_RESET_IN_REQUEST) in sctp_sf_do_reconf()
4050 else if (param.p->type == SCTP_PARAM_RESET_TSN_REQUEST) in sctp_sf_do_reconf()
4053 else if (param.p->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) in sctp_sf_do_reconf()
4056 else if (param.p->type == SCTP_PARAM_RESET_ADD_IN_STREAMS) in sctp_sf_do_reconf()
4059 else if (param.p->type == SCTP_PARAM_RESET_RESPONSE) in sctp_sf_do_reconf()
4076 * PR-SCTP Section 3.6 Receiver Side Implementation of PR-SCTP
4078 * When a FORWARD TSN chunk arrives, the data receiver MUST first update
4079 * its cumulative TSN point to the value carried in the FORWARD TSN
4080 * chunk, and then MUST further advance its cumulative TSN point locally
4083 * missing TSNs earlier than or equal to the new cumulative TSN point.
4099 __u32 tsn; in sctp_sf_eat_fwd_tsn() local
4107 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn()
4111 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn()
4115 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn()
4116 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn()
4117 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn()
4118 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn()
4119 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn()
4121 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn()
4122 pr_debug("%s: TSN 0x%x\n", __func__, tsn); in sctp_sf_eat_fwd_tsn()
4124 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn()
4127 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn()
4130 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4133 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_FWDTSN, SCTP_U32(tsn)); in sctp_sf_eat_fwd_tsn()
4134 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn()
4139 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_fwd_tsn()
4166 __u32 tsn; in sctp_sf_eat_fwd_tsn_fast() local
4174 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn_fast()
4178 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn_fast()
4182 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn_fast()
4183 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn_fast()
4184 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn_fast()
4185 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn_fast()
4186 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn_fast()
4188 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn_fast()
4189 pr_debug("%s: TSN 0x%x\n", __func__, tsn); in sctp_sf_eat_fwd_tsn_fast()
4191 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn_fast()
4194 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn_fast()
4197 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4200 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_FWDTSN, SCTP_U32(tsn)); in sctp_sf_eat_fwd_tsn_fast()
4201 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn_fast()
4209 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_fwd_tsn_fast()
4211 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_fwd_tsn_fast()
4222 * SCTP-AUTH Section 6.3 Receiving authenticated chukns
4226 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4255 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_authenticate()
4256 chunk->subh.auth_hdr = auth_hdr; in sctp_sf_authenticate()
4257 skb_pull(chunk->skb, sizeof(*auth_hdr)); in sctp_sf_authenticate()
4262 if (!sctp_auth_asoc_verify_hmac_id(asoc, auth_hdr->hmac_id)) in sctp_sf_authenticate()
4268 key_id = ntohs(auth_hdr->shkey_id); in sctp_sf_authenticate()
4269 if (key_id != asoc->active_key_id) { in sctp_sf_authenticate()
4278 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4280 hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); in sctp_sf_authenticate()
4281 if (sig_len != hmac->hmac_len) in sctp_sf_authenticate()
4291 digest = auth_hdr->hmac; in sctp_sf_authenticate()
4292 skb_pull(chunk->skb, sig_len); in sctp_sf_authenticate()
4300 sctp_auth_calculate_hmac(asoc, chunk->skb, in sctp_sf_authenticate()
4301 (struct sctp_auth_chunk *)chunk->chunk_hdr, in sctp_sf_authenticate()
4311 chunk->auth = 1; in sctp_sf_authenticate()
4329 /* Make sure that the peer has AUTH capable */ in sctp_sf_eat_auth()
4330 if (!asoc->peer.auth_capable) in sctp_sf_eat_auth()
4344 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4353 &auth_hdr->hmac_id, in sctp_sf_eat_auth()
4375 if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { in sctp_sf_eat_auth()
4378 ev = sctp_ulpevent_make_authkey(asoc, ntohs(auth_hdr->shkey_id), in sctp_sf_eat_auth()
4396 * Chunk Types are encoded such that the highest-order two bits specify
4400 * 00 - Stop processing this SCTP packet and discard it, do not process
4403 * 01 - Stop processing this SCTP packet and discard it, do not process
4407 * 10 - Skip this chunk and continue processing.
4409 * 11 - Skip this chunk and continue processing, but report in an ERROR
4444 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4447 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4462 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4465 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4600 /* SCTP-AUTH, Section 6.3: in sctp_sf_abort_violation()
4620 /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ in sctp_sf_abort_violation()
4621 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4622 !asoc->peer.i.init_tag) { in sctp_sf_abort_violation()
4625 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4627 abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T; in sctp_sf_abort_violation()
4631 inittag = ntohl(initack->init_hdr.init_tag); in sctp_sf_abort_violation()
4640 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { in sctp_sf_abort_violation()
4661 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4663 abort->skb->sk = ep->base.sk; in sctp_sf_abort_violation()
4762 * cumulative tsn ack to a point beyond the max tsn currently sent.
4775 static const char err_str[] = "The cumulative tsn ack beyond the max tsn currently sent:"; in sctp_sf_violation_ctsn()
4782 * when we have an association and we receive bundled INIT-ACK, or
4783 * SHUDOWN-COMPLETE, our peer is clearly violationg the "MUST NOT bundle"
4809 * Section: 10.1 ULP-to-SCTP
4814 * -> association id [,destination transport addr list] [,outbound stream
4843 * stuff happens when the INIT ACK arrives. This is a NON-BLOCKING
4848 * o local SCTP instance name - obtained from the INITIALIZE operation.
4850 * o destination transport addr - specified as one of the transport
4853 * [This is asoc->peer.active_path.]
4854 * o outbound stream count - the number of outbound streams the ULP
4873 /* The comment below says that we enter COOKIE-WAIT AFTER in sctp_sf_do_prm_asoc()
4888 repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); in sctp_sf_do_prm_asoc()
4902 /* After sending the INIT, "A" starts the T1-init timer and in sctp_sf_do_prm_asoc()
4903 * enters the COOKIE-WAIT state. in sctp_sf_do_prm_asoc()
4917 * Section: 10.1 ULP-to-SCTP
4922 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
4923 * -> result
4929 * o association id - local handle to the SCTP association
4931 * o buffer address - the location where the user message to be
4934 * o byte count - The size of the user data in number of bytes;
4938 * o context - an optional 32 bit integer that will be carried in the
4942 * o stream id - to indicate which stream to send the data on. If not
4945 * o life time - specifies the life time of the user data. The user data
4954 * o destination transport address - specified as one of the destination
4960 * o unorder flag - this flag, if present, indicates that the user
4965 * o no-bundle flag - instructs SCTP not to bundle this user data with
4969 * o payload protocol-id - A 32 bit unsigned integer that is to be
4995 * -> result
5006 * o association id - local handle to the SCTP association
5026 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_do_9_2_prm_shutdown()
5036 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_prm_shutdown()
5051 * -> result
5061 * o association id - local handle to the SCTP association
5065 * o cause code - reason of the abort to be passed to the peer
5116 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_ERROR, SCTP_ERROR(-EINVAL)); in sctp_sf_error_closed()
5132 SCTP_ERROR(-ESHUTDOWN)); in sctp_sf_error_shutdown()
5194 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_shutdown()
5223 /* Stop T1-init timer */ in sctp_sf_cookie_wait_prm_abort()
5271 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_abort()
5283 * state table when someone issues an abort while in SHUTDOWN-PENDING state.
5296 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_pending_prm_abort()
5310 * state table when someone issues an abort while in SHUTDOWN-SENT state.
5323 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_prm_abort()
5327 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_prm_abort()
5355 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_prm_abort()
5363 * 10.1 ULP-to-SCTP
5368 * -> result
5377 * o association id - local handle to the SCTP association
5379 * o destination transport address - the transport address of the
5397 * D) Request an on-demand HEARTBEAT on a specific destination in sctp_sf_do_prm_requestheartbeat()
5431 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5499 * TSN Ack field the last sequential TSN it has received from the peer.
5500 * It shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT
5501 * state. If the timer expires, the endpoint must re-send the SHUTDOWN
5502 * with the updated last sequential TSN received from its peer.
5518 * in the Cumulative TSN Ack field the last sequential TSN it in sctp_sf_do_9_2_start_shutdown()
5526 * T2-shutdown timer. in sctp_sf_do_9_2_start_shutdown()
5530 /* It shall then start the T2-shutdown timer */ in sctp_sf_do_9_2_start_shutdown()
5536 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. in sctp_sf_do_9_2_start_shutdown()
5541 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_start_shutdown()
5545 /* and enter the SHUTDOWN-SENT state. */ in sctp_sf_do_9_2_start_shutdown()
5549 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_start_shutdown()
5552 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_start_shutdown()
5570 * shall send a SHUTDOWN ACK and start a T2-shutdown timer of its own,
5571 * entering the SHUTDOWN-ACK-SENT state. If the timer expires, the
5572 * endpoint must re-send the SHUTDOWN ACK.
5614 * the T2-shutdown timer. in sctp_sf_do_9_2_shutdown_ack()
5618 /* and start/restart a T2-shutdown timer of its own, */ in sctp_sf_do_9_2_shutdown_ack()
5622 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_shutdown_ack()
5626 /* Enter the SHUTDOWN-ACK-SENT state. */ in sctp_sf_do_9_2_shutdown_ack()
5630 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_shutdown_ack()
5633 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_shutdown_ack()
5670 * Section: 6.3.3 Handle T3-rtx Expiration
5672 * Whenever the retransmission timer T3-rtx expires for a destination
5689 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_do_6_3_3_rtx()
5690 if (asoc->peer.zero_window_announced && in sctp_sf_do_6_3_3_rtx()
5691 asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { in sctp_sf_do_6_3_3_rtx()
5717 * 7.2.3 and set the cwnd <- MTU. in sctp_sf_do_6_3_3_rtx()
5721 * expires, set RTO <- RTO * 2 ("back off the timer"). The in sctp_sf_do_6_3_3_rtx()
5726 /* E3) Determine how many of the earliest (i.e., lowest TSN) in sctp_sf_do_6_3_3_rtx()
5728 * T3-rtx has expired will fit into a single packet, subject in sctp_sf_do_6_3_3_rtx()
5737 * which the T3-rtx timer expired but did not fit in one MTU in sctp_sf_do_6_3_3_rtx()
5787 * 2) If the T1-init timer expires, the endpoint MUST retransmit INIT
5788 * and re-start the T1-init timer without changing state. This MUST
5805 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_init_timer_expire()
5813 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_init_timer_expire()
5814 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_t1_init_timer_expire()
5831 asoc->max_init_attempts); in sctp_sf_t1_init_timer_expire()
5852 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
5853 * COOKIE ECHO and re-start the T1-cookie timer without changing
5870 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_cookie_timer_expire()
5873 pr_debug("%s: timer T1 expired (COOKIE-ECHO)\n", __func__); in sctp_sf_t1_cookie_timer_expire()
5877 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_cookie_timer_expire()
5900 /* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
5901 * with the updated last sequential TSN received from its peer.
5910 * the T2-Shutdown timer, giving its peer ample opportunity to transmit
5927 ((struct sctp_association *)asoc)->shutdown_retries++; in sctp_sf_t2_timer_expire()
5929 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t2_timer_expire()
5940 switch (asoc->state) { in sctp_sf_t2_timer_expire()
5961 if (asoc->shutdown_last_sent_to) in sctp_sf_t2_timer_expire()
5963 SCTP_TRANSPORT(asoc->shutdown_last_sent_to)); in sctp_sf_t2_timer_expire()
5966 * the T2-shutdown timer. in sctp_sf_t2_timer_expire()
5970 /* Restart the T2-shutdown timer. */ in sctp_sf_t2_timer_expire()
5992 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire()
5993 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
6013 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t4_timer_expire()
6025 /* ADDIP 4.1 B3) Back-off the destination address RTO value to which in sctp_sf_t4_timer_expire()
6030 /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible in sctp_sf_t4_timer_expire()
6036 sctp_chunk_hold(asoc->addip_last_asconf); in sctp_sf_t4_timer_expire()
6038 SCTP_CHUNK(asoc->addip_last_asconf)); in sctp_sf_t4_timer_expire()
6040 /* ADDIP 4.1 B5) Restart the T-4 RTO timer. Note that if a different in sctp_sf_t4_timer_expire()
6050 /* sctpimpguide-05 Section 2.12.2
6052 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
6107 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_autoclose_timer_expire()
6117 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_autoclose_timer_expire()
6201 sack = (struct sctp_sackhdr *) chunk->skb->data; in sctp_sm_pull_sack()
6203 num_blocks = ntohs(sack->num_gap_ack_blocks); in sctp_sm_pull_sack()
6204 num_dup_tsns = ntohs(sack->num_dup_tsns); in sctp_sm_pull_sack()
6207 if (len > chunk->skb->len) in sctp_sm_pull_sack()
6210 skb_pull(chunk->skb, len); in sctp_sm_pull_sack()
6240 /* Reflect vtag if T-Bit is set */ in sctp_abort_pkt_new()
6242 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6250 abort->skb->sk = ep->base.sk; in sctp_abort_pkt_new()
6271 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6272 dport = ntohs(chunk->sctp_hdr->source); in sctp_ootb_pkt_new()
6274 /* The V-tag is going to be the same as the inbound packet if no in sctp_ootb_pkt_new()
6278 /* Special case the INIT-ACK as there is no peer's vtag in sctp_ootb_pkt_new()
6281 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6287 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6288 vtag = ntohl(initack->init_hdr.init_tag); in sctp_ootb_pkt_new()
6292 vtag = asoc->peer.i.init_tag; in sctp_ootb_pkt_new()
6299 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6304 init = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6305 vtag = ntohl(init->init_hdr.init_tag); in sctp_ootb_pkt_new()
6309 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6322 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6323 sctp_sk(net->sctp.ctl_sock)); in sctp_ootb_pkt_new()
6325 packet = &transport->packet; in sctp_ootb_pkt_new()
6338 sctp_transport_free(packet->transport); in sctp_ootb_pkt_free()
6357 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6358 packet->vtag = cookie->c.peer_vtag; in sctp_send_stale_cookie_err()
6361 err_chunk->skb->sk = ep->base.sk; in sctp_send_stale_cookie_err()
6377 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_eat_data()
6378 struct sock *sk = asoc->base.sk; in sctp_eat_data()
6384 __u32 tsn; in sctp_eat_data() local
6387 data_hdr = (struct sctp_datahdr *)chunk->skb->data; in sctp_eat_data()
6388 chunk->subh.data_hdr = data_hdr; in sctp_eat_data()
6389 skb_pull(chunk->skb, sctp_datahdr_len(&asoc->stream)); in sctp_eat_data()
6391 tsn = ntohl(data_hdr->tsn); in sctp_eat_data()
6392 pr_debug("%s: TSN 0x%x\n", __func__, tsn); in sctp_eat_data()
6394 /* ASSERT: Now skb->data is really the user data. */ in sctp_eat_data()
6406 if (asoc->peer.ecn_capable && !chunk->ecn_ce_done) { in sctp_eat_data()
6407 struct sctp_af *af = SCTP_INPUT_CB(chunk->skb)->af; in sctp_eat_data()
6408 chunk->ecn_ce_done = 1; in sctp_eat_data()
6410 if (af->is_ce(sctp_gso_headskb(chunk->skb))) { in sctp_eat_data()
6413 SCTP_U32(tsn)); in sctp_eat_data()
6417 tmp = sctp_tsnmap_check(&asoc->peer.tsn_map, tsn); in sctp_eat_data()
6419 /* The TSN is too high--silently discard the chunk and in sctp_eat_data()
6422 if (chunk->asoc) in sctp_eat_data()
6423 chunk->asoc->stats.outofseqtsns++; in sctp_eat_data()
6427 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_DUP, SCTP_U32(tsn)); in sctp_eat_data()
6431 /* This is a new TSN. */ in sctp_eat_data()
6436 datalen = ntohs(chunk->chunk_hdr->length); in sctp_eat_data()
6437 datalen -= sctp_datachk_len(&asoc->stream); in sctp_eat_data()
6442 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) { in sctp_eat_data()
6455 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6456 (datalen > asoc->rwnd + asoc->frag_point))) { in sctp_eat_data()
6458 /* If this is the next TSN, consider reneging to make in sctp_eat_data()
6465 (sctp_tsnmap_get_ctsn(map) + 1) == tsn) { in sctp_eat_data()
6466 pr_debug("%s: reneging for tsn:%u\n", __func__, tsn); in sctp_eat_data()
6469 pr_debug("%s: discard tsn:%u len:%zu, rwnd:%d\n", in sctp_eat_data()
6470 __func__, tsn, datalen, asoc->rwnd); in sctp_eat_data()
6485 (sctp_tsnmap_get_ctsn(map) + 1) == tsn) { in sctp_eat_data()
6486 pr_debug("%s: under pressure, reneging for tsn:%u\n", in sctp_eat_data()
6487 __func__, tsn); in sctp_eat_data()
6498 * --------------- in sctp_eat_data()
6503 err = sctp_make_abort_no_data(asoc, chunk, tsn); in sctp_eat_data()
6521 chunk->data_accepted = 1; in sctp_eat_data()
6526 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_eat_data()
6528 if (chunk->asoc) in sctp_eat_data()
6529 chunk->asoc->stats.iuodchunks++; in sctp_eat_data()
6532 if (chunk->asoc) in sctp_eat_data()
6533 chunk->asoc->stats.iodchunks++; in sctp_eat_data()
6544 if (ntohs(data_hdr->stream) >= asoc->stream.incnt) { in sctp_eat_data()
6545 /* Mark tsn as received even though we drop it */ in sctp_eat_data()
6546 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_TSN, SCTP_U32(tsn)); in sctp_eat_data()
6549 &data_hdr->stream, in sctp_eat_data()
6550 sizeof(data_hdr->stream), in sctp_eat_data()
6558 /* Check to see if the SSN is possible for this TSN. in sctp_eat_data()
6561 * wrap and for a valid TSN. We can simply check if the current in sctp_eat_data()
6565 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()