Lines Matching +full:ep +full:- +full:side

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>
54 const struct sctp_endpoint *ep,
66 const struct sctp_endpoint *ep,
73 const struct sctp_endpoint *ep,
80 const struct sctp_endpoint *ep,
87 const struct sctp_endpoint *ep,
94 const struct sctp_endpoint *ep,
110 const struct sctp_endpoint *ep,
119 const struct sctp_endpoint *ep,
127 const struct sctp_endpoint *ep,
135 const struct sctp_endpoint *ep,
143 const struct sctp_endpoint *ep,
155 const struct sctp_endpoint *ep,
162 __sctp_sf_do_9_2_reshutack(struct net *net, const struct sctp_endpoint *ep,
177 __u16 chunk_length = ntohs(chunk->chunk_hdr->length); in sctp_chunk_length_valid()
180 if (unlikely(chunk->pdiscard)) in sctp_chunk_length_valid()
193 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_err_chunk_valid()
195 return (void *)err == (void *)chunk->chunk_end; in sctp_err_chunk_valid()
207 * that it is in SHUTDOWN-ACK-SENT state, if it is not the chunk should be
208 * discarded. If the endpoint is in the SHUTDOWN-ACK-SENT state the endpoint
209 * should stop the T2-shutdown timer and remove all knowledge of the
215 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
223 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
234 const struct sctp_endpoint *ep, in sctp_sf_do_4_C() argument
243 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_4_C()
250 if (!chunk->singleton) in sctp_sf_do_4_C()
251 return sctp_sf_violation_chunk(net, ep, asoc, type, arg, commands); in sctp_sf_do_4_C()
255 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_4_C()
258 /* RFC 2960 10.2 SCTP-to-ULP in sctp_sf_do_4_C()
272 * will verify that it is in SHUTDOWN-ACK-SENT state, if it is in sctp_sf_do_4_C()
274 * the SHUTDOWN-ACK-SENT state the endpoint should stop the in sctp_sf_do_4_C()
275 * T2-shutdown timer and remove all knowledge of the in sctp_sf_do_4_C()
298 * We are the side that is being asked for an association.
319 const struct sctp_endpoint *ep, in sctp_sf_do_5_1B_init() argument
340 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
341 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1B_init()
349 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1B_init()
354 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1B_init()
356 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1B_init()
362 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
363 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1B_init()
371 if (sctp_sstate(ep->base.sk, CLOSING)) in sctp_sf_do_5_1B_init()
372 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1B_init()
376 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1B_init()
377 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1B_init()
383 packet = sctp_abort_pkt_new(net, ep, asoc, arg, in sctp_sf_do_5_1B_init()
384 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
386 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
400 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, in sctp_sf_do_5_1B_init()
406 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1B_init()
409 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1B_init()
411 new_asoc = sctp_make_temp_asoc(ep, chunk, GFP_ATOMIC); in sctp_sf_do_5_1B_init()
416 if (security_sctp_assoc_request(new_asoc, chunk->skb)) { in sctp_sf_do_5_1B_init()
418 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1B_init()
428 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
439 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1B_init()
459 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1B_init()
492 * We are the side that is initiating the association.
495 * C) Upon reception of the INIT ACK from "Z", "A" shall stop the T1-init
496 * timer and leave COOKIE-WAIT state. "A" shall then send the State
498 * the T1-cookie timer, and enter the COOKIE-ECHOED state.
519 const struct sctp_endpoint *ep, in sctp_sf_do_5_1C_ack() argument
531 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1C_ack()
537 if (!chunk->singleton) in sctp_sf_do_5_1C_ack()
538 return sctp_sf_violation_chunk(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1C_ack()
540 /* Make sure that the INIT-ACK chunk has a valid length */ in sctp_sf_do_5_1C_ack()
542 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_5_1C_ack()
545 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_5_1C_ack()
549 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_5_1C_ack()
550 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_5_1C_ack()
561 packet = sctp_abort_pkt_new(net, ep, asoc, arg, in sctp_sf_do_5_1C_ack()
562 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_5_1C_ack()
564 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_5_1C_ack()
577 /* SCTP-AUTH, Section 6.3: in sctp_sf_do_5_1C_ack()
589 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1C_ack()
593 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
599 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_5_1C_ack()
601 initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_sf_do_5_1C_ack()
606 /* Reset init error count upon receipt of INIT-ACK. */ in sctp_sf_do_5_1C_ack()
609 /* 5.1 C) "A" shall stop the T1-init timer and leave in sctp_sf_do_5_1C_ack()
610 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie in sctp_sf_do_5_1C_ack()
611 * timer, and enter the COOKIE-ECHOED state. in sctp_sf_do_5_1C_ack()
620 /* SCTP-AUTH: generate the association shared keys so that in sctp_sf_do_5_1C_ack()
621 * we can potentially sign the COOKIE-ECHO. in sctp_sf_do_5_1C_ack()
642 if (!chunk->auth_chunk) in sctp_auth_chunk_verify()
645 /* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo in sctp_auth_chunk_verify()
653 if (!net->sctp.auth_enable || !asoc->peer.auth_capable) in sctp_auth_chunk_verify()
656 /* set-up our fake chunk so that we can process it */ in sctp_auth_chunk_verify()
657 auth.skb = chunk->auth_chunk; in sctp_auth_chunk_verify()
658 auth.asoc = chunk->asoc; in sctp_auth_chunk_verify()
659 auth.sctp_hdr = chunk->sctp_hdr; in sctp_auth_chunk_verify()
661 skb_push(chunk->auth_chunk, in sctp_auth_chunk_verify()
663 skb_pull(chunk->auth_chunk, sizeof(struct sctp_chunkhdr)); in sctp_auth_chunk_verify()
664 auth.transport = chunk->transport; in sctp_auth_chunk_verify()
671 * We are the side that is being asked for an association.
687 * - When sending a COOKIE ECHO, the endpoint MUST use the value of the
690 * - The receiver of a COOKIE ECHO follows the procedures in Section 5.
701 const struct sctp_endpoint *ep, in sctp_sf_do_5_1D_ce() argument
717 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
722 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { in sctp_sf_do_5_1D_ce()
724 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
733 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_5_1D_ce()
737 * on the TCP-style socket exceed the max backlog, respond with an in sctp_sf_do_5_1D_ce()
740 sk = ep->base.sk; in sctp_sf_do_5_1D_ce()
743 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
748 chunk->subh.cookie_hdr = in sctp_sf_do_5_1D_ce()
749 (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_1D_ce()
750 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_1D_ce()
758 new_asoc = sctp_unpack_cookie(ep, asoc, chunk, GFP_ATOMIC, &error, in sctp_sf_do_5_1D_ce()
762 * If the re-build failed, what is the proper error path in sctp_sf_do_5_1D_ce()
765 * [We should abort the association. --piggy] in sctp_sf_do_5_1D_ce()
772 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_1D_ce()
775 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_1D_ce()
776 sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, in sctp_sf_do_5_1D_ce()
778 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
780 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_1D_ce()
782 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
786 if (security_sctp_assoc_request(new_asoc, chunk->head_skb ?: chunk->skb)) { in sctp_sf_do_5_1D_ce()
788 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
793 * Re-build the bind address for the association is done in in sctp_sf_do_5_1D_ce()
796 /* This is a brand-new association, so these are not yet side in sctp_sf_do_5_1D_ce()
797 * effects--it is safe to run them here. in sctp_sf_do_5_1D_ce()
799 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_5_1D_ce()
801 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
805 /* SCTP-AUTH: Now that we've populate required fields in in sctp_sf_do_5_1D_ce()
815 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1D_ce()
829 new_asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1D_ce()
830 new_asoc->c.sinit_max_instreams, in sctp_sf_do_5_1D_ce()
840 if (new_asoc->peer.adaptation_ind) { in sctp_sf_do_5_1D_ce()
847 if (!new_asoc->peer.auth_capable) { in sctp_sf_do_5_1D_ce()
857 * during side-effect processing and correctly count established in sctp_sf_do_5_1D_ce()
867 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1D_ce()
903 * We are the side that is asking for an association.
908 * COOKIE-ECHOED state to the ESTABLISHED state, stopping the T1-cookie
923 const struct sctp_endpoint *ep, in sctp_sf_do_5_1E_ca() argument
933 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1E_ca()
937 chunk->head_skb ?: chunk->skb)) in sctp_sf_do_5_1E_ca()
938 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_1E_ca()
940 /* Verify that the chunk length for the COOKIE-ACK is OK. in sctp_sf_do_5_1E_ca()
944 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_5_1E_ca()
947 /* Reset init error count upon receipt of COOKIE-ACK, in sctp_sf_do_5_1E_ca()
950 * from the COOKIE-ECHOED state to the COOKIE-WAIT in sctp_sf_do_5_1E_ca()
958 * from the COOKIE-ECHOED state to the ESTABLISHED state, in sctp_sf_do_5_1E_ca()
959 * stopping the T1-cookie timer. in sctp_sf_do_5_1E_ca()
968 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_5_1E_ca()
977 0, asoc->c.sinit_num_ostreams, in sctp_sf_do_5_1E_ca()
978 asoc->c.sinit_max_instreams, in sctp_sf_do_5_1E_ca()
991 if (asoc->peer.adaptation_ind) { in sctp_sf_do_5_1E_ca()
1000 if (!asoc->peer.auth_capable) { in sctp_sf_do_5_1E_ca()
1016 const struct sctp_endpoint *ep, in sctp_sf_heartbeat() argument
1042 const struct sctp_endpoint *ep, in sctp_sf_sendbeat_8_3() argument
1050 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_sendbeat_8_3()
1062 * The Sender-specific Heartbeat Info field should normally include in sctp_sf_sendbeat_8_3()
1068 if (transport->param_flags & SPP_HB_ENABLE) { in sctp_sf_sendbeat_8_3()
1070 sctp_sf_heartbeat(ep, asoc, type, arg, in sctp_sf_sendbeat_8_3()
1090 const struct sctp_endpoint *ep, in sctp_sf_send_reconf() argument
1098 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_send_reconf()
1109 sctp_chunk_hold(asoc->strreset_chunk); in sctp_sf_send_reconf()
1111 SCTP_CHUNK(asoc->strreset_chunk)); in sctp_sf_send_reconf()
1119 const struct sctp_endpoint *ep, in sctp_sf_send_probe() argument
1132 reply = sctp_make_heartbeat(asoc, transport, transport->pl.probe_size); in sctp_sf_send_probe()
1167 const struct sctp_endpoint *ep, in sctp_sf_beat_8_3() argument
1178 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_beat_8_3()
1183 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_beat_8_3()
1190 chunk->subh.hb_hdr = (struct sctp_heartbeathdr *)chunk->skb->data; in sctp_sf_beat_8_3()
1191 param_hdr = (struct sctp_paramhdr *)chunk->subh.hb_hdr; in sctp_sf_beat_8_3()
1192 paylen = ntohs(chunk->chunk_hdr->length) - sizeof(struct sctp_chunkhdr); in sctp_sf_beat_8_3()
1194 if (ntohs(param_hdr->length) > paylen) in sctp_sf_beat_8_3()
1195 return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, in sctp_sf_beat_8_3()
1198 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1241 const struct sctp_endpoint *ep, in sctp_sf_backbeat_8_3() argument
1254 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_backbeat_8_3()
1256 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1259 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_backbeat_8_3()
1262 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1264 if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo)) in sctp_sf_backbeat_8_3()
1267 from_addr = hbinfo->daddr; in sctp_sf_backbeat_8_3()
1286 /* Validate the 64-bit random nonce. */ in sctp_sf_backbeat_8_3()
1287 if (hbinfo->hb_nonce != link->hb_nonce) in sctp_sf_backbeat_8_3()
1290 if (hbinfo->probe_size) { in sctp_sf_backbeat_8_3()
1291 if (hbinfo->probe_size != link->pl.probe_size || in sctp_sf_backbeat_8_3()
1298 return sctp_sf_send_probe(net, ep, asoc, type, link, commands); in sctp_sf_backbeat_8_3()
1301 max_interval = link->hbinterval + link->rto; in sctp_sf_backbeat_8_3()
1304 if (time_after(hbinfo->sent_at, jiffies) || in sctp_sf_backbeat_8_3()
1305 time_after(jiffies, hbinfo->sent_at + max_interval)) { in sctp_sf_backbeat_8_3()
1330 struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); in sctp_sf_send_restart_abort()
1334 struct sctp_endpoint *ep; in sctp_sf_send_restart_abort() local
1345 len = af->to_addr_param(ssa, addrparm); in sctp_sf_send_restart_abort()
1348 errhdr->cause = SCTP_ERROR_RESTART; in sctp_sf_send_restart_abort()
1349 errhdr->length = htons(len); in sctp_sf_send_restart_abort()
1352 ep = sctp_sk(net->sctp.ctl_sock)->ep; in sctp_sf_send_restart_abort()
1357 pkt = sctp_abort_pkt_new(net, ep, NULL, init, errhdr, len); in sctp_sf_send_restart_abort()
1381 if (sctp_cmp_addr_exact(ipaddr, &addr->ipaddr)) in list_has_sctp_addr()
1395 struct net *net = new_asoc->base.net; in sctp_sf_check_restart_addrs()
1399 /* Implementor's Guide - Section 5.2.2 in sctp_sf_check_restart_addrs()
1410 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1412 if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, in sctp_sf_check_restart_addrs()
1413 &new_addr->ipaddr)) { in sctp_sf_check_restart_addrs()
1414 sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, in sctp_sf_check_restart_addrs()
1428 * Note: Do not use in CLOSED or SHUTDOWN-ACK-SENT state.
1433 switch (asoc->state) { in sctp_tietags_populate()
1435 /* 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State */ in sctp_tietags_populate()
1438 new_asoc->c.my_vtag = asoc->c.my_vtag; in sctp_tietags_populate()
1439 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1440 new_asoc->c.peer_ttag = 0; in sctp_tietags_populate()
1444 new_asoc->c.my_vtag = asoc->c.my_vtag; 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()
1449 /* 5.2.2 Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, in sctp_tietags_populate()
1450 * COOKIE-WAIT and SHUTDOWN-ACK-SENT in sctp_tietags_populate()
1453 new_asoc->c.my_ttag = asoc->c.my_vtag; in sctp_tietags_populate()
1454 new_asoc->c.peer_ttag = asoc->c.peer_vtag; in sctp_tietags_populate()
1462 new_asoc->rwnd = asoc->rwnd; in sctp_tietags_populate()
1463 new_asoc->c.sinit_num_ostreams = asoc->c.sinit_num_ostreams; in sctp_tietags_populate()
1464 new_asoc->c.sinit_max_instreams = asoc->c.sinit_max_instreams; in sctp_tietags_populate()
1465 new_asoc->c.initial_tsn = asoc->c.initial_tsn; in sctp_tietags_populate()
1469 * Compare vtag/tietag values to determine unexpected COOKIE-ECHO
1481 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1482 (asoc->c.peer_vtag != new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1483 (asoc->c.my_vtag == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1484 (asoc->c.peer_vtag == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1488 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1489 ((asoc->c.peer_vtag != new_asoc->c.peer_vtag) || in sctp_tietags_compare()
1490 (0 == asoc->c.peer_vtag))) { in sctp_tietags_compare()
1495 if ((asoc->c.my_vtag == new_asoc->c.my_vtag) && in sctp_tietags_compare()
1496 (asoc->c.peer_vtag == new_asoc->c.peer_vtag)) in sctp_tietags_compare()
1500 if ((asoc->c.my_vtag != new_asoc->c.my_vtag) && in sctp_tietags_compare()
1501 (asoc->c.peer_vtag == new_asoc->c.peer_vtag) && in sctp_tietags_compare()
1502 (0 == new_asoc->c.my_ttag) && in sctp_tietags_compare()
1503 (0 == new_asoc->c.peer_ttag)) in sctp_tietags_compare()
1515 const struct sctp_endpoint *ep, in sctp_sf_do_unexpected_init() argument
1537 if (!chunk->singleton) in sctp_sf_do_unexpected_init()
1538 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_unexpected_init()
1542 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_unexpected_init()
1547 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_unexpected_init()
1548 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_unexpected_init()
1550 if (SCTP_INPUT_CB(chunk->skb)->encap_port != chunk->transport->encap_port) in sctp_sf_do_unexpected_init()
1551 return sctp_sf_new_encap_port(net, ep, asoc, type, arg, commands); in sctp_sf_do_unexpected_init()
1554 chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data; in sctp_sf_do_unexpected_init()
1557 chunk->param_hdr.v = skb_pull(chunk->skb, sizeof(struct sctp_inithdr)); in sctp_sf_do_unexpected_init()
1561 if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type, in sctp_sf_do_unexpected_init()
1562 (struct sctp_init_chunk *)chunk->chunk_hdr, chunk, in sctp_sf_do_unexpected_init()
1568 packet = sctp_abort_pkt_new(net, ep, asoc, arg, in sctp_sf_do_unexpected_init()
1569 (__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1571 ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1584 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, in sctp_sf_do_unexpected_init()
1596 new_asoc = sctp_make_temp_asoc(ep, chunk, GFP_ATOMIC); in sctp_sf_do_unexpected_init()
1601 if (security_sctp_assoc_request(new_asoc, chunk->skb)) { in sctp_sf_do_unexpected_init()
1603 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_unexpected_init()
1612 * place (local tie-tag and per tie-tag) within the state cookie. in sctp_sf_do_unexpected_init()
1615 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1620 * restart. Do not do this check for COOKIE-WAIT state, in sctp_sf_do_unexpected_init()
1641 len = ntohs(err_chunk->chunk_hdr->length) - in sctp_sf_do_unexpected_init()
1662 ((__u8 *)(err_chunk->chunk_hdr) + in sctp_sf_do_unexpected_init()
1699 * Section: 5.2.1 INIT received in COOKIE-WAIT or COOKIE-ECHOED State (Item B)
1704 * Upon receipt of an INIT in the COOKIE-WAIT or COOKIE-ECHOED state, an
1712 * After that, the endpoint MUST NOT change its state, the T1-init
1717 * For an endpoint that is in the COOKIE-ECHOED state it MUST populate
1718 * its Tie-Tags with the Tag information of itself and its peer (see
1719 * section 5.2.2 for a description of the Tie-Tags).
1734 const struct sctp_endpoint *ep, in sctp_sf_do_5_2_1_siminit() argument
1743 return sctp_sf_do_unexpected_init(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_1_siminit()
1751 * COOKIE-ECHOED and COOKIE-WAIT
1758 * the Peer's-Tie-Tag and the Local-Tie-Tag. The outbound SCTP packet
1770 * Note: Only when a TCB exists and the association is not in a COOKIE-
1771 * WAIT state are the Tie-Tags populated. For a normal association INIT
1772 * (i.e. the endpoint is in a COOKIE-WAIT state), the Tie-Tags MUST be
1789 const struct sctp_endpoint *ep, in sctp_sf_do_5_2_2_dupinit() argument
1798 return sctp_sf_do_unexpected_init(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_2_dupinit()
1803 * Unexpected INIT-ACK handler.
1807 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1813 const struct sctp_endpoint *ep, in sctp_sf_do_5_2_3_initack() argument
1820 * endpoint. If this is an OOTB INIT-ACK, treat it as such. in sctp_sf_do_5_2_3_initack()
1822 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) in sctp_sf_do_5_2_3_initack()
1823 return sctp_sf_ootb(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_3_initack()
1825 return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_3_initack()
1832 struct net *net = asoc->base.net; in sctp_sf_do_assoc_update()
1849 return -ENOMEM; in sctp_sf_do_assoc_update()
1852 /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A')
1859 const struct sctp_endpoint *ep, in sctp_sf_do_dupcook_a() argument
1871 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_a()
1872 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_a()
1874 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_a()
1892 /* If the endpoint is in the SHUTDOWN-ACK-SENT state and recognizes in sctp_sf_do_dupcook_a()
1899 disposition = __sctp_sf_do_9_2_reshutack(net, ep, asoc, in sctp_sf_do_dupcook_a()
1900 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1915 /* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked in sctp_sf_do_dupcook_a()
1923 /* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue in sctp_sf_do_dupcook_a()
1924 * and ASCONF-ACK cache. in sctp_sf_do_dupcook_a()
1940 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_a()
1941 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_a()
1949 (sctp_sstate(asoc->base.sk, CLOSING) || in sctp_sf_do_dupcook_a()
1950 sock_flag(asoc->base.sk, SOCK_DEAD))) { in sctp_sf_do_dupcook_a()
1956 return sctp_sf_do_9_2_start_shutdown(net, ep, asoc, in sctp_sf_do_dupcook_a()
1972 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'B')
1982 const struct sctp_endpoint *ep, in sctp_sf_do_dupcook_b() argument
1991 /* new_asoc is a brand-new association, so these are not yet in sctp_sf_do_dupcook_b()
1992 * side effects--it is safe to run them here. in sctp_sf_do_dupcook_b()
1994 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_b()
2007 if (asoc->state < SCTP_STATE_ESTABLISHED) in sctp_sf_do_dupcook_b()
2027 * Sadly, this needs to be implemented as a side-effect, because in sctp_sf_do_dupcook_b()
2040 * This also needs to be done as a side effect for the same reason as in sctp_sf_do_dupcook_b()
2043 if (asoc->peer.adaptation_ind) in sctp_sf_do_dupcook_b()
2046 if (!asoc->peer.auth_capable) in sctp_sf_do_dupcook_b()
2055 /* Unexpected COOKIE-ECHO handler for setup collision (Table 2, action 'C')
2060 * INIT-ACK and finally sent a COOKIE ECHO with the peer's same tag
2066 const struct sctp_endpoint *ep, in sctp_sf_do_dupcook_c() argument
2079 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2089 const struct sctp_endpoint *ep, in sctp_sf_do_dupcook_d() argument
2100 * enter the ESTABLISHED state, if it is in the COOKIE-ECHOED state. in sctp_sf_do_dupcook_d()
2109 if (asoc->state < SCTP_STATE_ESTABLISHED) { in sctp_sf_do_dupcook_d()
2127 asoc->c.sinit_num_ostreams, in sctp_sf_do_dupcook_d()
2128 asoc->c.sinit_max_instreams, in sctp_sf_do_dupcook_d()
2138 if (asoc->peer.adaptation_ind) { in sctp_sf_do_dupcook_d()
2146 if (!asoc->peer.auth_capable) { in sctp_sf_do_dupcook_d()
2184 * Handle a duplicate COOKIE-ECHO. This usually means a cookie-carrying
2201 const struct sctp_endpoint *ep, in sctp_sf_do_5_2_4_dupcook() argument
2222 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_4_dupcook()
2228 chunk->subh.cookie_hdr = (struct sctp_signed_cookie *)chunk->skb->data; in sctp_sf_do_5_2_4_dupcook()
2229 if (!pskb_pull(chunk->skb, ntohs(chunk->chunk_hdr->length) - in sctp_sf_do_5_2_4_dupcook()
2238 new_asoc = sctp_unpack_cookie(ep, asoc, chunk, GFP_ATOMIC, &error, in sctp_sf_do_5_2_4_dupcook()
2242 * If the re-build failed, what is the proper error path in sctp_sf_do_5_2_4_dupcook()
2245 * [We should abort the association. --piggy] in sctp_sf_do_5_2_4_dupcook()
2252 case -SCTP_IERROR_NOMEM: in sctp_sf_do_5_2_4_dupcook()
2255 case -SCTP_IERROR_STALE_COOKIE: in sctp_sf_do_5_2_4_dupcook()
2256 sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, in sctp_sf_do_5_2_4_dupcook()
2258 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_4_dupcook()
2259 case -SCTP_IERROR_BAD_SIG: in sctp_sf_do_5_2_4_dupcook()
2261 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_4_dupcook()
2266 new_asoc->temp = 1; in sctp_sf_do_5_2_4_dupcook()
2282 chunk->head_skb ?: chunk->skb)) { in sctp_sf_do_5_2_4_dupcook()
2284 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_4_dupcook()
2291 retval = sctp_sf_do_dupcook_a(net, ep, asoc, chunk, commands, in sctp_sf_do_5_2_4_dupcook()
2296 retval = sctp_sf_do_dupcook_b(net, ep, asoc, chunk, commands, in sctp_sf_do_5_2_4_dupcook()
2301 retval = sctp_sf_do_dupcook_c(net, ep, asoc, chunk, commands, in sctp_sf_do_5_2_4_dupcook()
2306 retval = sctp_sf_do_dupcook_d(net, ep, asoc, chunk, commands, in sctp_sf_do_5_2_4_dupcook()
2311 retval = sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_5_2_4_dupcook()
2332 * Process an ABORT. (SHUTDOWN-PENDING state)
2338 const struct sctp_endpoint *ep, in sctp_sf_shutdown_pending_abort() argument
2347 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_pending_abort()
2360 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_pending_abort()
2362 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_pending_abort()
2368 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2369 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_pending_abort()
2372 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_pending_abort()
2374 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_pending_abort()
2378 * Process an ABORT. (SHUTDOWN-SENT state)
2384 const struct sctp_endpoint *ep, in sctp_sf_shutdown_sent_abort() argument
2393 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_sent_abort()
2406 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_sent_abort()
2408 /* ADD-IP: Special case for ABORT chunks in sctp_sf_shutdown_sent_abort()
2414 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2415 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_sent_abort()
2418 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_sent_abort()
2420 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_abort()
2424 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_abort()
2428 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_sent_abort()
2432 * Process an ABORT. (SHUTDOWN-ACK-SENT state)
2438 const struct sctp_endpoint *ep, in sctp_sf_shutdown_ack_sent_abort() argument
2445 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_abort()
2447 return sctp_sf_shutdown_sent_abort(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_ack_sent_abort()
2466 const struct sctp_endpoint *ep, in sctp_sf_cookie_echoed_err() argument
2476 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_echoed_err()
2482 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_cookie_echoed_err()
2486 /* FUTURE FIXME: When PR-SCTP related and other optional in sctp_sf_cookie_echoed_err()
2490 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2491 if (SCTP_ERROR_STALE_COOKIE == err->cause) in sctp_sf_cookie_echoed_err()
2492 return sctp_sf_do_5_2_6_stale(net, ep, asoc, type, in sctp_sf_cookie_echoed_err()
2501 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_echoed_err()
2508 * If the association is in the COOKIE-ECHOED state, the endpoint may elect
2531 const struct sctp_endpoint *ep, in sctp_sf_do_5_2_6_stale() argument
2537 int attempts = asoc->init_err_counter + 1; in sctp_sf_do_5_2_6_stale()
2544 if (attempts > asoc->max_init_attempts) { in sctp_sf_do_5_2_6_stale()
2552 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2561 * Suggested Cookie Life-span Increment's unit is msec. in sctp_sf_do_5_2_6_stale()
2576 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_do_5_2_6_stale()
2586 /* Stop pending T3-rtx and heartbeat timers */ in sctp_sf_do_5_2_6_stale()
2590 /* Delete non-primary peer ip addresses since we are transitioning in sctp_sf_do_5_2_6_stale()
2591 * back to the COOKIE-WAIT state in sctp_sf_do_5_2_6_stale()
2595 /* If we've sent any data bundled with COOKIE-ECHO we will need to in sctp_sf_do_5_2_6_stale()
2599 SCTP_TRANSPORT(asoc->peer.primary_path)); in sctp_sf_do_5_2_6_stale()
2632 * - The endpoint shall always fill in the Verification Tag field of the
2636 * - If the ABORT is sent in response to an OOTB packet, the endpoint
2639 * - The receiver MUST accept the packet if the Verification Tag
2654 const struct sctp_endpoint *ep, in sctp_sf_do_9_1_abort() argument
2663 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_1_abort()
2676 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_1_abort()
2678 /* ADD-IP: Special case for ABORT chunks in sctp_sf_do_9_1_abort()
2684 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_do_9_1_abort()
2685 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_1_abort()
2688 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_1_abort()
2690 return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_1_abort()
2695 const struct sctp_endpoint *ep, in __sctp_sf_do_9_1_abort() argument
2706 len = ntohs(chunk->chunk_hdr->length); in __sctp_sf_do_9_1_abort()
2708 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in __sctp_sf_do_9_1_abort()
2720 * Process an ABORT. (COOKIE-WAIT state)
2726 const struct sctp_endpoint *ep, in sctp_sf_cookie_wait_abort() argument
2737 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_wait_abort()
2750 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_wait_abort()
2753 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_cookie_wait_abort()
2755 error = ((struct sctp_errhdr *)chunk->skb->data)->cause; in sctp_sf_cookie_wait_abort()
2758 chunk->transport); in sctp_sf_cookie_wait_abort()
2762 * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state)
2766 const struct sctp_endpoint *ep, in sctp_sf_cookie_wait_icmp_abort() argument
2778 * Process an ABORT. (COOKIE-ECHOED state)
2782 const struct sctp_endpoint *ep, in sctp_sf_cookie_echoed_abort() argument
2789 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_abort()
2791 return sctp_sf_cookie_wait_abort(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_echoed_abort()
2826 * - enter the SHUTDOWN-RECEIVED state,
2828 * - stop accepting new data from its SCTP user
2830 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2834 * Once an endpoint as reached the SHUTDOWN-RECEIVED state it MUST NOT
2856 const struct sctp_endpoint *ep, in sctp_sf_do_9_2_shutdown() argument
2869 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_shutdown()
2873 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_9_2_shutdown()
2877 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shutdown()
2878 skb_pull(chunk->skb, sizeof(*sdh)); in sctp_sf_do_9_2_shutdown()
2879 chunk->subh.shutdown_hdr = sdh; in sctp_sf_do_9_2_shutdown()
2880 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shutdown()
2882 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shutdown()
2884 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shutdown()
2893 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shutdown()
2894 return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_shutdown()
2908 * - enter the SHUTDOWN-RECEIVED state, in sctp_sf_do_9_2_shutdown()
2909 * - stop accepting new data from its SCTP user in sctp_sf_do_9_2_shutdown()
2917 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_shutdown()
2918 disposition = sctp_sf_do_9_2_shutdown_ack(net, ep, asoc, type, in sctp_sf_do_9_2_shutdown()
2925 /* - verify, by checking the Cumulative TSN Ack field of the in sctp_sf_do_9_2_shutdown()
2930 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2939 * Once an endpoint has reached the SHUTDOWN-RECEIVED state,
2946 const struct sctp_endpoint *ep, in sctp_sf_do_9_2_shut_ctsn() argument
2957 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_shut_ctsn()
2961 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_9_2_shut_ctsn()
2964 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2965 ctsn = ntohl(sdh->cum_tsn_ack); in sctp_sf_do_9_2_shut_ctsn()
2967 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_do_9_2_shut_ctsn()
2969 asoc->ctsn_ack_point); in sctp_sf_do_9_2_shut_ctsn()
2978 if (!TSN_lt(ctsn, asoc->next_tsn)) in sctp_sf_do_9_2_shut_ctsn()
2979 return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_shut_ctsn()
2986 SCTP_BE32(sdh->cum_tsn_ack)); in sctp_sf_do_9_2_shut_ctsn()
2992 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
2999 __sctp_sf_do_9_2_reshutack(struct net *net, const struct sctp_endpoint *ep, in __sctp_sf_do_9_2_reshutack() argument
3009 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in __sctp_sf_do_9_2_reshutack()
3021 * the T2-SHUTDOWN timer. in __sctp_sf_do_9_2_reshutack()
3025 /* and restart the T2-shutdown timer. */ in __sctp_sf_do_9_2_reshutack()
3037 sctp_sf_do_9_2_reshutack(struct net *net, const struct sctp_endpoint *ep, in sctp_sf_do_9_2_reshutack() argument
3044 if (!chunk->singleton) in sctp_sf_do_9_2_reshutack()
3045 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_reshutack()
3048 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_reshutack()
3050 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_9_2_reshutack()
3051 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_reshutack()
3053 return __sctp_sf_do_9_2_reshutack(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_reshutack()
3082 const struct sctp_endpoint *ep, in sctp_sf_do_ecn_cwr() argument
3093 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_ecn_cwr()
3096 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_ecn_cwr()
3099 cwr = (struct sctp_cwrhdr *)chunk->skb->data; in sctp_sf_do_ecn_cwr()
3100 skb_pull(chunk->skb, sizeof(*cwr)); in sctp_sf_do_ecn_cwr()
3102 lowest_tsn = ntohl(cwr->lowest_tsn); in sctp_sf_do_ecn_cwr()
3105 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) { in sctp_sf_do_ecn_cwr()
3119 * ECN-Echo
3138 const struct sctp_endpoint *ep, in sctp_sf_do_ecne() argument
3147 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_ecne()
3150 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_ecne()
3153 ecne = (struct sctp_ecnehdr *)chunk->skb->data; in sctp_sf_do_ecne()
3154 skb_pull(chunk->skb, sizeof(*ecne)); in sctp_sf_do_ecne()
3158 SCTP_U32(ntohl(ecne->lowest_tsn))); in sctp_sf_do_ecne()
3194 const struct sctp_endpoint *ep, in sctp_sf_eat_data_6_2() argument
3207 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_data_6_2()
3210 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_6_2()
3211 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_data_6_2()
3229 return sctp_sf_abort_violation(net, ep, asoc, chunk, commands, in sctp_sf_eat_data_6_2()
3230 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_6_2()
3231 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_6_2()
3236 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3239 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_data_6_2()
3266 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3286 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3291 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3301 * (4) In SHUTDOWN-SENT state the endpoint MUST acknowledge any received
3315 const struct sctp_endpoint *ep, in sctp_sf_eat_data_fast_4_4() argument
3327 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_data_fast_4_4()
3330 if (!sctp_chunk_length_valid(chunk, sctp_datachk_len(&asoc->stream))) in sctp_sf_eat_data_fast_4_4()
3331 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_data_fast_4_4()
3345 return sctp_sf_abort_violation(net, ep, asoc, chunk, commands, in sctp_sf_eat_data_fast_4_4()
3346 (u8 *)chunk->subh.data_hdr, in sctp_sf_eat_data_fast_4_4()
3347 sctp_datahdr_len(&asoc->stream)); in sctp_sf_eat_data_fast_4_4()
3356 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_data_fast_4_4()
3358 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_data_fast_4_4()
3360 if (chunk->end_of_packet) { in sctp_sf_eat_data_fast_4_4()
3380 * Cumulative TSN Ack Point indicates an out-of-order SACK.
3392 * chunk was originally transmitted, then T3-rtx is started for
3406 const struct sctp_endpoint *ep, in sctp_sf_eat_sack_6_2() argument
3417 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_sack_6_2()
3421 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_sack_6_2()
3428 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_sack_6_2()
3429 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3430 ctsn = ntohl(sackh->cum_tsn_ack); in sctp_sf_eat_sack_6_2()
3436 if (TSN_lte(asoc->next_tsn, ctsn)) in sctp_sf_eat_sack_6_2()
3437 return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); in sctp_sf_eat_sack_6_2()
3439 trace_sctp_probe(ep, asoc, chunk); in sctp_sf_eat_sack_6_2()
3445 * Point indicates an out-of-order SACK. in sctp_sf_eat_sack_6_2()
3447 if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { in sctp_sf_eat_sack_6_2()
3449 asoc->ctsn_ack_point); in sctp_sf_eat_sack_6_2()
3472 * packet and set the T-bit in the Chunk Flags to indicate that the
3483 const struct sctp_endpoint *ep, in sctp_sf_tabort_8_4_8() argument
3506 /* Reflect vtag if T-Bit is set */ in sctp_sf_tabort_8_4_8()
3508 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3511 abort->skb->sk = ep->base.sk; in sctp_sf_tabort_8_4_8()
3519 sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_tabort_8_4_8()
3526 * From Section 4 at draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.
3530 const struct sctp_endpoint *ep, in sctp_sf_new_encap_port() argument
3550 abort->skb->sk = ep->base.sk; in sctp_sf_new_encap_port()
3559 sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_new_encap_port()
3567 * API 5.3.1.3 - SCTP_REMOTE_ERROR
3572 const struct sctp_endpoint *ep, in sctp_sf_operr_notify() argument
3582 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_operr_notify()
3586 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_operr_notify()
3588 sctp_walk_errors(err, chunk->chunk_hdr); in sctp_sf_operr_notify()
3589 if ((void *)err != (void *)chunk->chunk_end) in sctp_sf_operr_notify()
3590 return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, in sctp_sf_operr_notify()
3604 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3610 const struct sctp_endpoint *ep, in sctp_sf_do_9_2_final() argument
3621 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_9_2_final()
3625 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_9_2_final()
3648 * stop the T2-shutdown timer, in sctp_sf_do_9_2_final()
3673 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3680 * set the T-bit in the Chunk Flags to indicate that the Verification
3687 * packet and set the T-bit in the Chunk Flags to indicate that the
3693 const struct sctp_endpoint *ep, in sctp_sf_ootb() argument
3699 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3711 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3714 if (ntohs(ch->length) < sizeof(*ch)) in sctp_sf_ootb()
3715 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_ootb()
3719 ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); in sctp_sf_ootb()
3721 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_ootb()
3727 if (SCTP_CID_SHUTDOWN_ACK == ch->type) in sctp_sf_ootb()
3735 if (SCTP_CID_ABORT == ch->type) in sctp_sf_ootb()
3736 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_ootb()
3743 if (SCTP_CID_COOKIE_ACK == ch->type) in sctp_sf_ootb()
3746 if (SCTP_CID_ERROR == ch->type) { in sctp_sf_ootb()
3748 if (SCTP_ERROR_STALE_COOKIE == err->cause) { in sctp_sf_ootb()
3759 return sctp_sf_shut_8_4_5(net, ep, asoc, type, arg, commands); in sctp_sf_ootb()
3761 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_ootb()
3763 return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); in sctp_sf_ootb()
3776 * set the T-bit in the Chunk Flags to indicate that the Verification
3789 const struct sctp_endpoint *ep, in sctp_sf_shut_8_4_5() argument
3812 /* Reflect vtag if T-Bit is set */ in sctp_sf_shut_8_4_5()
3814 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3817 shut->skb->sk = ep->base.sk; in sctp_sf_shut_8_4_5()
3830 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_shut_8_4_5()
3837 * If the receiver is in COOKIE-ECHOED or COOKIE-WAIT state the
3841 * chunks. --piggy ]
3845 const struct sctp_endpoint *ep, in sctp_sf_do_8_5_1_E_sa() argument
3858 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_8_5_1_E_sa()
3868 return sctp_sf_shut_8_4_5(net, ep, NULL, type, arg, commands); in sctp_sf_do_8_5_1_E_sa()
3873 const struct sctp_endpoint *ep, in sctp_sf_do_asconf() argument
3888 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_asconf()
3893 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_asconf()
3896 /* ADD-IP: Section 4.1.1 in sctp_sf_do_asconf()
3898 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3900 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf()
3902 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf()
3903 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3904 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_asconf()
3906 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3907 serial = ntohl(hdr->serial); in sctp_sf_do_asconf()
3911 return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, in sctp_sf_do_asconf()
3916 * 'Peer-Serial-Number'. in sctp_sf_do_asconf()
3918 if (serial == asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3920 * we can clean our old ASCONF-ACKs. in sctp_sf_do_asconf()
3922 if (!chunk->has_asconf) in sctp_sf_do_asconf()
3927 * processing the ASCONF Chunk, append an ASCONF-ACK Chunk to in sctp_sf_do_asconf()
3931 * Essentially, do V1-V5. in sctp_sf_do_asconf()
3937 } else if (serial < asoc->peer.addip_serial + 1) { in sctp_sf_do_asconf()
3940 * ('Peer- Sequence-Number' + 1), simply skip to the next in sctp_sf_do_asconf()
3942 * any previously cached ASCONF-ACK response that was in sctp_sf_do_asconf()
3944 * ASCONF. Note: It is possible that no cached ASCONF-ACK in sctp_sf_do_asconf()
3947 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3950 asconf_ack = sctp_assoc_lookup_asconf_ack(asoc, hdr->serial); in sctp_sf_do_asconf()
3958 asconf_ack->transport = NULL; in sctp_sf_do_asconf()
3967 * containing the ASCONF-ACK Chunks MUST be the source address of in sctp_sf_do_asconf()
3975 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
3977 if (asoc->new_transport) { in sctp_sf_do_asconf()
3978 sctp_sf_heartbeat(ep, asoc, type, asoc->new_transport, commands); in sctp_sf_do_asconf()
3979 ((struct sctp_association *)asoc)->new_transport = NULL; in sctp_sf_do_asconf()
3987 const struct sctp_endpoint *ep, in sctp_send_next_asconf() argument
3995 if (list_empty(&asoc->addip_chunk_list)) in sctp_send_next_asconf()
3998 entry = asoc->addip_chunk_list.next; in sctp_send_next_asconf()
4003 asoc->addip_last_asconf = asconf; in sctp_send_next_asconf()
4005 return sctp_sf_do_prm_asconf(net, ep, asoc, type, asconf, commands); in sctp_send_next_asconf()
4014 const struct sctp_endpoint *ep, in sctp_sf_do_asconf_ack() argument
4020 struct sctp_chunk *last_asconf = asoc->addip_last_asconf; in sctp_sf_do_asconf_ack()
4030 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_asconf_ack()
4036 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_asconf_ack()
4039 /* ADD-IP, Section 4.1.2: in sctp_sf_do_asconf_ack()
4041 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf_ack()
4043 * described in [I-D.ietf-tsvwg-sctp-auth]. in sctp_sf_do_asconf_ack()
4045 if (!asoc->peer.asconf_capable || in sctp_sf_do_asconf_ack()
4046 (!net->sctp.addip_noauth && !asconf_ack->auth)) in sctp_sf_do_asconf_ack()
4047 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_asconf_ack()
4049 addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data; in sctp_sf_do_asconf_ack()
4050 rcvd_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4052 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
4054 return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, in sctp_sf_do_asconf_ack()
4058 addip_hdr = last_asconf->subh.addip_hdr; in sctp_sf_do_asconf_ack()
4059 sent_serial = ntohl(addip_hdr->serial); in sctp_sf_do_asconf_ack()
4061 sent_serial = asoc->addip_serial - 1; in sctp_sf_do_asconf_ack()
4064 /* D0) If an endpoint receives an ASCONF-ACK that is greater than or in sctp_sf_do_asconf_ack()
4067 * sequence number is greater than if it is no more than 2^^31-1 in sctp_sf_do_asconf_ack()
4071 !(asoc->addip_last_asconf)) { in sctp_sf_do_asconf_ack()
4094 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { in sctp_sf_do_asconf_ack()
4100 return sctp_send_next_asconf(net, ep, in sctp_sf_do_asconf_ack()
4127 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
4129 const struct sctp_endpoint *ep, in sctp_sf_do_reconf() argument
4143 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_do_reconf()
4148 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_do_reconf()
4152 return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, in sctp_sf_do_reconf()
4155 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4160 if (param.p->type == SCTP_PARAM_RESET_OUT_REQUEST) in sctp_sf_do_reconf()
4163 else if (param.p->type == SCTP_PARAM_RESET_IN_REQUEST) in sctp_sf_do_reconf()
4166 else if (param.p->type == SCTP_PARAM_RESET_TSN_REQUEST) in sctp_sf_do_reconf()
4169 else if (param.p->type == SCTP_PARAM_RESET_ADD_OUT_STREAMS) in sctp_sf_do_reconf()
4172 else if (param.p->type == SCTP_PARAM_RESET_ADD_IN_STREAMS) in sctp_sf_do_reconf()
4175 else if (param.p->type == SCTP_PARAM_RESET_RESPONSE) in sctp_sf_do_reconf()
4192 * PR-SCTP Section 3.6 Receiver Side Implementation of PR-SCTP
4206 const struct sctp_endpoint *ep, in sctp_sf_eat_fwd_tsn() argument
4220 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_fwd_tsn()
4223 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn()
4224 return sctp_sf_unk_chunk(net, ep, asoc, type, arg, commands); in sctp_sf_eat_fwd_tsn()
4227 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn()
4228 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_fwd_tsn()
4231 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn()
4232 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn()
4233 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn()
4234 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn()
4235 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn()
4237 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn()
4240 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn()
4243 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn()
4246 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4250 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn()
4255 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) { in sctp_sf_eat_fwd_tsn()
4273 const struct sctp_endpoint *ep, in sctp_sf_eat_fwd_tsn_fast() argument
4287 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_fwd_tsn_fast()
4290 if (!asoc->peer.prsctp_capable) in sctp_sf_eat_fwd_tsn_fast()
4291 return sctp_sf_unk_chunk(net, ep, asoc, type, arg, commands); in sctp_sf_eat_fwd_tsn_fast()
4294 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) in sctp_sf_eat_fwd_tsn_fast()
4295 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_fwd_tsn_fast()
4298 fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; in sctp_sf_eat_fwd_tsn_fast()
4299 chunk->subh.fwdtsn_hdr = fwdtsn_hdr; in sctp_sf_eat_fwd_tsn_fast()
4300 len = ntohs(chunk->chunk_hdr->length); in sctp_sf_eat_fwd_tsn_fast()
4301 len -= sizeof(struct sctp_chunkhdr); in sctp_sf_eat_fwd_tsn_fast()
4302 skb_pull(chunk->skb, len); in sctp_sf_eat_fwd_tsn_fast()
4304 tsn = ntohl(fwdtsn_hdr->new_cum_tsn); in sctp_sf_eat_fwd_tsn_fast()
4307 /* The TSN is too high--silently discard the chunk and count on it in sctp_sf_eat_fwd_tsn_fast()
4310 if (sctp_tsnmap_check(&asoc->peer.tsn_map, tsn) < 0) in sctp_sf_eat_fwd_tsn_fast()
4313 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4317 if (len > sctp_ftsnhdr_len(&asoc->stream)) in sctp_sf_eat_fwd_tsn_fast()
4325 * While in SHUTDOWN-SENT state, the SHUTDOWN sender MUST immediately in sctp_sf_eat_fwd_tsn_fast()
4327 * with a SACK, a SHUTDOWN chunk, and restart the T2-shutdown timer in sctp_sf_eat_fwd_tsn_fast()
4338 * SCTP-AUTH Section 6.3 Receiving authenticated chunks
4342 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4371 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_authenticate()
4372 chunk->subh.auth_hdr = auth_hdr; in sctp_sf_authenticate()
4373 skb_pull(chunk->skb, sizeof(*auth_hdr)); in sctp_sf_authenticate()
4378 if (!sctp_auth_asoc_verify_hmac_id(asoc, auth_hdr->hmac_id)) in sctp_sf_authenticate()
4384 key_id = ntohs(auth_hdr->shkey_id); in sctp_sf_authenticate()
4385 if (key_id != asoc->active_key_id) { in sctp_sf_authenticate()
4394 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4396 hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); in sctp_sf_authenticate()
4397 if (sig_len != hmac->hmac_len) in sctp_sf_authenticate()
4408 skb_pull(chunk->skb, sig_len); in sctp_sf_authenticate()
4416 sctp_auth_calculate_hmac(asoc, chunk->skb, in sctp_sf_authenticate()
4417 (struct sctp_auth_chunk *)chunk->chunk_hdr, in sctp_sf_authenticate()
4427 chunk->auth = 1; in sctp_sf_authenticate()
4435 const struct sctp_endpoint *ep, in sctp_sf_eat_auth() argument
4446 if (!asoc->peer.auth_capable) in sctp_sf_eat_auth()
4447 return sctp_sf_unk_chunk(net, ep, asoc, type, arg, commands); in sctp_sf_eat_auth()
4452 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_auth()
4457 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_auth()
4460 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4469 &auth_hdr->hmac_id, in sctp_sf_eat_auth()
4478 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_eat_auth()
4481 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_eat_auth()
4491 if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { in sctp_sf_eat_auth()
4494 ev = sctp_ulpevent_make_authkey(asoc, ntohs(auth_hdr->shkey_id), in sctp_sf_eat_auth()
4512 * Chunk Types are encoded such that the highest-order two bits specify
4516 * 00 - Stop processing this SCTP packet and discard it, do not process
4519 * 01 - Stop processing this SCTP packet and discard it, do not process
4523 * 10 - Skip this chunk and continue processing.
4525 * 11 - Skip this chunk and continue processing, but report in an ERROR
4531 const struct sctp_endpoint *ep, in sctp_sf_unk_chunk() argument
4544 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_unk_chunk()
4551 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_unk_chunk()
4557 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_unk_chunk()
4560 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4563 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4571 sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_unk_chunk()
4578 hdr = unk_chunk->chunk_hdr; in sctp_sf_unk_chunk()
4581 SCTP_PAD4(ntohs(hdr->length)), in sctp_sf_unk_chunk()
4611 const struct sctp_endpoint *ep, in sctp_sf_discard_chunk() argument
4620 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_discard_chunk()
4627 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_discard_chunk()
4654 const struct sctp_endpoint *ep, in sctp_sf_pdiscard() argument
4681 const struct sctp_endpoint *ep, in sctp_sf_violation() argument
4690 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); in sctp_sf_violation()
4694 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, in sctp_sf_violation()
4705 const struct sctp_endpoint *ep, in sctp_sf_abort_violation() argument
4716 /* SCTP-AUTH, Section 6.3: in sctp_sf_abort_violation()
4736 /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ in sctp_sf_abort_violation()
4737 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4738 !asoc->peer.i.init_tag) { in sctp_sf_abort_violation()
4741 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4743 abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T; in sctp_sf_abort_violation()
4747 inittag = ntohl(initack->init_hdr.init_tag); in sctp_sf_abort_violation()
4756 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { in sctp_sf_abort_violation()
4777 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4779 abort->skb->sk = ep->base.sk; in sctp_sf_abort_violation()
4792 sctp_sf_pdiscard(net, ep, asoc, SCTP_ST_CHUNK(0), arg, commands); in sctp_sf_abort_violation()
4822 const struct sctp_endpoint *ep, in sctp_sf_violation_chunklen() argument
4830 return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, in sctp_sf_violation_chunklen()
4842 const struct sctp_endpoint *ep, in sctp_sf_violation_paramlen() argument
4871 sctp_sf_pdiscard(net, ep, asoc, SCTP_ST_CHUNK(0), arg, commands); in sctp_sf_violation_paramlen()
4885 const struct sctp_endpoint *ep, in sctp_sf_violation_ctsn() argument
4893 return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, in sctp_sf_violation_ctsn()
4898 * when we have an association and we receive bundled INIT-ACK, or
4899 * SHUTDOWN-COMPLETE, our peer is clearly violating the "MUST NOT bundle"
4905 const struct sctp_endpoint *ep, in sctp_sf_violation_chunk() argument
4913 return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, in sctp_sf_violation_chunk()
4922 * Section: 10.1 ULP-to-SCTP
4927 * -> association id [,destination transport addr list] [,outbound stream
4956 * stuff happens when the INIT ACK arrives. This is a NON-BLOCKING
4961 * o local SCTP instance name - obtained from the INITIALIZE operation.
4963 * o destination transport addr - specified as one of the transport
4966 * [This is asoc->peer.active_path.]
4967 * o outbound stream count - the number of outbound streams the ULP
4977 const struct sctp_endpoint *ep, in sctp_sf_do_prm_asoc() argument
4986 /* The comment below says that we enter COOKIE-WAIT AFTER in sctp_sf_do_prm_asoc()
5001 repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); in sctp_sf_do_prm_asoc()
5015 /* After sending the INIT, "A" starts the T1-init timer and in sctp_sf_do_prm_asoc()
5016 * enters the COOKIE-WAIT state. in sctp_sf_do_prm_asoc()
5030 * Section: 10.1 ULP-to-SCTP
5035 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
5036 * -> result
5042 * o association id - local handle to the SCTP association
5044 * o buffer address - the location where the user message to be
5047 * o byte count - The size of the user data in number of bytes;
5051 * o context - an optional 32 bit integer that will be carried in the
5055 * o stream id - to indicate which stream to send the data on. If not
5058 * o life time - specifies the life time of the user data. The user data
5067 * o destination transport address - specified as one of the destination
5073 * o unorder flag - this flag, if present, indicates that the user
5078 * o no-bundle flag - instructs SCTP not to bundle this user data with
5082 * o payload protocol-id - A 32 bit unsigned integer that is to be
5089 const struct sctp_endpoint *ep, in sctp_sf_do_prm_send() argument
5108 * -> result
5119 * o association id - local handle to the SCTP association
5129 const struct sctp_endpoint *ep, in sctp_sf_do_9_2_prm_shutdown() argument
5139 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_do_9_2_prm_shutdown()
5149 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_do_9_2_prm_shutdown()
5150 disposition = sctp_sf_do_9_2_start_shutdown(net, ep, asoc, type, in sctp_sf_do_9_2_prm_shutdown()
5164 * -> result
5174 * o association id - local handle to the SCTP association
5178 * o cause code - reason of the abort to be passed to the peer
5186 const struct sctp_endpoint *ep, in sctp_sf_do_9_1_prm_abort() argument
5223 const struct sctp_endpoint *ep, in sctp_sf_error_closed() argument
5229 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_ERROR, SCTP_ERROR(-EINVAL)); in sctp_sf_error_closed()
5238 const struct sctp_endpoint *ep, in sctp_sf_error_shutdown() argument
5245 SCTP_ERROR(-ESHUTDOWN)); in sctp_sf_error_shutdown()
5265 const struct sctp_endpoint *ep, in sctp_sf_cookie_wait_prm_shutdown() argument
5300 const struct sctp_endpoint *ep, in sctp_sf_cookie_echoed_prm_shutdown() argument
5307 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_shutdown()
5309 return sctp_sf_cookie_wait_prm_shutdown(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_echoed_prm_shutdown()
5328 const struct sctp_endpoint *ep, in sctp_sf_cookie_wait_prm_abort() argument
5336 /* Stop T1-init timer */ in sctp_sf_cookie_wait_prm_abort()
5377 const struct sctp_endpoint *ep, in sctp_sf_cookie_echoed_prm_abort() argument
5384 * common function with the COOKIE-WAIT state. in sctp_sf_cookie_echoed_prm_abort()
5386 return sctp_sf_cookie_wait_prm_abort(net, ep, asoc, type, arg, commands); in sctp_sf_cookie_echoed_prm_abort()
5396 * state table when someone issues an abort while in SHUTDOWN-PENDING state.
5403 const struct sctp_endpoint *ep, in sctp_sf_shutdown_pending_prm_abort() argument
5409 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_pending_prm_abort()
5413 return sctp_sf_do_9_1_prm_abort(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_pending_prm_abort()
5423 * state table when someone issues an abort while in SHUTDOWN-SENT state.
5430 const struct sctp_endpoint *ep, in sctp_sf_shutdown_sent_prm_abort() argument
5436 /* Stop the T2-shutdown timer. */ in sctp_sf_shutdown_sent_prm_abort()
5440 /* Stop the T5-shutdown guard timer. */ in sctp_sf_shutdown_sent_prm_abort()
5444 return sctp_sf_do_9_1_prm_abort(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_sent_prm_abort()
5461 const struct sctp_endpoint *ep, in sctp_sf_shutdown_ack_sent_prm_abort() argument
5468 * common function with the SHUTDOWN-SENT state. in sctp_sf_shutdown_ack_sent_prm_abort()
5470 return sctp_sf_shutdown_sent_prm_abort(net, ep, asoc, type, arg, commands); in sctp_sf_shutdown_ack_sent_prm_abort()
5476 * 10.1 ULP-to-SCTP
5481 * -> result
5490 * o association id - local handle to the SCTP association
5492 * o destination transport address - the transport address of the
5497 const struct sctp_endpoint *ep, in sctp_sf_do_prm_requestheartbeat() argument
5503 if (SCTP_DISPOSITION_NOMEM == sctp_sf_heartbeat(ep, asoc, type, in sctp_sf_do_prm_requestheartbeat()
5510 * D) Request an on-demand HEARTBEAT on a specific destination in sctp_sf_do_prm_requestheartbeat()
5529 const struct sctp_endpoint *ep, in sctp_sf_do_prm_asconf() argument
5544 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5546 const struct sctp_endpoint *ep, in sctp_sf_do_prm_reconf() argument
5565 const struct sctp_endpoint *ep, in sctp_sf_ignore_primitive() argument
5589 const struct sctp_endpoint *ep, in sctp_sf_do_no_pending_tsn() argument
5613 * It shall then start the T2-shutdown timer and enter the SHUTDOWN-SENT
5614 * state. If the timer expires, the endpoint must re-send the SHUTDOWN
5621 const struct sctp_endpoint *ep, in sctp_sf_do_9_2_start_shutdown() argument
5639 * T2-shutdown timer. in sctp_sf_do_9_2_start_shutdown()
5643 /* It shall then start the T2-shutdown timer */ in sctp_sf_do_9_2_start_shutdown()
5649 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. in sctp_sf_do_9_2_start_shutdown()
5654 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_start_shutdown()
5658 /* and enter the SHUTDOWN-SENT state. */ in sctp_sf_do_9_2_start_shutdown()
5662 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_start_shutdown()
5665 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_start_shutdown()
5683 * shall send a SHUTDOWN ACK and start a T2-shutdown timer of its own,
5684 * entering the SHUTDOWN-ACK-SENT state. If the timer expires, the
5685 * endpoint must re-send the SHUTDOWN ACK.
5691 const struct sctp_endpoint *ep, in sctp_sf_do_9_2_shutdown_ack() argument
5709 return sctp_sf_pdiscard(net, ep, asoc, type, arg, in sctp_sf_do_9_2_shutdown_ack()
5715 return sctp_sf_violation_chunklen(net, ep, asoc, type, in sctp_sf_do_9_2_shutdown_ack()
5727 * the T2-shutdown timer. in sctp_sf_do_9_2_shutdown_ack()
5731 /* and start/restart a T2-shutdown timer of its own, */ in sctp_sf_do_9_2_shutdown_ack()
5735 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) in sctp_sf_do_9_2_shutdown_ack()
5739 /* Enter the SHUTDOWN-ACK-SENT state. */ in sctp_sf_do_9_2_shutdown_ack()
5743 /* sctp-implguide 2.10 Issues with Heartbeating and failover in sctp_sf_do_9_2_shutdown_ack()
5746 * or SHUTDOWN-ACK. in sctp_sf_do_9_2_shutdown_ack()
5764 const struct sctp_endpoint *ep, in sctp_sf_ignore_other() argument
5783 * Section: 6.3.3 Handle T3-rtx Expiration
5785 * Whenever the retransmission timer T3-rtx expires for a destination
5792 const struct sctp_endpoint *ep, in sctp_sf_do_6_3_3_rtx() argument
5802 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_do_6_3_3_rtx()
5803 if (asoc->peer.zero_window_announced && in sctp_sf_do_6_3_3_rtx()
5804 asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { in sctp_sf_do_6_3_3_rtx()
5830 * 7.2.3 and set the cwnd <- MTU. in sctp_sf_do_6_3_3_rtx()
5834 * expires, set RTO <- RTO * 2 ("back off the timer"). The in sctp_sf_do_6_3_3_rtx()
5841 * T3-rtx has expired will fit into a single packet, subject in sctp_sf_do_6_3_3_rtx()
5850 * which the T3-rtx timer expired but did not fit in one MTU in sctp_sf_do_6_3_3_rtx()
5880 const struct sctp_endpoint *ep, in sctp_sf_do_6_2_sack() argument
5900 * 2) If the T1-init timer expires, the endpoint MUST retransmit INIT
5901 * and re-start the T1-init timer without changing state. This MUST
5912 const struct sctp_endpoint *ep, in sctp_sf_t1_init_timer_expire() argument
5918 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_init_timer_expire()
5926 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_init_timer_expire()
5927 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; in sctp_sf_t1_init_timer_expire()
5944 asoc->max_init_attempts); in sctp_sf_t1_init_timer_expire()
5965 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
5966 * COOKIE ECHO and re-start the T1-cookie timer without changing
5977 const struct sctp_endpoint *ep, in sctp_sf_t1_cookie_timer_expire() argument
5983 int attempts = asoc->init_err_counter + 1; in sctp_sf_t1_cookie_timer_expire()
5986 pr_debug("%s: timer T1 expired (COOKIE-ECHO)\n", __func__); in sctp_sf_t1_cookie_timer_expire()
5990 if (attempts <= asoc->max_init_attempts) { in sctp_sf_t1_cookie_timer_expire()
6013 /* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
6023 * the T2-Shutdown timer, giving its peer ample opportunity to transmit
6028 const struct sctp_endpoint *ep, in sctp_sf_t2_timer_expire() argument
6040 ((struct sctp_association *)asoc)->shutdown_retries++; in sctp_sf_t2_timer_expire()
6042 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t2_timer_expire()
6053 switch (asoc->state) { in sctp_sf_t2_timer_expire()
6074 if (asoc->shutdown_last_sent_to) in sctp_sf_t2_timer_expire()
6076 SCTP_TRANSPORT(asoc->shutdown_last_sent_to)); in sctp_sf_t2_timer_expire()
6079 * the T2-shutdown timer. in sctp_sf_t2_timer_expire()
6083 /* Restart the T2-shutdown timer. */ in sctp_sf_t2_timer_expire()
6099 const struct sctp_endpoint *ep, in sctp_sf_t4_timer_expire() argument
6105 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire()
6106 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
6126 if (asoc->overall_error_count >= asoc->max_retrans) { in sctp_sf_t4_timer_expire()
6138 /* ADDIP 4.1 B3) Back-off the destination address RTO value to which in sctp_sf_t4_timer_expire()
6143 /* ADDIP 4.1 B4) Re-transmit the ASCONF Chunk last sent and if possible in sctp_sf_t4_timer_expire()
6149 sctp_chunk_hold(asoc->addip_last_asconf); in sctp_sf_t4_timer_expire()
6151 SCTP_CHUNK(asoc->addip_last_asconf)); in sctp_sf_t4_timer_expire()
6153 /* ADDIP 4.1 B5) Restart the T-4 RTO timer. Note that if a different in sctp_sf_t4_timer_expire()
6163 /* sctpimpguide-05 Section 2.12.2
6165 * 'T5-shutdown-guard' to bound the overall time for shutdown sequence.
6171 const struct sctp_endpoint *ep, in sctp_sf_t5_timer_expire() argument
6208 const struct sctp_endpoint *ep, in sctp_sf_autoclose_timer_expire() argument
6220 * layer, the endpoint enters SHUTDOWN-PENDING state and in sctp_sf_autoclose_timer_expire()
6230 if (sctp_outq_is_empty(&asoc->outqueue)) { in sctp_sf_autoclose_timer_expire()
6231 disposition = sctp_sf_do_9_2_start_shutdown(net, ep, asoc, type, in sctp_sf_autoclose_timer_expire()
6251 const struct sctp_endpoint *ep, in sctp_sf_not_impl() argument
6268 const struct sctp_endpoint *ep, in sctp_sf_bug() argument
6288 const struct sctp_endpoint *ep, in sctp_sf_timer_ignore() argument
6314 sack = (struct sctp_sackhdr *) chunk->skb->data; in sctp_sm_pull_sack()
6316 num_blocks = ntohs(sack->num_gap_ack_blocks); in sctp_sm_pull_sack()
6317 num_dup_tsns = ntohs(sack->num_dup_tsns); in sctp_sm_pull_sack()
6320 if (len > chunk->skb->len) in sctp_sm_pull_sack()
6323 skb_pull(chunk->skb, len); in sctp_sm_pull_sack()
6333 const struct sctp_endpoint *ep, in sctp_abort_pkt_new() argument
6353 /* Reflect vtag if T-Bit is set */ in sctp_abort_pkt_new()
6355 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6363 abort->skb->sk = ep->base.sk; in sctp_abort_pkt_new()
6384 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6385 dport = ntohs(chunk->sctp_hdr->source); in sctp_ootb_pkt_new()
6387 /* The V-tag is going to be the same as the inbound packet if no in sctp_ootb_pkt_new()
6391 /* Special case the INIT-ACK as there is no peer's vtag in sctp_ootb_pkt_new()
6394 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6400 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6401 vtag = ntohl(initack->init_hdr.init_tag); in sctp_ootb_pkt_new()
6405 vtag = asoc->peer.i.init_tag; in sctp_ootb_pkt_new()
6412 switch (chunk->chunk_hdr->type) { in sctp_ootb_pkt_new()
6417 init = (struct sctp_init_chunk *)chunk->chunk_hdr; in sctp_ootb_pkt_new()
6418 vtag = ntohl(init->init_hdr.init_tag); in sctp_ootb_pkt_new()
6422 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6432 transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_ootb_pkt_new()
6437 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6438 sctp_sk(net->sctp.ctl_sock)); in sctp_ootb_pkt_new()
6440 packet = &transport->packet; in sctp_ootb_pkt_new()
6453 sctp_transport_free(packet->transport); in sctp_ootb_pkt_free()
6458 const struct sctp_endpoint *ep, in sctp_send_stale_cookie_err() argument
6472 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6473 packet->vtag = cookie->c.peer_vtag; in sctp_send_stale_cookie_err()
6476 err_chunk->skb->sk = ep->base.sk; in sctp_send_stale_cookie_err()
6492 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_eat_data()
6493 struct sock *sk = asoc->base.sk; in sctp_eat_data()
6502 data_hdr = (struct sctp_datahdr *)chunk->skb->data; in sctp_eat_data()
6503 chunk->subh.data_hdr = data_hdr; in sctp_eat_data()
6504 skb_pull(chunk->skb, sctp_datahdr_len(&asoc->stream)); in sctp_eat_data()
6506 tsn = ntohl(data_hdr->tsn); in sctp_eat_data()
6509 /* ASSERT: Now skb->data is really the user data. */ in sctp_eat_data()
6521 if (asoc->peer.ecn_capable && !chunk->ecn_ce_done) { in sctp_eat_data()
6522 struct sctp_af *af = SCTP_INPUT_CB(chunk->skb)->af; in sctp_eat_data()
6523 chunk->ecn_ce_done = 1; in sctp_eat_data()
6525 if (af->is_ce(sctp_gso_headskb(chunk->skb))) { in sctp_eat_data()
6526 /* Do real work as side effect. */ in sctp_eat_data()
6532 tmp = sctp_tsnmap_check(&asoc->peer.tsn_map, tsn); in sctp_eat_data()
6534 /* The TSN is too high--silently discard the chunk and in sctp_eat_data()
6537 if (chunk->asoc) in sctp_eat_data()
6538 chunk->asoc->stats.outofseqtsns++; in sctp_eat_data()
6551 datalen = ntohs(chunk->chunk_hdr->length); in sctp_eat_data()
6552 datalen -= sctp_datachk_len(&asoc->stream); in sctp_eat_data()
6557 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) { in sctp_eat_data()
6570 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6571 (datalen > asoc->rwnd + asoc->frag_point))) { in sctp_eat_data()
6585 __func__, tsn, datalen, asoc->rwnd); in sctp_eat_data()
6611 * --------------- in sctp_eat_data()
6634 chunk->data_accepted = 1; in sctp_eat_data()
6639 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_eat_data()
6641 if (chunk->asoc) in sctp_eat_data()
6642 chunk->asoc->stats.iuodchunks++; in sctp_eat_data()
6645 if (chunk->asoc) in sctp_eat_data()
6646 chunk->asoc->stats.iodchunks++; in sctp_eat_data()
6657 if (ntohs(data_hdr->stream) >= asoc->stream.incnt) { in sctp_eat_data()
6662 &data_hdr->stream, in sctp_eat_data()
6663 sizeof(data_hdr->stream), in sctp_eat_data()
6678 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()