Lines Matching +full:always +full:- +full:wait +full:- +full:for +full:- +full:ack

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.
11 * These are the state functions for the state machine.
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()
186 /* Check for format error in an ABORT chunk */
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()
197 * These are the state functions for handling chunk events.
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
211 * C) Rules for packet carrying SHUTDOWN COMPLETE:
213 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
221 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
245 * An endpoint MUST NOT bundle INIT, INIT ACK or in sctp_sf_do_4_C()
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()
296 * We are the side that is being asked for an association.
299 * B) "Z" shall respond immediately with an INIT ACK chunk. The
300 * destination IP address of the INIT ACK MUST be set to the source
301 * IP address of the INIT to which this INIT ACK is responding. In
331 chunk->skb)) in sctp_sf_do_5_1B_init()
335 * An endpoint MUST NOT bundle INIT, INIT ACK or in sctp_sf_do_5_1B_init()
343 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
357 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1B_init()
365 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
374 if (sctp_sstate(ep->base.sk, CLOSING)) in sctp_sf_do_5_1B_init()
379 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1B_init()
380 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1B_init()
387 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
389 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
409 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1B_init()
412 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1B_init()
425 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
429 /* B) "Z" shall respond immediately with an INIT ACK chunk. */ in sctp_sf_do_5_1B_init()
431 /* If there are errors need to be reported for unknown parameters, in sctp_sf_do_5_1B_init()
432 * make sure to reserve enough room in the INIT ACK for them. in sctp_sf_do_5_1B_init()
436 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
443 /* If there are errors need to be reported for unknown parameters, in sctp_sf_do_5_1B_init()
444 * include them in the outgoing INIT ACK as "Unrecognized parameter" in sctp_sf_do_5_1B_init()
450 * error cause code for "unknown parameter" and the in sctp_sf_do_5_1B_init()
452 * construct the parameters in INIT ACK by copying the in sctp_sf_do_5_1B_init()
456 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
470 * Note: After sending out INIT ACK with the State Cookie parameter, in sctp_sf_do_5_1B_init()
471 * "Z" MUST NOT allocate any resources, nor keep any states for the in sctp_sf_do_5_1B_init()
488 * Respond to a normal INIT ACK chunk.
492 * C) Upon reception of the INIT ACK from "Z", "A" shall stop the T1-init
493 * timer and leave COOKIE-WAIT state. "A" shall then send the State
494 * Cookie received in the INIT ACK chunk in a COOKIE ECHO chunk, start
495 * the T1-cookie timer, and enter the COOKIE-ECHOED state.
499 * until the COOKIE ACK is returned the sender MUST NOT send any
503 * If the value of the Initiate Tag in a received INIT ACK chunk is
531 * An endpoint MUST NOT bundle INIT, INIT ACK or in sctp_sf_do_5_1C_ack()
534 if (!chunk->singleton) in sctp_sf_do_5_1C_ack()
537 /* Make sure that the INIT-ACK chunk has a valid length */ in sctp_sf_do_5_1C_ack()
542 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1C_ack()
546 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1C_ack()
547 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1C_ack()
559 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1C_ack()
561 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1C_ack()
574 /* SCTP-AUTH, Section 6.3: in sctp_sf_do_5_1C_ack()
590 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
596 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1C_ack()
598 initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_sf_do_5_1C_ack()
603 /* Reset init error count upon receipt of INIT-ACK. */ in sctp_sf_do_5_1C_ack()
606 /* 5.1 C) "A" shall stop the T1-init timer and leave in sctp_sf_do_5_1C_ack()
607 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie in sctp_sf_do_5_1C_ack()
608 * timer, and enter the COOKIE-ECHOED state. in sctp_sf_do_5_1C_ack()
617 /* SCTP-AUTH: generate the association shared keys so that in sctp_sf_do_5_1C_ack()
618 * we can potentially sign the COOKIE-ECHO. in sctp_sf_do_5_1C_ack()
623 * INIT ACK chunk in a COOKIE ECHO chunk, ... in sctp_sf_do_5_1C_ack()
626 * for unknown parameters as well. in sctp_sf_do_5_1C_ack()
639 if (!chunk->auth_chunk) in sctp_auth_chunk_verify()
642 /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo in sctp_auth_chunk_verify()
650 if (!net->sctp.auth_enable || !asoc->peer.auth_capable) in sctp_auth_chunk_verify()
653 /* set-up our fake chunk so that we can process it */ in sctp_auth_chunk_verify()
654 auth.skb = chunk->auth_chunk; in sctp_auth_chunk_verify()
655 auth.asoc = chunk->asoc; in sctp_auth_chunk_verify()
656 auth.sctp_hdr = chunk->sctp_hdr; in sctp_auth_chunk_verify()
658 skb_push(chunk->auth_chunk, in sctp_auth_chunk_verify()
660 skb_pull(chunk->auth_chunk, sizeof(struct sctp_chunkhdr)); in sctp_auth_chunk_verify()
661 auth.transport = chunk->transport; in sctp_auth_chunk_verify()
668 * We are the side that is being asked for an association.
672 * with a COOKIE ACK chunk after building a TCB and moving to
673 * the ESTABLISHED state. A COOKIE ACK chunk may be bundled with
674 * any pending DATA chunks (and/or SACK chunks), but the COOKIE ACK
682 * D) Rules for packet carrying a COOKIE ECHO
684 * - When sending a COOKIE ECHO, the endpoint MUST use the value of the
685 * Initial Tag received in the INIT ACK.
687 * - The receiver of a COOKIE ECHO follows the procedures in Section 5.
719 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1D_ce()
725 * In this case, we check that we have enough for at least a in sctp_sf_do_5_1D_ce()
734 * on the TCP-style socket exceed the max backlog, respond with an in sctp_sf_do_5_1D_ce()
737 sk = ep->base.sk; in sctp_sf_do_5_1D_ce()
745 chunk->subh.cookie_hdr = in sctp_sf_do_5_1D_ce()
746 (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_1D_ce()
747 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_1D_ce()
752 * "Z" will reply with a COOKIE ACK chunk after building a TCB in sctp_sf_do_5_1D_ce()
759 * If the re-build failed, what is the proper error path in sctp_sf_do_5_1D_ce()
762 * [We should abort the association. --piggy] in sctp_sf_do_5_1D_ce()
769 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_1D_ce()
772 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_1D_ce()
777 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_1D_ce()
786 * Re-build the bind address for the association is done in in sctp_sf_do_5_1D_ce()
789 /* This is a brand-new association, so these are not yet side in sctp_sf_do_5_1D_ce()
790 * effects--it is safe to run them here. in sctp_sf_do_5_1D_ce()
792 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_5_1D_ce()
795 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
799 /* SCTP-AUTH: Now that we've populate required fields in in sctp_sf_do_5_1D_ce()
801 * necessary so that we can potentially authenticate the ACK in sctp_sf_do_5_1D_ce()
823 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1D_ce()
824 new_asoc->c.sinit_max_instreams, in sctp_sf_do_5_1D_ce()
834 if (new_asoc->peer.adaptation_ind) { in sctp_sf_do_5_1D_ce()
841 if (!new_asoc->peer.auth_capable) { in sctp_sf_do_5_1D_ce()
851 * during side-effect processing and correctly count established in sctp_sf_do_5_1D_ce()
861 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1D_ce()
865 /* This will send the COOKIE ACK */ in sctp_sf_do_5_1D_ce()
895 * Respond to a normal COOKIE ACK chunk.
896 * We are the side that is asking for an association.
900 * E) Upon reception of the COOKIE ACK, endpoint "A" will move from the
901 * COOKIE-ECHOED state to the ESTABLISHED state, stopping the T1-cookie
928 /* Verify that the chunk length for the COOKIE-ACK is OK. in sctp_sf_do_5_1E_ca()
935 /* Reset init error count upon receipt of COOKIE-ACK, in sctp_sf_do_5_1E_ca()
938 * from the COOKIE-ECHOED state to the COOKIE-WAIT in sctp_sf_do_5_1E_ca()
943 /* Set peer label for connection. */ in sctp_sf_do_5_1E_ca()
944 security_inet_conn_established(ep->base.sk, chunk->skb); in sctp_sf_do_5_1E_ca()
948 * E) Upon reception of the COOKIE ACK, endpoint "A" will move in sctp_sf_do_5_1E_ca()
949 * from the COOKIE-ECHOED state to the ESTABLISHED state, in sctp_sf_do_5_1E_ca()
950 * stopping the T1-cookie timer. in sctp_sf_do_5_1E_ca()
959 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1E_ca()
968 0, asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1E_ca()
969 asoc->c.sinit_max_instreams, in sctp_sf_do_5_1E_ca()
982 if (asoc->peer.adaptation_ind) { in sctp_sf_do_5_1E_ca()
991 if (!asoc->peer.auth_capable) { in sctp_sf_do_5_1E_ca()
1041 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_sendbeat_8_3()
1053 * The Sender-specific Heartbeat Info field should normally include in sctp_sf_sendbeat_8_3()
1059 if (transport->param_flags & SPP_HB_ENABLE) { in sctp_sf_sendbeat_8_3()
1089 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_send_reconf()
1100 sctp_chunk_hold(asoc->strreset_chunk); in sctp_sf_send_reconf()
1102 SCTP_CHUNK(asoc->strreset_chunk)); in sctp_sf_send_reconf()
1108 /* send hb chunk with padding for PLPMUTD. */
1123 reply = sctp_make_heartbeat(asoc, transport, transport->pl.probe_size); in sctp_sf_send_probe()
1139 * HEARTBEAT ACK that contains the Heartbeat Information field copied
1147 * discard the packet and shall not process it any further except for
1179 * respond with a HEARTBEAT ACK that contains the Heartbeat in sctp_sf_beat_8_3()
1182 chunk->subh.hb_hdr = (struct sctp_heartbeathdr *)chunk->skb->data; in sctp_sf_beat_8_3()
1183 param_hdr = (struct sctp_paramhdr *)chunk->subh.hb_hdr; in sctp_sf_beat_8_3()
1184 paylen = ntohs(chunk->chunk_hdr->length) - sizeof(struct sctp_chunkhdr); in sctp_sf_beat_8_3()
1186 if (ntohs(param_hdr->length) > paylen) in sctp_sf_beat_8_3()
1190 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1205 * Process the returning HEARTBEAT ACK.
1208 * Upon the receipt of the HEARTBEAT ACK, the sender of the HEARTBEAT
1214 * HEARTBEAT ACK. The receiver of the HEARTBEAT ACK must also
1218 * The receiver of the HEARTBEAT ACK should also perform an RTT
1219 * measurement for that destination transport address using the time
1220 * value carried in the HEARTBEAT ACK chunk.
1248 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1254 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1256 if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo)) in sctp_sf_backbeat_8_3()
1259 from_addr = hbinfo->daddr; in sctp_sf_backbeat_8_3()
1278 /* Validate the 64-bit random nonce. */ in sctp_sf_backbeat_8_3()
1279 if (hbinfo->hb_nonce != link->hb_nonce) in sctp_sf_backbeat_8_3()
1282 if (hbinfo->probe_size) { in sctp_sf_backbeat_8_3()
1283 if (hbinfo->probe_size != link->pl.probe_size || in sctp_sf_backbeat_8_3()
1293 max_interval = link->hbinterval + link->rto; in sctp_sf_backbeat_8_3()
1296 if (time_after(hbinfo->sent_at, jiffies) || in sctp_sf_backbeat_8_3()
1297 time_after(jiffies, hbinfo->sent_at + max_interval)) { in sctp_sf_backbeat_8_3()
1298 pr_debug("%s: HEARTBEAT ACK with invalid timestamp received " in sctp_sf_backbeat_8_3()
1299 "for transport:%p\n", __func__, link); in sctp_sf_backbeat_8_3()
1304 /* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of in sctp_sf_backbeat_8_3()
1315 /* Helper function to send out an abort for the restart
1322 struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); in sctp_sf_send_restart_abort()
1334 addrparm = (union sctp_addr_param *)errhdr->variable; in sctp_sf_send_restart_abort()
1337 len = af->to_addr_param(ssa, addrparm); in sctp_sf_send_restart_abort()
1340 errhdr->cause = SCTP_ERROR_RESTART; in sctp_sf_send_restart_abort()
1341 errhdr->length = htons(len); in sctp_sf_send_restart_abort()
1344 ep = sctp_sk(net->sctp.ctl_sock)->ep; in sctp_sf_send_restart_abort()
1373 if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr)) in list_has_sctp_addr()
1387 struct net *net = new_asoc->base.net; in sctp_sf_check_restart_addrs()
1391 /* Implementor's Guide - Section 5.2.2 in sctp_sf_check_restart_addrs()
1402 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1404 if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1405 &new_addr->ipaddr)) { in sctp_sf_check_restart_addrs()
1406 sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, in sctp_sf_check_restart_addrs()
1420 * Note: Do not use in CLOSED or SHUTDOWN-ACK-SENT state.
1425 switch (asoc->state) { in sctp_tietags_populate()
1427 /* 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State */ in sctp_tietags_populate()
1430 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1431 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1432 new_asoc->c.peer_ttag = 0; in sctp_tietags_populate()
1436 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1437 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1438 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1441 /* 5.2.2 Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, in sctp_tietags_populate()
1442 * COOKIE-WAIT and SHUTDOWN-ACK-SENT in sctp_tietags_populate()
1445 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1446 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1450 /* Other parameters for the endpoint SHOULD be copied from the in sctp_tietags_populate()
1452 * outbound streams) into the INIT ACK and cookie. in sctp_tietags_populate()
1454 new_asoc->rwnd = asoc->rwnd; in sctp_tietags_populate()
1455 new_asoc->c.sinit_num_ostreams = asoc->c.sinit_num_ostreams; in sctp_tietags_populate()
1456 new_asoc->c.sinit_max_instreams = asoc->c.sinit_max_instreams; in sctp_tietags_populate()
1457 new_asoc->c.initial_tsn = asoc->c.initial_tsn; in sctp_tietags_populate()
1461 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1473 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1474 (asoc->c.peer_vtag != new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1475 (asoc->c.my_vtag == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1476 (asoc->c.peer_vtag == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1480 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1481 ((asoc->c.peer_vtag != new_asoc->c.peer_vtag) || in sctp_tietags_compare()
1482 (0 == asoc->c.peer_vtag))) { in sctp_tietags_compare()
1487 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1488 (asoc->c.peer_vtag == new_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()
1494 (0 == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1495 (0 == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1502 /* Common helper routine for both duplicate and simultaneous INIT
1522 chunk->skb)) in sctp_sf_do_unexpected_init()
1526 * An endpoint MUST NOT bundle INIT, INIT ACK or in sctp_sf_do_unexpected_init()
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()
1587 * Other parameters for the endpoint SHOULD be copied from the in sctp_sf_do_unexpected_init()
1589 * outbound streams) into the INIT ACK and cookie. in sctp_sf_do_unexpected_init()
1601 /* In the outbound INIT ACK the endpoint MUST copy its current in sctp_sf_do_unexpected_init()
1603 * place (local tie-tag and per tie-tag) within the state cookie. in sctp_sf_do_unexpected_init()
1606 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1611 * restart. Do not do this check for COOKIE-WAIT state, in sctp_sf_do_unexpected_init()
1625 /* B) "Z" shall respond immediately with an INIT ACK chunk. */ in sctp_sf_do_unexpected_init()
1627 /* If there are errors need to be reported for unknown parameters, in sctp_sf_do_unexpected_init()
1628 * make sure to reserve enough room in the INIT ACK for them. in sctp_sf_do_unexpected_init()
1632 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1640 /* If there are errors need to be reported for unknown parameters, in sctp_sf_do_unexpected_init()
1641 * include them in the outgoing INIT ACK as "Unrecognized parameter" in sctp_sf_do_unexpected_init()
1647 * error cause code for "unknown parameter" and the in sctp_sf_do_unexpected_init()
1649 * construct the parameters in INIT ACK by copying the in sctp_sf_do_unexpected_init()
1653 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1665 * Note: After sending out INIT ACK with the State Cookie parameter, in sctp_sf_do_unexpected_init()
1666 * "Z" MUST NOT allocate any resources for this new association. in sctp_sf_do_unexpected_init()
1690 * Section: 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State (Item B)
1695 * Upon receipt of an INIT in the COOKIE-WAIT or COOKIE-ECHOED state, an
1696 * endpoint MUST respond with an INIT ACK using the same parameters it
1700 * Cookie with the INIT ACK. The endpoint uses the parameters sent in its
1703 * After that, the endpoint MUST NOT change its state, the T1-init
1705 * destroyed. The normal procedures for handling State Cookies when
1708 * For an endpoint that is in the COOKIE-ECHOED state it MUST populate
1709 * its Tie-Tags with the Tag information of itself and its peer (see
1710 * section 5.2.2 for a description of the Tie-Tags).
1731 /* Call helper to do the real work for both simultaneous and in sctp_sf_do_5_2_1_siminit()
1742 * COOKIE-ECHOED and COOKIE-WAIT
1744 * Unless otherwise stated, upon reception of an unexpected INIT for
1745 * this association, the endpoint shall generate an INIT ACK with a
1746 * State Cookie. In the outbound INIT ACK the endpoint MUST copy its
1749 * the Peer's-Tie-Tag and the Local-Tie-Tag. The outbound SCTP packet
1750 * containing this INIT ACK MUST carry a Verification Tag value equal to
1751 * the Initiation Tag found in the unexpected INIT. And the INIT ACK
1753 * 5.3.1). Other parameters for the endpoint SHOULD be copied from the
1755 * streams) into the INIT ACK and cookie.
1757 * After sending out the INIT ACK, the endpoint shall take no further
1761 * Note: Only when a TCB exists and the association is not in a COOKIE-
1762 * WAIT state are the Tie-Tags populated. For a normal association INIT
1763 * (i.e. the endpoint is in a COOKIE-WAIT state), the Tie-Tags MUST be
1764 * set to 0 (indicating that no previous TCB existed). The INIT ACK and
1786 /* Call helper to do the real work for both simultaneous and in sctp_sf_do_5_2_2_dupinit()
1794 * Unexpected INIT-ACK handler.
1797 * If an INIT ACK received by an endpoint in any state other than the
1798 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1799 * An unexpected INIT ACK usually indicates the processing of an old or
1811 * endpoint. If this is an OOTB INIT-ACK, treat it as such. in sctp_sf_do_5_2_3_initack()
1813 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) in sctp_sf_do_5_2_3_initack()
1823 struct net *net = asoc->base.net; in sctp_sf_do_assoc_update()
1840 return -ENOMEM; in sctp_sf_do_assoc_update()
1843 /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A')
1862 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_a()
1863 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_a()
1865 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_dupcook_a()
1884 /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in sctp_sf_do_dupcook_a()
1886 * association but instead resend the SHUTDOWN ACK and send an ERROR in sctp_sf_do_dupcook_a()
1892 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1907 /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked in sctp_sf_do_dupcook_a()
1915 /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue in sctp_sf_do_dupcook_a()
1916 * and ASCONF-ACK cache. in sctp_sf_do_dupcook_a()
1932 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_a()
1933 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_a()
1941 (sctp_sstate(asoc->base.sk, CLOSING) || in sctp_sf_do_dupcook_a()
1942 sock_flag(asoc->base.sk, SOCK_DEAD))) { in sctp_sf_do_dupcook_a()
1964 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'B')
1983 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_b()
1984 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_b()
1986 peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; in sctp_sf_do_dupcook_b()
1999 if (asoc->state < SCTP_STATE_ESTABLISHED) in sctp_sf_do_dupcook_b()
2019 * Sadly, this needs to be implemented as a side-effect, because in sctp_sf_do_dupcook_b()
2032 * This also needs to be done as a side effect for the same reason as in sctp_sf_do_dupcook_b()
2035 if (asoc->peer.adaptation_ind) in sctp_sf_do_dupcook_b()
2038 if (!asoc->peer.auth_capable) in sctp_sf_do_dupcook_b()
2047 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'C')
2052 * INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
2071 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2075 * D) When both local and remote tags match the endpoint should always
2092 * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state. in sctp_sf_do_dupcook_d()
2094 * a COOKIE ACK. in sctp_sf_do_dupcook_d()
2101 if (asoc->state < SCTP_STATE_ESTABLISHED) { in sctp_sf_do_dupcook_d()
2119 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_d()
2120 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_d()
2130 if (asoc->peer.adaptation_ind) { in sctp_sf_do_dupcook_d()
2138 if (!asoc->peer.auth_capable) { in sctp_sf_do_dupcook_d()
2176 * Handle a duplicate COOKIE-ECHO. This usually means a cookie-carrying
2208 * enough for the chunk header. Cookie length verification is in sctp_sf_do_5_2_4_dupcook()
2220 chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_2_4_dupcook()
2221 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_2_4_dupcook()
2234 * If the re-build failed, what is the proper error path in sctp_sf_do_5_2_4_dupcook()
2237 * [We should abort the association. --piggy] in sctp_sf_do_5_2_4_dupcook()
2244 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_2_4_dupcook()
2247 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_2_4_dupcook()
2251 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_2_4_dupcook()
2259 chunk->skb)) { in sctp_sf_do_5_2_4_dupcook()
2265 new_asoc->temp = 1; in sctp_sf_do_5_2_4_dupcook()
2293 default: /* Discard packet for all others. */ in sctp_sf_do_5_2_4_dupcook()
2315 * Process an ABORT. (SHUTDOWN-PENDING state)
2336 * If an endpoint receives an ABORT with a format error or for an in sctp_sf_shutdown_pending_abort()
2345 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_pending_abort()
2348 * ignored (see Section 5.3.1 for further details). in sctp_sf_shutdown_pending_abort()
2351 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2361 * Process an ABORT. (SHUTDOWN-SENT state)
2382 * If an endpoint receives an ABORT with a format error or for an in sctp_sf_shutdown_sent_abort()
2391 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_sent_abort()
2394 * ignored (see Section 5.3.1 for further details). in sctp_sf_shutdown_sent_abort()
2397 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2403 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_abort()
2407 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_abort()
2415 * Process an ABORT. (SHUTDOWN-ACK-SENT state)
2428 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_abort()
2469 /* FUTURE FIXME: When PR-SCTP related and other optional in sctp_sf_cookie_echoed_err()
2473 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2474 if (SCTP_ERROR_STALE_COOKIE == err->cause) in sctp_sf_cookie_echoed_err()
2491 * If the association is in the COOKIE-ECHOED state, the endpoint may elect
2520 int attempts = asoc->init_err_counter + 1; in sctp_sf_do_5_2_6_stale()
2527 if (attempts > asoc->max_init_attempts) { in sctp_sf_do_5_2_6_stale()
2535 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2544 * Suggested Cookie Life-span Increment's unit is msec. in sctp_sf_do_5_2_6_stale()
2559 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_do_5_2_6_stale()
2569 /* Stop pending T3-rtx and heartbeat timers */ in sctp_sf_do_5_2_6_stale()
2573 /* Delete non-primary peer ip addresses since we are transitioning in sctp_sf_do_5_2_6_stale()
2574 * back to the COOKIE-WAIT state in sctp_sf_do_5_2_6_stale()
2578 /* If we've sent any data bundled with COOKIE-ECHO we will need to in sctp_sf_do_5_2_6_stale()
2582 SCTP_TRANSPORT(asoc->peer.primary_path)); in sctp_sf_do_5_2_6_stale()
2613 * B) Rules for packet carrying ABORT:
2615 * - The endpoint shall always fill in the Verification Tag field of the
2619 * - If the ABORT is sent in response to an OOTB packet, the endpoint
2622 * - The receiver MUST accept the packet if the Verification Tag
2652 * If an endpoint receives an ABORT with a format error or for an in sctp_sf_do_9_1_abort()
2661 /* ADD-IP: Special case for ABORT chunks in sctp_sf_do_9_1_abort()
2664 * ignored (see Section 5.3.1 for further details). in sctp_sf_do_9_1_abort()
2667 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_do_9_1_abort()
2689 len = ntohs(chunk->chunk_hdr->length); in __sctp_sf_do_9_1_abort()
2691 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in __sctp_sf_do_9_1_abort()
2703 * Process an ABORT. (COOKIE-WAIT state)
2726 * If an endpoint receives an ABORT with a format error or for an in sctp_sf_cookie_wait_abort()
2736 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_cookie_wait_abort()
2738 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in sctp_sf_cookie_wait_abort()
2741 chunk->transport); in sctp_sf_cookie_wait_abort()
2745 * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state)
2761 * Process an ABORT. (COOKIE-ECHOED state)
2772 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_abort()
2809 * - enter the SHUTDOWN-RECEIVED state,
2811 * - stop accepting new data from its SCTP user
2813 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2817 * Once an endpoint as reached the SHUTDOWN-RECEIVED state it MUST NOT
2860 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shutdown()
2861 skb_pull(chunk->skb, sizeof(*sdh)); in sctp_sf_do_9_2_shutdown()
2862 chunk->subh.shutdown_hdr = sdh; in sctp_sf_do_9_2_shutdown()
2863 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shutdown()
2865 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shutdown()
2867 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shutdown()
2872 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shutdown()
2876 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shutdown()
2891 * - enter the SHUTDOWN-RECEIVED state, in sctp_sf_do_9_2_shutdown()
2892 * - stop accepting new data from its SCTP user in sctp_sf_do_9_2_shutdown()
2900 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_shutdown()
2908 /* - verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shutdown()
2913 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2922 * Once an endpoint has reached the SHUTDOWN-RECEIVED state,
2924 * The Cumulative TSN Ack of the received SHUTDOWN chunk
2947 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2948 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shut_ctsn()
2950 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shut_ctsn()
2952 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shut_ctsn()
2957 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_do_9_2_shut_ctsn()
2961 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shut_ctsn()
2964 /* verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shut_ctsn()
2969 SCTP_BE32(sdh->cum_tsn_ack)); in sctp_sf_do_9_2_shut_ctsn()
2975 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
2979 * retransmit the SHUTDOWN ACK chunk.
2997 * the SHUTDOWN ACK. in __sctp_sf_do_9_2_reshutack()
3003 /* Set the transport for the SHUTDOWN ACK chunk and the timeout for in __sctp_sf_do_9_2_reshutack()
3004 * the T2-SHUTDOWN timer. in __sctp_sf_do_9_2_reshutack()
3008 /* and restart the T2-shutdown timer. */ in __sctp_sf_do_9_2_reshutack()
3027 if (!chunk->singleton) in sctp_sf_do_9_2_reshutack()
3033 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_9_2_reshutack()
3046 * RFC 2481 details a specific bit for a sender to send in the header of
3048 * reduced its congestion window. This is termed the CWR bit. For
3082 cwr = (struct sctp_cwrhdr *)chunk->skb->data; in sctp_sf_do_ecn_cwr()
3083 skb_pull(chunk->skb, sizeof(*cwr)); in sctp_sf_do_ecn_cwr()
3085 lowest_tsn = ntohl(cwr->lowest_tsn); in sctp_sf_do_ecn_cwr()
3087 /* Does this CWR ack the last sent congestion notification? */ in sctp_sf_do_ecn_cwr()
3088 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) { in sctp_sf_do_ecn_cwr()
3102 * ECN-Echo
3104 * RFC 2481 details a specific bit for a receiver to send back in its
3106 * Experienced (CE) bit having arrived from the network. For SCTP this
3136 ecne = (struct sctp_ecnehdr *)chunk->skb->data; in sctp_sf_do_ecne()
3137 skb_pull(chunk->skb, sizeof(*ecne)); in sctp_sf_do_ecne()
3141 SCTP_U32(ntohl(ecne->lowest_tsn))); in sctp_sf_do_ecne()
3149 * The SCTP endpoint MUST always acknowledge the reception of each valid
3154 * acknowledgement SHOULD be generated for at least every second packet
3157 * situations it may be beneficial for an SCTP transmitter to be more
3162 * A SCTP receiver MUST NOT generate more than one SACK for every
3193 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_6_2()
3213 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_6_2()
3214 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_6_2()
3219 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3222 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_data_6_2()
3235 * The SCTP endpoint MUST always acknowledge the reception of in sctp_sf_eat_data_6_2()
3240 * Specifically, an acknowledgement SHOULD be generated for at in sctp_sf_eat_data_6_2()
3244 * situations it may be beneficial for an SCTP transmitter to in sctp_sf_eat_data_6_2()
3249 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3269 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3274 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3284 * (4) In SHUTDOWN-SENT state the endpoint MUST acknowledge any received
3313 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_fast_4_4()
3329 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_fast_4_4()
3330 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_fast_4_4()
3339 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_data_fast_4_4()
3341 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_data_fast_4_4()
3343 if (chunk->end_of_packet) { in sctp_sf_eat_data_fast_4_4()
3360 * i) If Cumulative TSN Ack is less than the Cumulative TSN Ack Point,
3361 * then drop the SACK. Since Cumulative TSN Ack is monotonically
3362 * increasing, a SACK whose Cumulative TSN Ack is less than the
3363 * Cumulative TSN Ack Point indicates an out-of-order SACK.
3366 * of bytes still outstanding after processing the Cumulative TSN Ack
3367 * and the Gap Ack Blocks.
3370 * acknowledged via a Gap Ack Block (e.g., the data receiver
3372 * as available for retransmit: Mark it as missing for fast
3374 * timer is running for the destination address to which the DATA
3375 * chunk was originally transmitted, then T3-rtx is started for
3412 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3413 ctsn = ntohl(sackh->cum_tsn_ack); in sctp_sf_eat_sack_6_2()
3415 /* If Cumulative TSN Ack beyond the max tsn currently in sctp_sf_eat_sack_6_2()
3419 if (TSN_lte(asoc->next_tsn, ctsn)) in sctp_sf_eat_sack_6_2()
3424 /* i) If Cumulative TSN Ack is less than the Cumulative TSN in sctp_sf_eat_sack_6_2()
3425 * Ack Point, then drop the SACK. Since Cumulative TSN in sctp_sf_eat_sack_6_2()
3426 * Ack is monotonically increasing, a SACK whose in sctp_sf_eat_sack_6_2()
3427 * Cumulative TSN Ack is less than the Cumulative TSN Ack in sctp_sf_eat_sack_6_2()
3428 * Point indicates an out-of-order SACK. in sctp_sf_eat_sack_6_2()
3430 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_eat_sack_6_2()
3432 asoc->ctsn_ack_point); in sctp_sf_eat_sack_6_2()
3437 /* Return this SACK for further processing. */ in sctp_sf_eat_sack_6_2()
3455 * packet and set the T-bit in the Chunk Flags to indicate that the
3489 /* Reflect vtag if T-Bit is set */ in sctp_sf_tabort_8_4_8()
3491 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3493 /* Set the skb to the belonging sock for accounting. */ in sctp_sf_tabort_8_4_8()
3494 abort->skb->sk = ep->base.sk; in sctp_sf_tabort_8_4_8()
3509 * From Section 4 at draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.
3533 abort->skb->sk = ep->base.sk; in sctp_sf_new_encap_port()
3548 * event as ULP notification for each cause included in the chunk.
3550 * API 5.3.1.3 - SCTP_REMOTE_ERROR
3571 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_sf_operr_notify()
3572 if ((void *)err != (void *)chunk->chunk_end) in sctp_sf_operr_notify()
3583 * Process an inbound SHUTDOWN ACK.
3586 * Upon the receipt of the SHUTDOWN ACK, the SHUTDOWN sender shall
3587 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3630 /* Upon the receipt of the SHUTDOWN ACK, the SHUTDOWN sender shall in sctp_sf_do_9_2_final()
3631 * stop the T2-shutdown timer, in sctp_sf_do_9_2_final()
3656 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3658 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should
3662 * packet with the Verification Tag received in the SHUTDOWN ACK and
3663 * set the T-bit in the Chunk Flags to indicate that the Verification
3670 * packet and set the T-bit in the Chunk Flags to indicate that the
3682 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3694 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3697 if (ntohs(ch->length) < sizeof(*ch)) in sctp_sf_ootb()
3702 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); in sctp_sf_ootb()
3710 if (SCTP_CID_SHUTDOWN_ACK == ch->type) in sctp_sf_ootb()
3718 if (SCTP_CID_ABORT == ch->type) in sctp_sf_ootb()
3722 * or a COOKIE ACK the SCTP Packet should be silently in sctp_sf_ootb()
3726 if (SCTP_CID_COOKIE_ACK == ch->type) in sctp_sf_ootb()
3729 if (SCTP_CID_ERROR == ch->type) { in sctp_sf_ootb()
3731 if (SCTP_ERROR_STALE_COOKIE == err->cause) { in sctp_sf_ootb()
3750 * Handle an "Out of the blue" SHUTDOWN ACK.
3754 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should
3758 * packet with the Verification Tag received in the SHUTDOWN ACK and
3759 * set the T-bit in the Chunk Flags to indicate that the Verification
3795 /* Reflect vtag if T-Bit is set */ in sctp_sf_shut_8_4_5()
3797 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3799 /* Set the skb to the belonging sock for accounting. */ in sctp_sf_shut_8_4_5()
3800 shut->skb->sk = ep->base.sk; in sctp_sf_shut_8_4_5()
3817 * Handle SHUTDOWN ACK in COOKIE_ECHOED or COOKIE_WAIT state.
3819 * Verification Tag: 8.5.1 E) Rules for packet carrying a SHUTDOWN ACK
3820 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the
3824 * chunks. --piggy ]
3879 /* ADD-IP: Section 4.1.1 in sctp_sf_do_asconf()
3881 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3883 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf()
3885 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf()
3886 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3889 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3890 serial = ntohl(hdr->serial); in sctp_sf_do_asconf()
3899 * 'Peer-Serial-Number'. in sctp_sf_do_asconf()
3901 if (serial == asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3903 * we can clean our old ASCONF-ACKs. in sctp_sf_do_asconf()
3905 if (!chunk->has_asconf) in sctp_sf_do_asconf()
3910 * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to in sctp_sf_do_asconf()
3914 * Essentially, do V1-V5. in sctp_sf_do_asconf()
3920 } else if (serial < asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3923 * ('Peer- Sequence-Number' + 1), simply skip to the next in sctp_sf_do_asconf()
3925 * any previously cached ASCONF-ACK response that was in sctp_sf_do_asconf()
3927 * ASCONF. Note: It is possible that no cached ASCONF-ACK in sctp_sf_do_asconf()
3930 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3931 * Chunk for that chunk. in sctp_sf_do_asconf()
3933 asconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial); in sctp_sf_do_asconf()
3941 asconf_ack->transport = NULL; in sctp_sf_do_asconf()
3950 * containing the ASCONF-ACK Chunks MUST be the source address of in sctp_sf_do_asconf()
3958 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
3960 if (asoc->new_transport) { in sctp_sf_do_asconf()
3961 sctp_sf_heartbeat(ep, asoc, type, asoc->new_transport, commands); in sctp_sf_do_asconf()
3962 ((struct sctp_association *)asoc)->new_transport = NULL; in sctp_sf_do_asconf()
3978 if (list_empty(&asoc->addip_chunk_list)) in sctp_send_next_asconf()
3981 entry = asoc->addip_chunk_list.next; in sctp_send_next_asconf()
3986 asoc->addip_last_asconf = asconf; in sctp_send_next_asconf()
3992 * ADDIP Section 4.3 General rules for address manipulation
3993 * When building TLV parameters for the ASCONF Chunk that will add or
4003 struct sctp_chunk *last_asconf = asoc->addip_last_asconf; in sctp_sf_do_asconf_ack()
4022 /* ADD-IP, Section 4.1.2: in sctp_sf_do_asconf_ack()
4024 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf_ack()
4026 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf_ack()
4028 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf_ack()
4029 (!net->sctp.addip_noauth && !asconf_ack->auth)) in sctp_sf_do_asconf_ack()
4032 addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data; in sctp_sf_do_asconf_ack()
4033 rcvd_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4035 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
4041 addip_hdr = (struct sctp_addiphdr *)last_asconf->subh.addip_hdr; in sctp_sf_do_asconf_ack()
4042 sent_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4044 sent_serial = asoc->addip_serial - 1; in sctp_sf_do_asconf_ack()
4047 /* D0) If an endpoint receives an ASCONF-ACK that is greater than or in sctp_sf_do_asconf_ack()
4050 * sequence number is greater than if it is no more than 2^^31-1 in sctp_sf_do_asconf_ack()
4054 !(asoc->addip_last_asconf)) { in sctp_sf_do_asconf_ack()
4077 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { in sctp_sf_do_asconf_ack()
4110 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
4138 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4143 if (param.p->type == SCTP_PARAM_RESET_OUT_REQUEST) in sctp_sf_do_reconf()
4146 else if (param.p->type == SCTP_PARAM_RESET_IN_REQUEST) in sctp_sf_do_reconf()
4149 else if (param.p->type == SCTP_PARAM_RESET_TSN_REQUEST) in sctp_sf_do_reconf()
4152 else if (param.p->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) in sctp_sf_do_reconf()
4155 else if (param.p->type == SCTP_PARAM_RESET_ADD_IN_STREAMS) in sctp_sf_do_reconf()
4158 else if (param.p->type == SCTP_PARAM_RESET_RESPONSE) in sctp_sf_do_reconf()
4175 * PR-SCTP Section 3.6 Receiver Side Implementation of PR-SCTP
4206 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn()
4210 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn()
4214 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn()
4215 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn()
4216 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn()
4217 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn()
4218 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn()
4220 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn()
4223 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn()
4226 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn()
4229 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4233 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn()
4238 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_fwd_tsn()
4243 /* FIXME: For now send a SACK, but DATA processing may in sctp_sf_eat_fwd_tsn()
4273 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn_fast()
4277 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn_fast()
4281 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn_fast()
4282 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn_fast()
4283 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn_fast()
4284 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn_fast()
4285 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn_fast()
4287 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn_fast()
4290 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn_fast()
4293 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn_fast()
4296 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4300 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn_fast()
4308 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_fwd_tsn_fast()
4310 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_fwd_tsn_fast()
4321 * SCTP-AUTH Section 6.3 Receiving authenticated chunks
4325 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4332 * the endpoint has at least one endpoint pair shared key for the peer,
4334 * key has been configured for that Shared Key Identifier. If no
4335 * endpoint pair shared key has been configured for that Shared Key
4354 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_authenticate()
4355 chunk->subh.auth_hdr = auth_hdr; in sctp_sf_authenticate()
4356 skb_pull(chunk->skb, sizeof(*auth_hdr)); in sctp_sf_authenticate()
4361 if (!sctp_auth_asoc_verify_hmac_id(asoc, auth_hdr->hmac_id)) in sctp_sf_authenticate()
4367 key_id = ntohs(auth_hdr->shkey_id); in sctp_sf_authenticate()
4368 if (key_id != asoc->active_key_id) { in sctp_sf_authenticate()
4377 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4379 hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); in sctp_sf_authenticate()
4380 if (sig_len != hmac->hmac_len) in sctp_sf_authenticate()
4390 digest = auth_hdr->hmac; in sctp_sf_authenticate()
4391 skb_pull(chunk->skb, sig_len); in sctp_sf_authenticate()
4399 sctp_auth_calculate_hmac(asoc, chunk->skb, in sctp_sf_authenticate()
4400 (struct sctp_auth_chunk *)chunk->chunk_hdr, in sctp_sf_authenticate()
4410 chunk->auth = 1; in sctp_sf_authenticate()
4429 if (!asoc->peer.auth_capable) in sctp_sf_eat_auth()
4443 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4452 &auth_hdr->hmac_id, in sctp_sf_eat_auth()
4474 if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { in sctp_sf_eat_auth()
4477 ev = sctp_ulpevent_make_authkey(asoc, ntohs(auth_hdr->shkey_id), in sctp_sf_eat_auth()
4481 return -ENOMEM; in sctp_sf_eat_auth()
4495 * Chunk Types are encoded such that the highest-order two bits specify
4499 * 00 - Stop processing this SCTP packet and discard it, do not process
4502 * 01 - Stop processing this SCTP packet and discard it, do not process
4506 * 10 - Skip this chunk and continue processing.
4508 * 11 - Skip this chunk and continue processing, but report in an ERROR
4543 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4546 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4561 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4564 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4699 /* SCTP-AUTH, Section 6.3: in sctp_sf_abort_violation()
4719 /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ in sctp_sf_abort_violation()
4720 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4721 !asoc->peer.i.init_tag) { in sctp_sf_abort_violation()
4724 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4726 abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T; in sctp_sf_abort_violation()
4730 inittag = ntohl(initack->init_hdr.init_tag); in sctp_sf_abort_violation()
4739 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { in sctp_sf_abort_violation()
4760 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4762 abort->skb->sk = ep->base.sk; in sctp_sf_abort_violation()
4787 * given chunk can be. For example, a SACK chunk has invalid length
4861 * cumulative tsn ack to a point beyond the max tsn currently sent.
4874 static const char err_str[] = "The cumulative tsn ack beyond the max tsn currently sent:"; in sctp_sf_violation_ctsn()
4880 /* Handle protocol violation of an invalid chunk bundling. For example,
4881 * when we have an association and we receive bundled INIT-ACK, or
4882 * SHUTDOWN-COMPLETE, our peer is clearly violating the "MUST NOT bundle"
4903 * These are the state functions for handling primitive (Section 10) events.
4908 * Section: 10.1 ULP-to-SCTP
4913 * -> association id [,destination transport addr list] [,outbound stream
4923 * [This is not relevant for the kernel implementation since we do all
4938 * the local endpoint as default primary path for sending SCTP packets
4942 * stuff happens when the INIT ACK arrives. This is a NON-BLOCKING
4947 * o local SCTP instance name - obtained from the INITIALIZE operation.
4949 * o destination transport addr - specified as one of the transport
4952 * [This is asoc->peer.active_path.]
4953 * o outbound stream count - the number of outbound streams the ULP
4972 /* The comment below says that we enter COOKIE-WAIT AFTER in sctp_sf_do_prm_asoc()
4984 * 1 to 4294967295 (see 5.3.1 for Tag value selection). ... in sctp_sf_do_prm_asoc()
4987 repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); in sctp_sf_do_prm_asoc()
4991 /* Choose transport for INIT. */ in sctp_sf_do_prm_asoc()
5001 /* After sending the INIT, "A" starts the T1-init timer and in sctp_sf_do_prm_asoc()
5002 * enters the COOKIE-WAIT state. in sctp_sf_do_prm_asoc()
5016 * Section: 10.1 ULP-to-SCTP
5021 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
5022 * -> result
5028 * o association id - local handle to the SCTP association
5030 * o buffer address - the location where the user message to be
5033 * o byte count - The size of the user data in number of bytes;
5037 * o context - an optional 32 bit integer that will be carried in the
5041 * o stream id - to indicate which stream to send the data on. If not
5044 * o life time - specifies the life time of the user data. The user data
5053 * o destination transport address - specified as one of the destination
5056 * transport address for sending the packets, instead of the current
5059 * o unorder flag - this flag, if present, indicates that the user
5064 * o no-bundle flag - instructs SCTP not to bundle this user data with
5068 * o payload protocol-id - A 32 bit unsigned integer that is to be
5094 * -> result
5105 * o association id - local handle to the SCTP association
5125 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_do_9_2_prm_shutdown()
5135 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_prm_shutdown()
5150 * -> result
5160 * o association id - local handle to the SCTP association
5164 * o cause code - reason of the abort to be passed to the peer
5215 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_ERROR, SCTP_ERROR(-EINVAL)); in sctp_sf_error_closed()
5231 SCTP_ERROR(-ESHUTDOWN)); in sctp_sf_error_shutdown()
5293 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_shutdown()
5322 /* Stop T1-init timer */ in sctp_sf_cookie_wait_prm_abort()
5370 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_abort()
5382 * state table when someone issues an abort while in SHUTDOWN-PENDING state.
5395 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_pending_prm_abort()
5409 * state table when someone issues an abort while in SHUTDOWN-SENT state.
5422 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_prm_abort()
5426 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_prm_abort()
5454 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_prm_abort()
5462 * 10.1 ULP-to-SCTP
5467 * -> result
5476 * o association id - local handle to the SCTP association
5478 * o destination transport address - the transport address of the
5496 * D) Request an on-demand HEARTBEAT on a specific destination in sctp_sf_do_prm_requestheartbeat()
5530 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5564 * These are the state functions for the OTHER events.
5598 * TSN Ack field the last sequential TSN it has received from the peer.
5599 * It shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT
5600 * state. If the timer expires, the endpoint must re-send the SHUTDOWN
5617 * in the Cumulative TSN Ack field the last sequential TSN it in sctp_sf_do_9_2_start_shutdown()
5624 /* Set the transport for the SHUTDOWN chunk and the timeout for the in sctp_sf_do_9_2_start_shutdown()
5625 * T2-shutdown timer. in sctp_sf_do_9_2_start_shutdown()
5629 /* It shall then start the T2-shutdown timer */ in sctp_sf_do_9_2_start_shutdown()
5635 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. in sctp_sf_do_9_2_start_shutdown()
5640 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_start_shutdown()
5644 /* and enter the SHUTDOWN-SENT state. */ in sctp_sf_do_9_2_start_shutdown()
5648 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_start_shutdown()
5651 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_start_shutdown()
5664 * Generate a SHUTDOWN ACK now that everything is SACK'd.
5669 * shall send a SHUTDOWN ACK and start a T2-shutdown timer of its own,
5670 * entering the SHUTDOWN-ACK-SENT state. If the timer expires, the
5671 * endpoint must re-send the SHUTDOWN ACK.
5690 * For the case (2), the arg parameter is set to NULL. We need in sctp_sf_do_9_2_shutdown_ack()
5706 * shall send a SHUTDOWN ACK ... in sctp_sf_do_9_2_shutdown_ack()
5712 /* Set the transport for the SHUTDOWN ACK chunk and the timeout for in sctp_sf_do_9_2_shutdown_ack()
5713 * the T2-shutdown timer. in sctp_sf_do_9_2_shutdown_ack()
5717 /* and start/restart a T2-shutdown timer of its own, */ in sctp_sf_do_9_2_shutdown_ack()
5721 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_shutdown_ack()
5725 /* Enter the SHUTDOWN-ACK-SENT state. */ in sctp_sf_do_9_2_shutdown_ack()
5729 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_shutdown_ack()
5732 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_shutdown_ack()
5763 * These are the state functions for handling timeout events.
5769 * Section: 6.3.3 Handle T3-rtx Expiration
5771 * Whenever the retransmission timer T3-rtx expires for a destination
5788 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_do_6_3_3_rtx()
5789 if (asoc->peer.zero_window_announced && in sctp_sf_do_6_3_3_rtx()
5790 asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { in sctp_sf_do_6_3_3_rtx()
5793 * closed for a while and we have not been able to in sctp_sf_do_6_3_3_rtx()
5814 /* E1) For the destination address for which the timer in sctp_sf_do_6_3_3_rtx()
5816 * 7.2.3 and set the cwnd <- MTU. in sctp_sf_do_6_3_3_rtx()
5819 /* E2) For the destination address for which the timer in sctp_sf_do_6_3_3_rtx()
5820 * expires, set RTO <- RTO * 2 ("back off the timer"). The in sctp_sf_do_6_3_3_rtx()
5826 * outstanding DATA chunks for the address for which the in sctp_sf_do_6_3_3_rtx()
5827 * T3-rtx has expired will fit into a single packet, subject in sctp_sf_do_6_3_3_rtx()
5828 * to the MTU constraint for the path corresponding to the in sctp_sf_do_6_3_3_rtx()
5830 * is being sent (this may be different from the address for in sctp_sf_do_6_3_3_rtx()
5835 * Note: Any DATA chunks that were sent to the address for in sctp_sf_do_6_3_3_rtx()
5836 * which the T3-rtx timer expired but did not fit in one MTU in sctp_sf_do_6_3_3_rtx()
5837 * (rule E3 above), should be marked for retransmission and in sctp_sf_do_6_3_3_rtx()
5857 * acknowledgement SHOULD be generated for at least every second packet
5860 * some situations it may be beneficial for an SCTP transmitter to be
5886 * 2) If the T1-init timer expires, the endpoint MUST retransmit INIT
5887 * and re-start the T1-init timer without changing state. This MUST
5904 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_init_timer_expire()
5912 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_init_timer_expire()
5913 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_t1_init_timer_expire()
5918 /* Choose transport for INIT. */ in sctp_sf_t1_init_timer_expire()
5930 asoc->max_init_attempts); in sctp_sf_t1_init_timer_expire()
5951 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
5952 * COOKIE ECHO and re-start the T1-cookie timer without changing
5969 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_cookie_timer_expire()
5972 pr_debug("%s: timer T1 expired (COOKIE-ECHO)\n", __func__); in sctp_sf_t1_cookie_timer_expire()
5976 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_cookie_timer_expire()
5999 /* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
6009 * the T2-Shutdown timer, giving its peer ample opportunity to transmit
6026 ((struct sctp_association *)asoc)->shutdown_retries++; in sctp_sf_t2_timer_expire()
6028 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t2_timer_expire()
6039 switch (asoc->state) { in sctp_sf_t2_timer_expire()
6060 if (asoc->shutdown_last_sent_to) in sctp_sf_t2_timer_expire()
6062 SCTP_TRANSPORT(asoc->shutdown_last_sent_to)); in sctp_sf_t2_timer_expire()
6064 /* Set the transport for the SHUTDOWN/ACK chunk and the timeout for in sctp_sf_t2_timer_expire()
6065 * the T2-shutdown timer. in sctp_sf_t2_timer_expire()
6069 /* Restart the T2-shutdown timer. */ in sctp_sf_t2_timer_expire()
6091 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire()
6092 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
6112 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t4_timer_expire()
6124 /* ADDIP 4.1 B3) Back-off the destination address RTO value to which in sctp_sf_t4_timer_expire()
6129 /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible in sctp_sf_t4_timer_expire()
6135 sctp_chunk_hold(asoc->addip_last_asconf); in sctp_sf_t4_timer_expire()
6137 SCTP_CHUNK(asoc->addip_last_asconf)); in sctp_sf_t4_timer_expire()
6139 /* ADDIP 4.1 B5) Restart the T-4 RTO timer. Note that if a different in sctp_sf_t4_timer_expire()
6149 /* sctpimpguide-05 Section 2.12.2
6151 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
6206 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_autoclose_timer_expire()
6216 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_autoclose_timer_expire()
6300 sack = (struct sctp_sackhdr *) chunk->skb->data; in sctp_sm_pull_sack()
6302 num_blocks = ntohs(sack->num_gap_ack_blocks); in sctp_sm_pull_sack()
6303 num_dup_tsns = ntohs(sack->num_dup_tsns); in sctp_sm_pull_sack()
6306 if (len > chunk->skb->len) in sctp_sm_pull_sack()
6309 skb_pull(chunk->skb, len); in sctp_sm_pull_sack()
6339 /* Reflect vtag if T-Bit is set */ in sctp_abort_pkt_new()
6341 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6348 /* Set the skb to the belonging sock for accounting. */ in sctp_abort_pkt_new()
6349 abort->skb->sk = ep->base.sk; in sctp_abort_pkt_new()
6358 /* Allocate a packet for responding in the OOTB conditions. */
6370 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6371 dport = ntohs(chunk->sctp_hdr->source); in sctp_ootb_pkt_new()
6373 /* The V-tag is going to be the same as the inbound packet if no in sctp_ootb_pkt_new()
6377 /* Special case the INIT-ACK as there is no peer's vtag in sctp_ootb_pkt_new()
6380 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6386 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6387 vtag = ntohl(initack->init_hdr.init_tag); in sctp_ootb_pkt_new()
6391 vtag = asoc->peer.i.init_tag; in sctp_ootb_pkt_new()
6398 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6403 init = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6404 vtag = ntohl(init->init_hdr.init_tag); in sctp_ootb_pkt_new()
6408 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6413 /* Make a transport for the bucket, Eliza... */ in sctp_ootb_pkt_new()
6418 transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_ootb_pkt_new()
6420 /* Cache a route for the transport with the chunk's destination as in sctp_ootb_pkt_new()
6423 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6424 sctp_sk(net->sctp.ctl_sock)); in sctp_ootb_pkt_new()
6426 packet = &transport->packet; in sctp_ootb_pkt_new()
6436 /* Free the packet allocated earlier for responding in the OOTB condition. */
6439 sctp_transport_free(packet->transport); in sctp_ootb_pkt_free()
6458 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6459 packet->vtag = cookie->c.peer_vtag; in sctp_send_stale_cookie_err()
6461 /* Set the skb to the belonging sock for accounting. */ in sctp_send_stale_cookie_err()
6462 err_chunk->skb->sk = ep->base.sk; in sctp_send_stale_cookie_err()
6478 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_eat_data()
6479 struct sock *sk = asoc->base.sk; in sctp_eat_data()
6488 data_hdr = (struct sctp_datahdr *)chunk->skb->data; in sctp_eat_data()
6489 chunk->subh.data_hdr = data_hdr; in sctp_eat_data()
6490 skb_pull(chunk->skb, sctp_datahdr_len(&asoc->stream)); in sctp_eat_data()
6492 tsn = ntohl(data_hdr->tsn); in sctp_eat_data()
6495 /* ASSERT: Now skb->data is really the user data. */ in sctp_eat_data()
6499 * Since the chunk structure is reused for all chunks within in sctp_eat_data()
6501 * done CE processing for this packet. in sctp_eat_data()
6507 if (asoc->peer.ecn_capable && !chunk->ecn_ce_done) { in sctp_eat_data()
6508 struct sctp_af *af = SCTP_INPUT_CB(chunk->skb)->af; in sctp_eat_data()
6509 chunk->ecn_ce_done = 1; in sctp_eat_data()
6511 if (af->is_ce(sctp_gso_headskb(chunk->skb))) { in sctp_eat_data()
6518 tmp = sctp_tsnmap_check(&asoc->peer.tsn_map, tsn); in sctp_eat_data()
6520 /* The TSN is too high--silently discard the chunk and in sctp_eat_data()
6523 if (chunk->asoc) in sctp_eat_data()
6524 chunk->asoc->stats.outofseqtsns++; in sctp_eat_data()
6537 datalen = ntohs(chunk->chunk_hdr->length); in sctp_eat_data()
6538 datalen -= sctp_datachk_len(&asoc->stream); in sctp_eat_data()
6543 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) { in sctp_eat_data()
6556 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6557 (datalen > asoc->rwnd + asoc->frag_point))) { in sctp_eat_data()
6567 pr_debug("%s: reneging for tsn:%u\n", __func__, tsn); in sctp_eat_data()
6571 __func__, tsn, datalen, asoc->rwnd); in sctp_eat_data()
6587 pr_debug("%s: under pressure, reneging for tsn:%u\n", in sctp_eat_data()
6599 * --------------- in sctp_eat_data()
6622 chunk->data_accepted = 1; in sctp_eat_data()
6627 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_eat_data()
6629 if (chunk->asoc) in sctp_eat_data()
6630 chunk->asoc->stats.iuodchunks++; in sctp_eat_data()
6633 if (chunk->asoc) in sctp_eat_data()
6634 chunk->asoc->stats.iodchunks++; in sctp_eat_data()
6645 if (ntohs(data_hdr->stream) >= asoc->stream.incnt) { in sctp_eat_data()
6650 &data_hdr->stream, in sctp_eat_data()
6651 sizeof(data_hdr->stream), in sctp_eat_data()
6659 /* Check to see if the SSN is possible for this TSN. in sctp_eat_data()
6662 * wrap and for a valid TSN. We can simply check if the current in sctp_eat_data()
6666 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()