Lines Matching full:chunk

56 					struct sctp_chunk *chunk,
59 struct sctp_chunk *chunk,
64 const struct sctp_chunk *chunk);
68 const struct sctp_chunk *chunk,
99 static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk);
151 struct sctp_chunk *chunk);
167 /* Small helper function that checks if the chunk length
169 * is set to be the size of a specific chunk we are testing.
174 static inline bool sctp_chunk_length_valid(struct sctp_chunk *chunk, in sctp_chunk_length_valid() argument
177 __u16 chunk_length = ntohs(chunk->chunk_hdr->length); in sctp_chunk_length_valid()
180 if (unlikely(chunk->pdiscard)) in sctp_chunk_length_valid()
188 /* Check for format error in an ABORT chunk */
189 static inline bool sctp_err_chunk_valid(struct sctp_chunk *chunk) in sctp_err_chunk_valid() argument
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()
199 * These are the state functions for handling chunk events.
206 * Upon reception of the SHUTDOWN COMPLETE chunk the endpoint will verify
207 * that it is in SHUTDOWN-ACK-SENT state, if it is not the chunk should be
219 * it is set to its peer's tag and the T bit is set in the Chunk
226 * (endpoint, asoc, chunk)
231 * The return value is the disposition of the chunk.
239 struct sctp_chunk *chunk = arg; in sctp_sf_do_4_C() local
242 if (!sctp_vtag_verify_either(chunk, asoc)) in sctp_sf_do_4_C()
250 if (!chunk->singleton) in sctp_sf_do_4_C()
253 /* Make sure that the SHUTDOWN_COMPLETE chunk has a valid length. */ in sctp_sf_do_4_C()
254 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_do_4_C()
271 /* Upon reception of the SHUTDOWN COMPLETE chunk the endpoint in sctp_sf_do_4_C()
273 * not the chunk should be discarded. If the endpoint is in in sctp_sf_do_4_C()
297 * Respond to a normal INIT chunk.
301 * B) "Z" shall respond immediately with an INIT ACK chunk. The
311 * (endpoint, asoc, chunk)
316 * The return value is the disposition of the chunk.
325 struct sctp_chunk *chunk = arg, *repl, *err_chunk; in sctp_sf_do_5_1B_init() local
336 * Furthermore, we require that the receiver of an INIT chunk MUST in sctp_sf_do_5_1B_init()
338 * with an INIT chunk that is bundled with other chunks. in sctp_sf_do_5_1B_init()
340 if (!chunk->singleton) in sctp_sf_do_5_1B_init()
343 /* Make sure that the INIT chunk has a valid length. in sctp_sf_do_5_1B_init()
348 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk))) in sctp_sf_do_5_1B_init()
359 /* 3.1 A packet containing an INIT chunk MUST have a zero Verification in sctp_sf_do_5_1B_init()
362 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_5_1B_init()
374 /* Verify the INIT chunk before processing it. */ 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()
379 /* This chunk contains fatal error. It is to be discarded. 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()
422 sctp_scope(sctp_source(chunk)), in sctp_sf_do_5_1B_init()
427 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), in sctp_sf_do_5_1B_init()
428 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_5_1B_init()
432 /* B) "Z" shall respond immediately with an INIT ACK chunk. */ in sctp_sf_do_5_1B_init()
442 repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); in sctp_sf_do_5_1B_init()
452 * ERROR chunk generated by sctp_verify_init(). Since the in sctp_sf_do_5_1B_init()
491 * Respond to a normal INIT ACK chunk.
497 * Cookie received in the INIT ACK chunk in a COOKIE ECHO chunk, start
500 * Note: The COOKIE ECHO chunk can be bundled with any pending outbound
501 * DATA chunks, but it MUST be the first chunk in the packet and
506 * If the value of the Initiate Tag in a received INIT ACK chunk is
511 * (endpoint, asoc, chunk)
516 * The return value is the disposition of the chunk.
526 struct sctp_chunk *chunk = arg; in sctp_sf_do_5_1C_ack() local
530 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_5_1C_ack()
537 if (!chunk->singleton) 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()
541 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_initack_chunk))) 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()
547 /* Verify the INIT chunk before processing it. */ 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()
555 /* This chunk contains fatal error. It is to be discarded. in sctp_sf_do_5_1C_ack()
593 asoc, chunk->transport); in sctp_sf_do_5_1C_ack()
597 * convert the parameters in an INIT chunk. 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()
626 * INIT ACK chunk in a COOKIE ECHO chunk, ... in sctp_sf_do_5_1C_ack()
628 /* If there is any errors to report, send the ERROR chunk generated in sctp_sf_do_5_1C_ack()
637 static bool sctp_auth_chunk_verify(struct net *net, struct sctp_chunk *chunk, in sctp_auth_chunk_verify() argument
642 if (!chunk->auth_chunk) 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()
670 * Respond to a normal COOKIE ECHO chunk.
674 * D) Upon reception of the COOKIE ECHO chunk, Endpoint "Z" will reply
675 * with a COOKIE ACK chunk after building a TCB and moving to
676 * the ESTABLISHED state. A COOKIE ACK chunk may be bundled with
678 * chunk MUST be the first chunk in the packet.
682 * of a valid COOKIE ECHO chunk.
693 * (endpoint, asoc, chunk)
698 * The return value is the disposition of the chunk.
710 struct sctp_chunk *chunk = arg; in sctp_sf_do_5_1D_ce() local
716 if (asoc && !sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_5_1D_ce()
727 /* Make sure that the COOKIE_ECHO chunk has a valid length. in sctp_sf_do_5_1D_ce()
729 * chunk header. More detailed verification is done in sctp_sf_do_5_1D_ce()
732 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_do_5_1D_ce()
745 /* "Decode" the chunk. We have no optional parameters so we 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()
754 /* 5.1 D) Upon reception of the COOKIE ECHO chunk, Endpoint in sctp_sf_do_5_1D_ce()
755 * "Z" will reply with a COOKIE ACK chunk after building a TCB 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()
776 sctp_send_stale_cookie_err(net, ep, asoc, chunk, 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()
799 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_5_1D_ce()
800 if (!sctp_process_init(new_asoc, chunk, in sctp_sf_do_5_1D_ce()
801 &chunk->subh.cookie_hdr->c.peer_addr, in sctp_sf_do_5_1D_ce()
813 if (!sctp_auth_chunk_verify(net, chunk, new_asoc)) { in sctp_sf_do_5_1D_ce()
818 repl = sctp_make_cookie_ack(new_asoc, chunk); in sctp_sf_do_5_1D_ce()
826 * upon reception of a valid COOKIE ECHO chunk. in sctp_sf_do_5_1D_ce()
902 * Respond to a normal COOKIE ACK chunk.
915 * (endpoint, asoc, chunk)
920 * The return value is the disposition of the chunk.
929 struct sctp_chunk *chunk = arg; in sctp_sf_do_5_1E_ca() local
932 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_5_1E_ca()
937 chunk->head_skb ?: chunk->skb)) 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()
943 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_do_5_1E_ca()
1031 * is started with this heartbeat chunk. in sctp_sf_heartbeat()
1064 * chunk is sent and the destination transport address to which this in sctp_sf_sendbeat_8_3()
1117 /* send hb chunk with padding for PLPMUTD. */
1148 * from the received HEARTBEAT chunk.
1159 * (endpoint, asoc, chunk)
1164 * The return value is the disposition of the chunk.
1173 struct sctp_chunk *chunk = arg; in sctp_sf_beat_8_3() local
1177 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_beat_8_3()
1180 /* Make sure that the HEARTBEAT chunk has a valid length. */ in sctp_sf_beat_8_3()
1181 if (!sctp_chunk_length_valid(chunk, in sctp_sf_beat_8_3()
1188 * Information field copied from the received HEARTBEAT chunk. 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()
1198 if (!pskb_pull(chunk->skb, paylen)) in sctp_sf_beat_8_3()
1201 reply = sctp_make_heartbeat_ack(asoc, chunk, param_hdr, paylen); in sctp_sf_beat_8_3()
1228 * value carried in the HEARTBEAT ACK chunk.
1233 * (endpoint, asoc, chunk)
1238 * The return value is the disposition of the chunk.
1248 struct sctp_chunk *chunk = arg; in sctp_sf_backbeat_8_3() local
1253 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_backbeat_8_3()
1256 /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ in sctp_sf_backbeat_8_3()
1257 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr) + in sctp_sf_backbeat_8_3()
1262 hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data; in sctp_sf_backbeat_8_3()
1511 * chunk handling.
1521 struct sctp_chunk *chunk = arg, *repl, *err_chunk; in sctp_sf_do_unexpected_init() local
1533 * Furthermore, we require that the receiver of an INIT chunk MUST in sctp_sf_do_unexpected_init()
1535 * with an INIT chunk that is bundled with other chunks. in sctp_sf_do_unexpected_init()
1537 if (!chunk->singleton) in sctp_sf_do_unexpected_init()
1540 /* Make sure that the INIT chunk has a valid length. */ in sctp_sf_do_unexpected_init()
1541 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk))) in sctp_sf_do_unexpected_init()
1544 /* 3.1 A packet containing an INIT chunk MUST have a zero Verification in sctp_sf_do_unexpected_init()
1547 if (chunk->sctp_hdr->vtag != 0) 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()
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()
1559 /* Verify the INIT chunk before processing it. */ 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()
1564 /* This chunk contains fatal error. It is to be discarded. 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()
1607 sctp_scope(sctp_source(chunk)), GFP_ATOMIC) < 0) in sctp_sf_do_unexpected_init()
1614 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), in sctp_sf_do_unexpected_init()
1615 (struct sctp_init_chunk *)chunk->chunk_hdr, in sctp_sf_do_unexpected_init()
1625 if (!sctp_sf_check_restart_addrs(new_asoc, asoc, chunk, in sctp_sf_do_unexpected_init()
1634 /* B) "Z" shall respond immediately with an INIT ACK chunk. */ in sctp_sf_do_unexpected_init()
1645 repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); in sctp_sf_do_unexpected_init()
1655 * ERROR chunk generated by sctp_verify_init(). Since the in sctp_sf_do_unexpected_init()
1706 * sent in its original INIT chunk (including its Verification Tag,
1708 * newly received INIT chunk. The endpoint shall also generate a State
1725 * (endpoint, asoc, chunk)
1730 * The return value is the disposition of the chunk.
1741 * duplicate INIT chunk handling. in sctp_sf_do_5_2_1_siminit()
1780 * (endpoint, asoc, chunk)
1785 * The return value is the disposition of the chunk.
1796 * duplicate INIT chunk handling. in sctp_sf_do_5_2_2_dupinit()
1807 * COOKIE-WAIT state, the endpoint should discard the INIT ACK chunk.
1809 * duplicated INIT chunk.
1819 /* Per the above section, we'll discard the chunk if we have an in sctp_sf_do_5_2_3_initack()
1861 struct sctp_chunk *chunk, in sctp_sf_do_dupcook_a() argument
1874 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_a()
1875 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, in sctp_sf_do_dupcook_a()
1882 if (!sctp_auth_chunk_verify(net, chunk, new_asoc)) in sctp_sf_do_dupcook_a()
1889 if (!sctp_sf_check_restart_addrs(new_asoc, asoc, chunk, commands)) in sctp_sf_do_dupcook_a()
1895 * chunk with a "Cookie Received while Shutting Down" error cause to in sctp_sf_do_dupcook_a()
1900 SCTP_ST_CHUNK(chunk->chunk_hdr->type), in sctp_sf_do_dupcook_a()
1901 chunk, commands); in sctp_sf_do_dupcook_a()
1905 err = sctp_make_op_error(asoc, chunk, in sctp_sf_do_dupcook_a()
1934 repl = sctp_make_cookie_ack(asoc, chunk); in sctp_sf_do_dupcook_a()
1984 struct sctp_chunk *chunk, in sctp_sf_do_dupcook_b() argument
1994 peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); in sctp_sf_do_dupcook_b()
1995 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, in sctp_sf_do_dupcook_b()
2002 if (!sctp_auth_chunk_verify(net, chunk, new_asoc)) in sctp_sf_do_dupcook_b()
2015 repl = sctp_make_cookie_ack(asoc, chunk); in sctp_sf_do_dupcook_b()
2025 * upon reception of a valid COOKIE ECHO chunk. in sctp_sf_do_dupcook_b()
2068 struct sctp_chunk *chunk, in sctp_sf_do_dupcook_c() argument
2079 /* Unexpected COOKIE-ECHO handler lost chunk (Table 2, action 'D')
2091 struct sctp_chunk *chunk, in sctp_sf_do_dupcook_d() argument
2105 if (!sctp_auth_chunk_verify(net, chunk, asoc)) in sctp_sf_do_dupcook_d()
2123 * ECHO chunk. in sctp_sf_do_dupcook_d()
2155 repl = sctp_make_cookie_ack(asoc, chunk); in sctp_sf_do_dupcook_d()
2185 * chunk was retransmitted and then delayed in the network.
2192 * (endpoint, asoc, chunk)
2197 * The return value is the disposition of the chunk.
2208 struct sctp_chunk *chunk = arg; in sctp_sf_do_5_2_4_dupcook() local
2214 /* Make sure that the chunk has a valid length from the protocol in sctp_sf_do_5_2_4_dupcook()
2216 * enough for the chunk header. Cookie length verification is in sctp_sf_do_5_2_4_dupcook()
2219 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) { in sctp_sf_do_5_2_4_dupcook()
2220 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_5_2_4_dupcook()
2225 /* "Decode" the chunk. We have no optional parameters so we 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()
2256 sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, in sctp_sf_do_5_2_4_dupcook()
2282 chunk->head_skb ?: chunk->skb)) { 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()
2344 struct sctp_chunk *chunk = arg; in sctp_sf_shutdown_pending_abort() local
2346 if (!sctp_vtag_verify_either(chunk, asoc)) in sctp_sf_shutdown_pending_abort()
2349 /* Make sure that the ABORT chunk has a valid length. in sctp_sf_shutdown_pending_abort()
2350 * Since this is an ABORT chunk, we have to discard it in sctp_sf_shutdown_pending_abort()
2359 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_abort_chunk))) in sctp_sf_shutdown_pending_abort()
2368 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_pending_abort()
2371 if (!sctp_err_chunk_valid(chunk)) in sctp_sf_shutdown_pending_abort()
2390 struct sctp_chunk *chunk = arg; in sctp_sf_shutdown_sent_abort() local
2392 if (!sctp_vtag_verify_either(chunk, asoc)) in sctp_sf_shutdown_sent_abort()
2395 /* Make sure that the ABORT chunk has a valid length. in sctp_sf_shutdown_sent_abort()
2396 * Since this is an ABORT chunk, we have to discard it in sctp_sf_shutdown_sent_abort()
2405 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_abort_chunk))) in sctp_sf_shutdown_sent_abort()
2414 sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) in sctp_sf_shutdown_sent_abort()
2417 if (!sctp_err_chunk_valid(chunk)) in sctp_sf_shutdown_sent_abort()
2457 * (endpoint, asoc, chunk)
2462 * The return value is the disposition of the chunk.
2472 struct sctp_chunk *chunk = arg; in sctp_sf_cookie_echoed_err() local
2475 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_cookie_echoed_err()
2478 /* Make sure that the ERROR chunk has a valid length. in sctp_sf_cookie_echoed_err()
2481 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_operr_chunk))) in sctp_sf_cookie_echoed_err()
2490 sctp_walk_errors(err, chunk->chunk_hdr) { in sctp_sf_cookie_echoed_err()
2511 * 3) Send a new INIT chunk to the endpoint, adding a Cookie
2522 * (endpoint, asoc, chunk)
2527 * The return value is the disposition of the chunk.
2538 struct sctp_chunk *chunk = arg, *reply; in sctp_sf_do_5_2_6_stale() local
2552 err = (struct sctp_errhdr *)(chunk->skb->data); in sctp_sf_do_5_2_6_stale()
2575 /* Build that new INIT chunk. */ in sctp_sf_do_5_2_6_stale()
2645 * (endpoint, asoc, chunk)
2650 * The return value is the disposition of the chunk.
2660 struct sctp_chunk *chunk = arg; in sctp_sf_do_9_1_abort() local
2662 if (!sctp_vtag_verify_either(chunk, asoc)) in sctp_sf_do_9_1_abort()
2665 /* Make sure that the ABORT chunk has a valid length. in sctp_sf_do_9_1_abort()
2666 * Since this is an ABORT chunk, we have to discard it in sctp_sf_do_9_1_abort()
2675 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_abort_chunk))) 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()
2687 if (!sctp_err_chunk_valid(chunk)) in sctp_sf_do_9_1_abort()
2702 struct sctp_chunk *chunk = arg; in __sctp_sf_do_9_1_abort() local
2705 /* See if we have an error cause code in the chunk. */ in __sctp_sf_do_9_1_abort()
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()
2733 struct sctp_chunk *chunk = arg; in sctp_sf_cookie_wait_abort() local
2736 if (!sctp_vtag_verify_either(chunk, asoc)) in sctp_sf_cookie_wait_abort()
2739 /* Make sure that the ABORT chunk has a valid length. in sctp_sf_cookie_wait_abort()
2740 * Since this is an ABORT chunk, we have to discard it in sctp_sf_cookie_wait_abort()
2749 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_abort_chunk))) in sctp_sf_cookie_wait_abort()
2752 /* See if we have an error cause code in the chunk. */ 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()
2830 * - verify, by checking the Cumulative TSN Ack field of the chunk,
2847 * (endpoint, asoc, chunk)
2852 * The return value is the disposition of the chunk.
2863 struct sctp_chunk *chunk = arg; in sctp_sf_do_9_2_shutdown() local
2868 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_9_2_shutdown()
2871 /* Make sure that the SHUTDOWN chunk has a valid length. */ in sctp_sf_do_9_2_shutdown()
2872 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk))) 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()
2926 * chunk, that all its outstanding DATA chunks have been in sctp_sf_do_9_2_shutdown()
2930 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack)); in sctp_sf_do_9_2_shutdown()
2941 * The Cumulative TSN Ack of the received SHUTDOWN chunk
2952 struct sctp_chunk *chunk = arg; in sctp_sf_do_9_2_shut_ctsn() local
2956 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_9_2_shut_ctsn()
2959 /* Make sure that the SHUTDOWN chunk has a valid length. */ in sctp_sf_do_9_2_shut_ctsn()
2960 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk))) in sctp_sf_do_9_2_shut_ctsn()
2964 sdh = (struct sctp_shutdownhdr *)chunk->skb->data; in sctp_sf_do_9_2_shut_ctsn()
2982 * chunk, that all its outstanding DATA chunks have been in sctp_sf_do_9_2_shut_ctsn()
2992 * If an endpoint is in SHUTDOWN-ACK-SENT state and receives an INIT chunk
2994 * transport addresses (either in the IP addresses or in the INIT chunk)
2995 * that belong to this association, it should discard the INIT chunk and
2996 * retransmit the SHUTDOWN ACK chunk.
3004 struct sctp_chunk *chunk = arg; in __sctp_sf_do_9_2_reshutack() local
3007 /* Make sure that the chunk has a valid length */ in __sctp_sf_do_9_2_reshutack()
3008 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in __sctp_sf_do_9_2_reshutack()
3013 * is no point in verifying chunk boundaries. Just generate in __sctp_sf_do_9_2_reshutack()
3016 reply = sctp_make_shutdown_ack(asoc, chunk); in __sctp_sf_do_9_2_reshutack()
3020 /* Set the transport for the SHUTDOWN ACK chunk and the timeout for in __sctp_sf_do_9_2_reshutack()
3042 struct sctp_chunk *chunk = arg; in sctp_sf_do_9_2_reshutack() local
3044 if (!chunk->singleton) in sctp_sf_do_9_2_reshutack()
3047 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_init_chunk))) in sctp_sf_do_9_2_reshutack()
3050 if (chunk->sctp_hdr->vtag != 0) in sctp_sf_do_9_2_reshutack()
3066 * SCTP the same indication is made by including the CWR chunk.
3067 * This chunk contains one data element, i.e. the TSN number that
3068 * was sent in the ECNE chunk. This element represents the lowest
3074 * (endpoint, asoc, chunk)
3079 * The return value is the disposition of the chunk.
3088 struct sctp_chunk *chunk = arg; in sctp_sf_do_ecn_cwr() local
3092 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_ecn_cwr()
3095 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_ecne_chunk))) 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()
3124 * same indication is made by including the ECNE chunk. This chunk
3130 * (endpoint, asoc, chunk)
3135 * The return value is the disposition of the chunk.
3143 struct sctp_chunk *chunk = arg; in sctp_sf_do_ecne() local
3146 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_ecne()
3149 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_ecne_chunk))) 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()
3167 * DATA chunk.
3172 * (not every second DATA chunk) received, and SHOULD be generated within
3173 * 200 ms of the arrival of any unacknowledged DATA chunk. In some
3186 * (endpoint, asoc, chunk)
3191 * The return value is the disposition of the chunk.
3201 struct sctp_chunk *chunk = arg; in sctp_sf_eat_data_6_2() local
3204 if (!sctp_vtag_verify(chunk, asoc)) { 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()
3214 error = sctp_eat_data(asoc, chunk, commands); 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()
3236 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) in sctp_sf_eat_data_6_2()
3244 /* If this is the last chunk in a packet, we need to count it in sctp_sf_eat_data_6_2()
3247 * THEM. We elect to NOT generate SACK's if the chunk fails in sctp_sf_eat_data_6_2()
3253 * each valid DATA chunk. in sctp_sf_eat_data_6_2()
3258 * least every second packet (not every second DATA chunk) in sctp_sf_eat_data_6_2()
3260 * arrival of any unacknowledged DATA chunk. In some in sctp_sf_eat_data_6_2()
3266 if (chunk->end_of_packet) in sctp_sf_eat_data_6_2()
3274 * When a packet arrives with duplicate DATA chunk(s) and with in sctp_sf_eat_data_6_2()
3275 * no new DATA chunk(s), the endpoint MUST immediately send a in sctp_sf_eat_data_6_2()
3277 * DATA chunk(s) bundled with new DATA chunks, the endpoint in sctp_sf_eat_data_6_2()
3279 * DATA chunks will occur when the original SACK chunk was lost in sctp_sf_eat_data_6_2()
3284 * the last chunk is a duplicate.' 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()
3306 * (endpoint, asoc, chunk)
3311 * The return value is the disposition of the chunk.
3321 struct sctp_chunk *chunk = arg; in sctp_sf_eat_data_fast_4_4() local
3324 if (!sctp_vtag_verify(chunk, asoc)) { 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()
3334 error = sctp_eat_data(asoc, chunk, commands); 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()
3357 * respond to each received packet containing one or more DATA chunk(s) 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()
3361 /* We must delay the chunk creation since the cumulative in sctp_sf_eat_data_fast_4_4()
3388 * reneged on the data), then mark the corresponding DATA chunk
3392 * chunk was originally transmitted, then T3-rtx is started for
3398 * (endpoint, asoc, chunk)
3403 * The return value is the disposition of the chunk.
3412 struct sctp_chunk *chunk = arg; in sctp_sf_eat_sack_6_2() local
3416 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_eat_sack_6_2()
3419 /* Make sure that the SACK chunk has a valid length. */ in sctp_sf_eat_sack_6_2()
3420 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_sack_chunk))) in sctp_sf_eat_sack_6_2()
3424 /* Pull the SACK chunk from the data buffer */ in sctp_sf_eat_sack_6_2()
3425 sackh = sctp_sm_pull_sack(chunk); in sctp_sf_eat_sack_6_2()
3429 chunk->subh.sack_hdr = sackh; in sctp_sf_eat_sack_6_2()
3439 trace_sctp_probe(ep, asoc, chunk); in sctp_sf_eat_sack_6_2()
3455 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_CHUNK(chunk)); in sctp_sf_eat_sack_6_2()
3472 * packet and set the T-bit in the Chunk Flags to indicate that the
3479 * The return value is the disposition of the chunk.
3490 struct sctp_chunk *chunk = arg; in sctp_sf_tabort_8_4_8() local
3493 packet = sctp_ootb_pkt_new(net, asoc, chunk); in sctp_sf_tabort_8_4_8()
3500 abort = sctp_make_abort(asoc, chunk, 0); in sctp_sf_tabort_8_4_8()
3508 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_tabort_8_4_8()
3523 /* Handling of SCTP Packets Containing an INIT Chunk Matching an
3537 struct sctp_chunk *chunk = arg; in sctp_sf_new_encap_port() local
3540 packet = sctp_ootb_pkt_new(net, asoc, chunk); in sctp_sf_new_encap_port()
3544 abort = sctp_make_new_encap_port(asoc, chunk); in sctp_sf_new_encap_port()
3564 * Received an ERROR chunk from peer. Generate SCTP_REMOTE_ERROR
3565 * event as ULP notification for each cause included in the chunk.
3569 * The return value is the disposition of the chunk.
3578 struct sctp_chunk *chunk = arg; in sctp_sf_operr_notify() local
3581 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_operr_notify()
3584 /* Make sure that the ERROR chunk has a valid length. */ in sctp_sf_operr_notify()
3585 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_operr_chunk))) 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()
3594 SCTP_CHUNK(chunk)); in sctp_sf_operr_notify()
3604 * stop the T2-shutdown timer, send a SHUTDOWN COMPLETE chunk to its
3616 struct sctp_chunk *chunk = arg; in sctp_sf_do_9_2_final() local
3620 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_9_2_final()
3623 /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ in sctp_sf_do_9_2_final()
3624 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_do_9_2_final()
3637 /* ...send a SHUTDOWN COMPLETE chunk to its peer, */ in sctp_sf_do_9_2_final()
3638 reply = sctp_make_shutdown_complete(asoc, chunk); in sctp_sf_do_9_2_final()
3675 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should
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
3698 struct sctp_chunk *chunk = arg; in sctp_sf_ootb() local
3699 struct sk_buff *skb = chunk->skb; in sctp_sf_ootb()
3708 if (asoc && !sctp_vtag_verify(chunk, asoc)) in sctp_sf_ootb()
3711 ch = (struct sctp_chunkhdr *)chunk->chunk_hdr; in sctp_sf_ootb()
3713 /* Report violation if the chunk is less then minimal */ in sctp_sf_ootb()
3718 /* Report violation if chunk len overflows */ in sctp_sf_ootb()
3724 /* Now that we know we at least have a chunk header, in sctp_sf_ootb()
3771 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should
3776 * set the T-bit in the Chunk Flags to indicate that the Verification
3785 * The return value is the disposition of the chunk.
3796 struct sctp_chunk *chunk = arg; in sctp_sf_shut_8_4_5() local
3799 packet = sctp_ootb_pkt_new(net, asoc, chunk); in sctp_sf_shut_8_4_5()
3806 shut = sctp_make_shutdown_complete(asoc, chunk); in sctp_sf_shut_8_4_5()
3814 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_shut_8_4_5()
3851 struct sctp_chunk *chunk = arg; in sctp_sf_do_8_5_1_E_sa() local
3853 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_8_5_1_E_sa()
3856 /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ in sctp_sf_do_8_5_1_E_sa()
3857 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_do_8_5_1_E_sa()
3871 /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. */
3881 struct sctp_chunk *chunk = arg; in sctp_sf_do_asconf() local
3885 if (!sctp_vtag_verify(chunk, asoc)) { in sctp_sf_do_asconf()
3891 /* Make sure that the ASCONF ADDIP chunk has a valid length. */ in sctp_sf_do_asconf()
3892 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_addip_chunk))) in sctp_sf_do_asconf()
3897 * This chunk MUST be sent in an authenticated way by using in sctp_sf_do_asconf()
3898 * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk in sctp_sf_do_asconf()
3903 (!net->sctp.addip_noauth && !chunk->auth)) in sctp_sf_do_asconf()
3906 hdr = (struct sctp_addiphdr *)chunk->skb->data; in sctp_sf_do_asconf()
3909 /* Verify the ASCONF chunk before processing it. */ in sctp_sf_do_asconf()
3910 if (!sctp_verify_asconf(asoc, chunk, true, &err_param)) 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()
3934 asoc, chunk); in sctp_sf_do_asconf()
3945 * Chunk exists. This will occur when an older ASCONF in sctp_sf_do_asconf()
3947 * should skip the ASCONF Chunk and not include ASCONF-ACK in sctp_sf_do_asconf()
3948 * Chunk for that chunk. in sctp_sf_do_asconf()
3960 /* ADDIP 5.2 E5) Otherwise, the ASCONF Chunk is discarded since in sctp_sf_do_asconf()
3970 * To do this properly, we'll set the destination address of the chunk in sctp_sf_do_asconf()
3975 asconf_ack->dest = chunk->source; in sctp_sf_do_asconf()
4010 * When building TLV parameters for the ASCONF Chunk that will add or
4033 /* Make sure that the ADDIP chunk has a valid length. */ in sctp_sf_do_asconf_ack()
4040 * This chunk MUST be sent in an authenticated way by using 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()
4052 /* Verify the ASCONF-ACK chunk before processing it. */ in sctp_sf_do_asconf_ack()
4065 * equal to the next serial number to be used but no ASCONF chunk is in sctp_sf_do_asconf_ack()
4127 /* RE-CONFIG Section 5.2 Upon reception of an RECONF Chunk. */
4136 struct sctp_chunk *chunk = arg; in sctp_sf_do_reconf() local
4140 if (!sctp_vtag_verify(chunk, asoc)) { in sctp_sf_do_reconf()
4146 /* Make sure that the RECONF chunk has a valid length. */ in sctp_sf_do_reconf()
4147 if (!sctp_chunk_length_valid(chunk, sizeof(*hdr))) in sctp_sf_do_reconf()
4151 if (!sctp_verify_reconf(asoc, chunk, &err_param)) in sctp_sf_do_reconf()
4155 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_sf_do_reconf()
4194 * When a FORWARD TSN chunk arrives, the data receiver MUST first update
4196 * chunk, and then MUST further advance its cumulative TSN point locally
4203 * The return value is the disposition of the chunk.
4213 struct sctp_chunk *chunk = arg; in sctp_sf_eat_fwd_tsn() local
4217 if (!sctp_vtag_verify(chunk, asoc)) { in sctp_sf_eat_fwd_tsn()
4226 /* Make sure that the FORWARD_TSN chunk has valid length. */ in sctp_sf_eat_fwd_tsn()
4227 if (!sctp_chunk_length_valid(chunk, sctp_ftsnchk_len(&asoc->stream))) 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()
4235 skb_pull(chunk->skb, len); 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()
4246 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn()
4252 SCTP_CHUNK(chunk)); in sctp_sf_eat_fwd_tsn()
4280 struct sctp_chunk *chunk = arg; in sctp_sf_eat_fwd_tsn_fast() local
4284 if (!sctp_vtag_verify(chunk, asoc)) { in sctp_sf_eat_fwd_tsn_fast()
4293 /* Make sure that the FORWARD_TSN chunk has a valid length. */ 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()
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()
4302 skb_pull(chunk->skb, len); 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()
4313 if (!asoc->stream.si->validate_ftsn(chunk)) in sctp_sf_eat_fwd_tsn_fast()
4319 SCTP_CHUNK(chunk)); in sctp_sf_eat_fwd_tsn_fast()
4326 * respond to each received packet containing one or more DATA chunk(s) 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()
4342 * receiver in the HMAC-ALGO parameter in the INIT or INIT-ACK chunk
4343 * during association setup, the AUTH chunk and all chunks after it MUST
4344 * be discarded and an ERROR chunk SHOULD be sent with the error cause
4357 * The return value is the disposition of the chunk.
4361 struct sctp_chunk *chunk) in sctp_sf_authenticate() argument
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()
4376 * chunk. in sctp_sf_authenticate()
4394 sig_len = ntohs(chunk->chunk_hdr->length) - in sctp_sf_authenticate()
4402 * 1. Save the digest from the chunk. in sctp_sf_authenticate()
4403 * 2. Zero out the digest in the chunk. 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()
4440 struct sctp_chunk *chunk = arg; in sctp_sf_eat_auth() local
4449 if (!sctp_vtag_verify(chunk, asoc)) { in sctp_sf_eat_auth()
4455 /* Make sure that the AUTH chunk has valid length. */ in sctp_sf_eat_auth()
4456 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_auth_chunk))) in sctp_sf_eat_auth()
4460 auth_hdr = (struct sctp_authhdr *)chunk->skb->data; in sctp_sf_eat_auth()
4461 error = sctp_sf_authenticate(asoc, chunk); in sctp_sf_eat_auth()
4464 /* Generate the ERROR chunk and discard the rest in sctp_sf_eat_auth()
4467 err_chunk = sctp_make_op_error(asoc, chunk, in sctp_sf_eat_auth()
4508 * Process an unknown chunk.
4512 * Chunk Types are encoded such that the highest-order two bits specify
4514 * recognize the Chunk Type.
4521 * chunk in an 'Unrecognized Chunk Type'.
4523 * 10 - Skip this chunk and continue processing.
4525 * 11 - Skip this chunk and continue processing, but report in an ERROR
4526 * Chunk using the 'Unrecognized Chunk Type' cause of error.
4528 * The return value is the disposition of the chunk.
4541 pr_debug("%s: processing unknown chunk id:%d\n", __func__, type.chunk); in sctp_sf_unk_chunk()
4546 /* Make sure that the chunk has a valid length. in sctp_sf_unk_chunk()
4547 * Since we don't know the chunk type, we use a general in sctp_sf_unk_chunk()
4554 switch (type.chunk & SCTP_CID_ACTION_MASK) { in sctp_sf_unk_chunk()
4559 /* Generate an ERROR chunk as response. */ in sctp_sf_unk_chunk()
4574 /* Skip the chunk. */ in sctp_sf_unk_chunk()
4577 /* Generate an ERROR chunk as response. */ in sctp_sf_unk_chunk()
4587 /* Skip the chunk. */ in sctp_sf_unk_chunk()
4597 * Discard the chunk.
4603 * (endpoint, asoc, chunk)
4608 * The return value is the disposition of the chunk.
4617 struct sctp_chunk *chunk = arg; in sctp_sf_discard_chunk() local
4619 if (asoc && !sctp_vtag_verify(chunk, asoc)) in sctp_sf_discard_chunk()
4622 /* Make sure that the chunk has a valid length. in sctp_sf_discard_chunk()
4623 * Since we don't know the chunk type, we use a general in sctp_sf_discard_chunk()
4626 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_discard_chunk()
4630 pr_debug("%s: chunk:%d is discarded\n", __func__, type.chunk); in sctp_sf_discard_chunk()
4640 * 2) If the OOTB packet contains an ABORT chunk, the receiver MUST
4646 * (endpoint, asoc, chunk)
4651 * The return value is the disposition of the chunk.
4672 * (endpoint, asoc, chunk)
4677 * We simply tag the chunk as a violation. The state machine will log
4687 struct sctp_chunk *chunk = arg; in sctp_sf_violation() local
4689 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_violation()
4692 /* Make sure that the chunk has a valid length. */ in sctp_sf_violation()
4693 if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) in sctp_sf_violation()
4713 struct sctp_chunk *chunk = arg; in sctp_sf_abort_violation() local
4730 /* Make the abort chunk. */ in sctp_sf_abort_violation()
4731 abort = sctp_make_abort_violation(asoc, chunk, payload, paylen); in sctp_sf_abort_violation()
4737 if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && in sctp_sf_abort_violation()
4741 initack = (struct sctp_initack_chunk *)chunk->chunk_hdr; in sctp_sf_abort_violation()
4742 if (!sctp_chunk_length_valid(chunk, sizeof(*initack))) in sctp_sf_abort_violation()
4771 packet = sctp_ootb_pkt_new(net, asoc, chunk); in sctp_sf_abort_violation()
4777 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_sf_abort_violation()
4802 * Handle a protocol violation when the chunk length is invalid.
4804 * given chunk can be. For example, a SACK chunk has invalid length
4813 * (endpoint, asoc, chunk)
4818 * Generate an ABORT chunk and terminate the association.
4828 static const char err_str[] = "The following chunk had invalid length:"; in sctp_sf_violation_chunklen()
4837 * or accumulated length in multi parameters exceeds the end of the chunk,
4850 struct sctp_chunk *chunk = arg; in sctp_sf_violation_paramlen() local
4855 /* Make the abort chunk. */ in sctp_sf_violation_paramlen()
4856 abort = sctp_make_violation_paramlen(asoc, chunk, param); in sctp_sf_violation_paramlen()
4897 /* Handle protocol violation of an invalid chunk bundling. For example,
4911 static const char err_str[] = "The following chunk violates protocol:"; in sctp_sf_violation_chunk()
4995 * A) "A" first sends an INIT chunk to "Z". In the INIT, "A" in sctp_sf_do_prm_asoc()
5065 * chunk before the life time expired.
5167 * will be discarded and an ABORT chunk is sent to the peer. A success code
5486 * chunk to the destination address is successful.
5524 * ADDIP Section 4.1 ASCONF Chunk Procedures
5535 struct sctp_chunk *chunk = arg; in sctp_sf_do_prm_asconf() local
5537 sctp_add_cmd_sf(commands, SCTP_CMD_SETUP_T4, SCTP_CHUNK(chunk)); in sctp_sf_do_prm_asconf()
5540 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(chunk)); in sctp_sf_do_prm_asconf()
5544 /* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5552 struct sctp_chunk *chunk = arg; in sctp_sf_do_prm_reconf() local
5554 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(chunk)); in sctp_sf_do_prm_reconf()
5611 * shall send a SHUTDOWN chunk to its peer including in the Cumulative
5630 * endpoint shall send a SHUTDOWN chunk to its peer including in sctp_sf_do_9_2_start_shutdown()
5638 /* Set the transport for the SHUTDOWN chunk and the timeout for the in sctp_sf_do_9_2_start_shutdown()
5697 struct sctp_chunk *chunk = arg; in sctp_sf_do_9_2_shutdown_ack() local
5701 * 1) called in response to a SHUTDOWN chunk in sctp_sf_do_9_2_shutdown_ack()
5705 * to check that we have a chunk before accessing it's fields. in sctp_sf_do_9_2_shutdown_ack()
5707 if (chunk) { in sctp_sf_do_9_2_shutdown_ack()
5708 if (!sctp_vtag_verify(chunk, asoc)) in sctp_sf_do_9_2_shutdown_ack()
5712 /* Make sure that the SHUTDOWN chunk has a valid length. */ in sctp_sf_do_9_2_shutdown_ack()
5714 chunk, sizeof(struct sctp_shutdown_chunk))) in sctp_sf_do_9_2_shutdown_ack()
5722 reply = sctp_make_shutdown_ack(asoc, chunk); in sctp_sf_do_9_2_shutdown_ack()
5726 /* Set the transport for the SHUTDOWN ACK chunk and the timeout for in sctp_sf_do_9_2_shutdown_ack()
5789 * The return value is the disposition of the chunk.
5872 * (not every second DATA chunk) received, and SHOULD be generated
5873 * within 200 ms of the arrival of any unacknowledged DATA chunk. In
6017 * SHUTDOWN chunk to the protocol parameter 'Association.Max.Retrans'.
6078 /* Set the transport for the SHUTDOWN/ACK chunk and the timeout for in sctp_sf_t2_timer_expire()
6094 * ADDIP Section 4.1 ASCONF Chunk Procedures
6105 struct sctp_chunk *chunk = asoc->addip_last_asconf; in sctp_sf_t4_timer_expire() local
6106 struct sctp_transport *transport = chunk->transport; in sctp_sf_t4_timer_expire()
6119 sctp_add_cmd_sf(commands, SCTP_CMD_SETUP_T4, SCTP_CHUNK(chunk)); in sctp_sf_t4_timer_expire()
6139 * the ASCONF chunk was sent by doubling the RTO timer value. 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()
6146 * chunk, it MUST be the same (including its serial number) as the last in sctp_sf_t4_timer_expire()
6167 * by sending an ABORT chunk.
6246 * (endpoint, asoc, chunk)
6248 * The return value is the disposition of the chunk.
6263 * (endpoint, asoc, chunk)
6265 * The return value is the disposition of the chunk.
6283 * (endpoint, asoc, chunk)
6285 * The return value is the disposition of the chunk.
6294 pr_debug("%s: timer %d ignored\n", __func__, type.chunk); in sctp_sf_timer_ignore()
6303 /* Pull the SACK chunk based on the SACK header. */
6304 static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk) in sctp_sm_pull_sack() argument
6314 sack = (struct sctp_sackhdr *) chunk->skb->data; 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()
6335 struct sctp_chunk *chunk, in sctp_abort_pkt_new() argument
6341 packet = sctp_ootb_pkt_new(net, asoc, chunk); in sctp_abort_pkt_new()
6347 abort = sctp_make_abort(asoc, chunk, paylen); in sctp_abort_pkt_new()
6355 packet->vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_abort_pkt_new()
6358 * end of the chunk. in sctp_abort_pkt_new()
6376 const struct sctp_chunk *chunk) in sctp_ootb_pkt_new() argument
6384 sport = ntohs(chunk->sctp_hdr->dest); in sctp_ootb_pkt_new()
6385 dport = ntohs(chunk->sctp_hdr->source); 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()
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()
6422 vtag = ntohl(chunk->sctp_hdr->vtag); in sctp_ootb_pkt_new()
6428 transport = sctp_transport_new(net, sctp_source(chunk), GFP_ATOMIC); in sctp_ootb_pkt_new()
6432 transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_ootb_pkt_new()
6434 /* Cache a route for the transport with the chunk's destination as in sctp_ootb_pkt_new()
6437 sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, in sctp_ootb_pkt_new()
6456 /* Send a stale cookie error when a invalid COOKIE ECHO chunk is found */
6460 const struct sctp_chunk *chunk, in sctp_send_stale_cookie_err() argument
6467 packet = sctp_ootb_pkt_new(net, asoc, chunk); in sctp_send_stale_cookie_err()
6472 cookie = chunk->subh.cookie_hdr; in sctp_send_stale_cookie_err()
6487 /* Process a data chunk */
6489 struct sctp_chunk *chunk, in sctp_eat_data() argument
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()
6513 * Since the chunk structure is reused for all chunks within in sctp_eat_data()
6518 * chunk later. 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()
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()
6559 /* Even if we don't accept this chunk there is in sctp_eat_data()
6570 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || in sctp_eat_data()
6613 * DATA chunk if a received DATA chunk has no user data. in sctp_eat_data()
6616 err = sctp_make_abort_no_data(asoc, chunk, tsn); in sctp_eat_data()
6634 chunk->data_accepted = 1; in sctp_eat_data()
6637 * if we renege and the chunk arrives again. 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()
6651 * If an endpoint receive a DATA chunk with an invalid stream in sctp_eat_data()
6652 * identifier, it shall acknowledge the reception of the DATA chunk in sctp_eat_data()
6653 * following the normal procedure, immediately send an ERROR chunk in sctp_eat_data()
6655 * and discard the DATA chunk. in sctp_eat_data()
6661 err = sctp_make_op_error(asoc, chunk, SCTP_ERROR_INV_STRM, in sctp_eat_data()
6678 if (!asoc->stream.si->validate_data(chunk)) in sctp_eat_data()
6683 * chunk needs the updated rwnd. in sctp_eat_data()
6685 sctp_add_cmd_sf(commands, deliver, SCTP_CHUNK(chunk)); in sctp_eat_data()