Lines Matching +full:aind +full:-
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.
16 * lksctp developers <linux-sctp@vger.kernel.org>
73 struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg; in sctp_control_release_owner()
75 if (chunk->shkey) { in sctp_control_release_owner()
76 struct sctp_shared_key *shkey = chunk->shkey; in sctp_control_release_owner()
77 struct sctp_association *asoc = chunk->asoc; in sctp_control_release_owner()
83 if (shkey->deactivated && !list_empty(&shkey->key_list) && in sctp_control_release_owner()
84 refcount_read(&shkey->refcnt) == 2) { in sctp_control_release_owner()
87 ev = sctp_ulpevent_make_authkey(asoc, shkey->key_id, in sctp_control_release_owner()
91 asoc->stream.si->enqueue_event(&asoc->ulpq, ev); in sctp_control_release_owner()
93 sctp_auth_shkey_release(chunk->shkey); in sctp_control_release_owner()
99 struct sctp_association *asoc = chunk->asoc; in sctp_control_set_owner_w()
100 struct sk_buff *skb = chunk->skb; in sctp_control_set_owner_w()
109 if (chunk->auth) { in sctp_control_set_owner_w()
110 chunk->shkey = asoc->shkey; in sctp_control_set_owner_w()
111 sctp_auth_shkey_hold(chunk->shkey); in sctp_control_set_owner_w()
113 skb->sk = asoc ? asoc->base.sk : NULL; in sctp_control_set_owner_w()
114 skb_shinfo(skb)->destructor_arg = chunk; in sctp_control_set_owner_w()
115 skb->destructor = sctp_control_release_owner; in sctp_control_set_owner_w()
121 struct sk_buff *skb = chunk->skb; in sctp_chunk_iif()
123 return SCTP_INPUT_CB(skb)->af->skb_iif(skb); in sctp_chunk_iif()
154 if (skb_tailroom(chunk->skb) < len) in sctp_init_cause()
155 return -ENOSPC; in sctp_init_cause()
157 chunk->subh.err_hdr = sctp_addto_chunk(chunk, sizeof(err), &err); in sctp_init_cause()
169 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
171 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
173 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
175 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
179 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
181 * / Optional/Variable-Length Parameters /
183 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190 * ----------------------------------------------
198 * -------------------------------------------------------------
215 struct sctp_endpoint *ep = asoc->ep; in sctp_make_init()
235 init.init_tag = htonl(asoc->c.my_vtag); in sctp_make_init()
236 init.a_rwnd = htonl(asoc->rwnd); in sctp_make_init()
237 init.num_outbound_streams = htons(asoc->c.sinit_num_ostreams); in sctp_make_init()
238 init.num_inbound_streams = htons(asoc->c.sinit_max_instreams); in sctp_make_init()
239 init.initial_tsn = htonl(asoc->c.initial_tsn); in sctp_make_init()
242 sp = sctp_sk(asoc->base.sk); in sctp_make_init()
243 num_types = sp->pf->supported_addrs(sp, types); in sctp_make_init()
248 if (asoc->ep->ecn_enable) in sctp_make_init()
251 if (asoc->ep->prsctp_enable) in sctp_make_init()
256 * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and in sctp_make_init()
257 * INIT-ACK parameters. in sctp_make_init()
259 if (asoc->ep->asconf_enable) { in sctp_make_init()
265 if (asoc->ep->reconf_enable) { in sctp_make_init()
270 if (sp->adaptation_ind) in sctp_make_init()
273 if (asoc->ep->intl_enable) { in sctp_make_init()
281 if (ep->auth_enable) { in sctp_make_init()
283 chunksize += sizeof(asoc->c.auth_random); in sctp_make_init()
286 auth_hmacs = (struct sctp_paramhdr *)asoc->c.auth_hmacs; in sctp_make_init()
287 if (auth_hmacs->length) in sctp_make_init()
288 chunksize += SCTP_PAD4(ntohs(auth_hmacs->length)); in sctp_make_init()
293 auth_chunks = (struct sctp_paramhdr *)asoc->c.auth_chunks; in sctp_make_init()
294 if (auth_chunks->length) in sctp_make_init()
295 chunksize += SCTP_PAD4(ntohs(auth_chunks->length)); in sctp_make_init()
323 retval->subh.init_hdr = in sctp_make_init()
325 retval->param_hdr.v = in sctp_make_init()
340 if (asoc->ep->ecn_enable) in sctp_make_init()
353 if (asoc->ep->prsctp_enable) in sctp_make_init()
356 if (sp->adaptation_ind) { in sctp_make_init()
359 aiparam.adaptation_ind = htonl(sp->adaptation_ind); in sctp_make_init()
363 /* Add SCTP-AUTH chunks to the parameter list */ in sctp_make_init()
364 if (ep->auth_enable) { in sctp_make_init()
365 sctp_addto_chunk(retval, sizeof(asoc->c.auth_random), in sctp_make_init()
366 asoc->c.auth_random); in sctp_make_init()
368 sctp_addto_chunk(retval, ntohs(auth_hmacs->length), in sctp_make_init()
371 sctp_addto_chunk(retval, ntohs(auth_chunks->length), in sctp_make_init()
400 addrs = sctp_bind_addrs_to_raw(&asoc->base.bind_addr, &addrs_len, gfp); in sctp_make_init_ack()
402 initack.init_tag = htonl(asoc->c.my_vtag); in sctp_make_init_ack()
403 initack.a_rwnd = htonl(asoc->rwnd); in sctp_make_init_ack()
404 initack.num_outbound_streams = htons(asoc->c.sinit_num_ostreams); in sctp_make_init_ack()
405 initack.num_inbound_streams = htons(asoc->c.sinit_max_instreams); in sctp_make_init_ack()
406 initack.initial_tsn = htonl(asoc->c.initial_tsn); in sctp_make_init_ack()
411 cookie = sctp_pack_cookie(asoc->ep, asoc, chunk, &cookie_len, in sctp_make_init_ack()
419 sp = sctp_sk(asoc->base.sk); in sctp_make_init_ack()
423 if (asoc->peer.ecn_capable) in sctp_make_init_ack()
426 if (asoc->peer.prsctp_capable) in sctp_make_init_ack()
429 if (asoc->peer.asconf_capable) { in sctp_make_init_ack()
435 if (asoc->peer.reconf_capable) { in sctp_make_init_ack()
440 if (sp->adaptation_ind) in sctp_make_init_ack()
443 if (asoc->peer.intl_capable) { in sctp_make_init_ack()
448 if (asoc->peer.auth_capable) { in sctp_make_init_ack()
449 auth_random = (struct sctp_paramhdr *)asoc->c.auth_random; in sctp_make_init_ack()
450 chunksize += ntohs(auth_random->length); in sctp_make_init_ack()
452 auth_hmacs = (struct sctp_paramhdr *)asoc->c.auth_hmacs; in sctp_make_init_ack()
453 if (auth_hmacs->length) in sctp_make_init_ack()
454 chunksize += SCTP_PAD4(ntohs(auth_hmacs->length)); in sctp_make_init_ack()
458 auth_chunks = (struct sctp_paramhdr *)asoc->c.auth_chunks; in sctp_make_init_ack()
459 if (auth_chunks->length) in sctp_make_init_ack()
460 chunksize += SCTP_PAD4(ntohs(auth_chunks->length)); in sctp_make_init_ack()
476 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_init_ack()
485 if (chunk->transport) in sctp_make_init_ack()
486 retval->transport = in sctp_make_init_ack()
488 &chunk->transport->ipaddr); in sctp_make_init_ack()
490 retval->subh.init_hdr = in sctp_make_init_ack()
492 retval->param_hdr.v = sctp_addto_chunk(retval, addrs_len, addrs.v); in sctp_make_init_ack()
494 if (asoc->peer.ecn_capable) in sctp_make_init_ack()
502 if (asoc->peer.prsctp_capable) in sctp_make_init_ack()
505 if (sp->adaptation_ind) { in sctp_make_init_ack()
508 aiparam.adaptation_ind = htonl(sp->adaptation_ind); in sctp_make_init_ack()
512 if (asoc->peer.auth_capable) { in sctp_make_init_ack()
513 sctp_addto_chunk(retval, ntohs(auth_random->length), in sctp_make_init_ack()
516 sctp_addto_chunk(retval, ntohs(auth_hmacs->length), in sctp_make_init_ack()
519 sctp_addto_chunk(retval, ntohs(auth_chunks->length), in sctp_make_init_ack()
524 retval->asoc = (struct sctp_association *) asoc; in sctp_make_init_ack()
543 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
545 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
548 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
574 cookie = asoc->peer.cookie; in sctp_make_cookie_echo()
575 cookie_len = asoc->peer.cookie_len; in sctp_make_cookie_echo()
582 retval->subh.cookie_hdr = in sctp_make_cookie_echo()
585 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_cookie_echo()
595 retval->transport = chunk->transport; in sctp_make_cookie_echo()
611 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
613 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
626 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_cookie_ack()
635 if (retval && chunk && chunk->transport) in sctp_make_cookie_ack()
636 retval->transport = in sctp_make_cookie_ack()
638 &chunk->transport->ipaddr); in sctp_make_cookie_ack()
658 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
660 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
662 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
680 retval->subh.ecn_cwr_hdr = in sctp_make_cwr()
683 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_cwr()
694 retval->transport = chunk->transport; in sctp_make_cwr()
712 retval->subh.ecne_hdr = in sctp_make_ecne()
733 dp.ppid = sinfo->sinfo_ppid; in sctp_make_datafrag_empty()
734 dp.stream = htons(sinfo->sinfo_stream); in sctp_make_datafrag_empty()
737 if (sinfo->sinfo_flags & SCTP_UNORDERED) in sctp_make_datafrag_empty()
744 retval->subh.data_hdr = sctp_addto_chunk(retval, sizeof(dp), &dp); in sctp_make_datafrag_empty()
745 memcpy(&retval->sinfo, sinfo, sizeof(struct sctp_sndrcvinfo)); in sctp_make_datafrag_empty()
756 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; in sctp_make_sack()
776 sack.a_rwnd = htonl(asoc->a_rwnd); in sctp_make_sack()
789 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_sack()
807 * duplicates. --piggy] in sctp_make_sack()
810 * multi- homed endpoint it MAY be beneficial to vary the in sctp_make_sack()
813 * from a multi-homed endpoint might indicate that the return in sctp_make_sack()
819 retval->transport = asoc->peer.last_data_from; in sctp_make_sack()
821 retval->subh.sack_hdr = in sctp_make_sack()
831 asoc->stats.idupchunks += num_dup_tsns; in sctp_make_sack()
843 if (++asoc->peer.sack_generation == 0) { in sctp_make_sack()
844 list_for_each_entry(trans, &asoc->peer.transport_addr_list, in sctp_make_sack()
846 trans->sack_generation = 0; in sctp_make_sack()
847 asoc->peer.sack_generation = 1; in sctp_make_sack()
861 ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map); in sctp_make_shutdown()
869 retval->subh.shutdown_hdr = in sctp_make_shutdown()
873 retval->transport = chunk->transport; in sctp_make_shutdown()
886 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_shutdown_ack()
896 retval->transport = chunk->transport; in sctp_make_shutdown_ack()
908 /* Set the T-bit if we have no association (vtag will be in sctp_make_shutdown_complete()
916 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_shutdown_complete()
927 retval->transport = chunk->transport; in sctp_make_shutdown_complete()
942 /* Set the T-bit if we have no association and 'chunk' is not in sctp_make_abort()
946 if (chunk && chunk->chunk_hdr && in sctp_make_abort()
947 chunk->chunk_hdr->type == SCTP_CID_INIT) in sctp_make_abort()
956 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_abort()
966 retval->transport = chunk->transport; in sctp_make_abort()
991 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_abort_no_data()
1001 retval->transport = chunk->transport; in sctp_make_abort_no_data()
1055 int chunklen = ntohs(chunk->chunk_hdr->length); in sctp_addto_param()
1058 target = skb_put(chunk->skb, len); in sctp_addto_param()
1066 chunk->chunk_hdr->length = htons(chunklen + len); in sctp_addto_param()
1067 chunk->chunk_end = skb_tail_pointer(chunk->skb); in sctp_addto_param()
1090 phdr.type = htons(chunk->chunk_hdr->type); in sctp_make_abort_violation()
1091 phdr.length = chunk->chunk_hdr->length; in sctp_make_abort_violation()
1153 nep.cur_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_make_new_encap_port()
1154 nep.new_port = chunk->transport->encap_port; in sctp_make_new_encap_port()
1177 hbinfo.daddr = transport->ipaddr; in sctp_make_heartbeat()
1179 hbinfo.hb_nonce = transport->hb_nonce; in sctp_make_heartbeat()
1185 retval->transport = (struct sctp_transport *) transport; in sctp_make_heartbeat()
1186 retval->subh.hbs_hdr = sctp_addto_chunk(retval, sizeof(hbinfo), in sctp_make_heartbeat()
1188 retval->pmtu_probe = !!probe_size; in sctp_make_heartbeat()
1206 retval->subh.hbs_hdr = sctp_addto_chunk(retval, paylen, payload); in sctp_make_heartbeat_ack()
1208 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_heartbeat_ack()
1218 retval->transport = chunk->transport; in sctp_make_heartbeat_ack()
1227 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1229 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1233 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1243 skb_put_zero(retval->skb, len); in sctp_make_pad()
1244 retval->chunk_hdr->length = htons(ntohs(retval->chunk_hdr->length) + len); in sctp_make_pad()
1245 retval->chunk_end = skb_tail_pointer(retval->skb); in sctp_make_pad()
1266 /* RFC 2960 6.4 Multi-homed SCTP Endpoints in sctp_make_op_error_space()
1275 retval->transport = chunk->transport; in sctp_make_op_error_space()
1282 * min(asoc->pathmtu, SCTP_DEFAULT_MAXSEGMENT) - overheads.
1296 size = min_t(size_t, size, asoc->pathmtu); in sctp_make_op_error_limited()
1297 sp = sctp_sk(asoc->base.sk); in sctp_make_op_error_limited()
1339 hmac_desc->hmac_len + sizeof(auth_hdr), in sctp_make_auth()
1344 auth_hdr.hmac_id = htons(hmac_desc->hmac_id); in sctp_make_auth()
1347 retval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(auth_hdr), in sctp_make_auth()
1350 skb_put_zero(retval->skb, hmac_desc->hmac_len); in sctp_make_auth()
1353 retval->chunk_hdr->length = in sctp_make_auth()
1354 htons(ntohs(retval->chunk_hdr->length) + hmac_desc->hmac_len); in sctp_make_auth()
1355 retval->chunk_end = skb_tail_pointer(retval->skb); in sctp_make_auth()
1366 * FIXME: Eventually move the structure directly inside the skb->cb[].
1368 * sctpimpguide-05.txt Section 2.8.2
1388 INIT_LIST_HEAD(&retval->list); in sctp_chunkify()
1389 retval->skb = skb; in sctp_chunkify()
1390 retval->asoc = (struct sctp_association *)asoc; in sctp_chunkify()
1391 retval->singleton = 1; in sctp_chunkify()
1393 retval->fast_retransmit = SCTP_CAN_FRTX; in sctp_chunkify()
1396 INIT_LIST_HEAD(&retval->transmitted_list); in sctp_chunkify()
1397 INIT_LIST_HEAD(&retval->frag_list); in sctp_chunkify()
1399 refcount_set(&retval->refcnt, 1); in sctp_chunkify()
1405 /* Set chunk->source and dest based on the IP header in chunk->skb. */
1409 memcpy(&chunk->source, src, sizeof(union sctp_addr)); in sctp_init_addrs()
1410 memcpy(&chunk->dest, dest, sizeof(union sctp_addr)); in sctp_init_addrs()
1417 if (chunk->transport) { in sctp_source()
1418 return &chunk->transport->ipaddr; in sctp_source()
1421 return &chunk->source; in sctp_source()
1449 chunk_hdr->type = type; in _sctp_make_chunk()
1450 chunk_hdr->flags = flags; in _sctp_make_chunk()
1451 chunk_hdr->length = htons(sizeof(*chunk_hdr)); in _sctp_make_chunk()
1453 sk = asoc ? asoc->base.sk : NULL; in _sctp_make_chunk()
1460 retval->chunk_hdr = chunk_hdr; in _sctp_make_chunk()
1461 retval->chunk_end = ((__u8 *)chunk_hdr) + sizeof(*chunk_hdr); in _sctp_make_chunk()
1465 retval->auth = 1; in _sctp_make_chunk()
1500 BUG_ON(!list_empty(&chunk->list)); in sctp_chunk_destroy()
1501 list_del_init(&chunk->transmitted_list); in sctp_chunk_destroy()
1503 consume_skb(chunk->skb); in sctp_chunk_destroy()
1504 consume_skb(chunk->auth_chunk); in sctp_chunk_destroy()
1514 if (chunk->msg) in sctp_chunk_free()
1515 sctp_datamsg_put(chunk->msg); in sctp_chunk_free()
1523 refcount_inc(&ch->refcnt); in sctp_chunk_hold()
1529 if (refcount_dec_and_test(&ch->refcnt)) in sctp_chunk_put()
1538 int chunklen = ntohs(chunk->chunk_hdr->length); in sctp_addto_chunk()
1539 int padlen = SCTP_PAD4(chunklen) - chunklen; in sctp_addto_chunk()
1542 skb_put_zero(chunk->skb, padlen); in sctp_addto_chunk()
1543 target = skb_put_data(chunk->skb, data, len); in sctp_addto_chunk()
1546 chunk->chunk_hdr->length = htons(chunklen + padlen + len); in sctp_addto_chunk()
1547 chunk->chunk_end = skb_tail_pointer(chunk->skb); in sctp_addto_chunk()
1562 target = skb_put(chunk->skb, len); in sctp_user_addto_chunk()
1566 return -EFAULT; in sctp_user_addto_chunk()
1569 chunk->chunk_hdr->length = in sctp_user_addto_chunk()
1570 htons(ntohs(chunk->chunk_hdr->length) + len); in sctp_user_addto_chunk()
1571 chunk->chunk_end = skb_tail_pointer(chunk->skb); in sctp_user_addto_chunk()
1586 if (chunk->has_ssn) in sctp_chunk_assign_ssn()
1590 sid = ntohs(chunk->subh.data_hdr->stream); in sctp_chunk_assign_ssn()
1591 stream = &chunk->asoc->stream; in sctp_chunk_assign_ssn()
1596 msg = chunk->msg; in sctp_chunk_assign_ssn()
1597 list_for_each_entry(lchunk, &msg->chunks, frag_list) { in sctp_chunk_assign_ssn()
1598 if (lchunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { in sctp_chunk_assign_ssn()
1601 if (lchunk->chunk_hdr->flags & SCTP_DATA_LAST_FRAG) in sctp_chunk_assign_ssn()
1607 lchunk->subh.data_hdr->ssn = htons(ssn); in sctp_chunk_assign_ssn()
1608 lchunk->has_ssn = 1; in sctp_chunk_assign_ssn()
1617 if (!chunk->has_tsn) { in sctp_chunk_assign_tsn()
1621 chunk->subh.data_hdr->tsn = in sctp_chunk_assign_tsn()
1622 htonl(sctp_association_get_next_tsn(chunk->asoc)); in sctp_chunk_assign_tsn()
1623 chunk->has_tsn = 1; in sctp_chunk_assign_tsn()
1638 asoc = sctp_association_new(ep, ep->base.sk, scope, gfp); in sctp_make_temp_asoc()
1641 asoc->temp = 1; in sctp_make_temp_asoc()
1642 skb = chunk->skb; in sctp_make_temp_asoc()
1644 SCTP_INPUT_CB(skb)->af->from_skb(&asoc->c.peer_addr, skb, 1); in sctp_make_temp_asoc()
1668 (sizeof(struct sctp_signed_cookie) - in sctp_pack_cookie()
1671 + ntohs(init_chunk->chunk_hdr->length) + addrs_len; in sctp_pack_cookie()
1678 - (bodysize % SCTP_COOKIE_MULTIPLE); in sctp_pack_cookie()
1688 cookie = (struct sctp_signed_cookie *) retval->body; in sctp_pack_cookie()
1691 retval->p.type = SCTP_PARAM_STATE_COOKIE; in sctp_pack_cookie()
1692 retval->p.length = htons(*cookie_len); in sctp_pack_cookie()
1695 cookie->c = asoc->c; in sctp_pack_cookie()
1697 cookie->c.raw_addr_list_len = addrs_len; in sctp_pack_cookie()
1699 /* Remember PR-SCTP capability. */ in sctp_pack_cookie()
1700 cookie->c.prsctp_capable = asoc->peer.prsctp_capable; in sctp_pack_cookie()
1703 cookie->c.adaptation_ind = asoc->peer.adaptation_ind; in sctp_pack_cookie()
1706 cookie->c.expiration = ktime_add(asoc->cookie_life, in sctp_pack_cookie()
1710 memcpy(cookie + 1, init_chunk->chunk_hdr, in sctp_pack_cookie()
1711 ntohs(init_chunk->chunk_hdr->length)); in sctp_pack_cookie()
1715 ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len); in sctp_pack_cookie()
1717 if (sctp_sk(ep->base.sk)->hmac) { in sctp_pack_cookie()
1718 struct crypto_shash *tfm = sctp_sk(ep->base.sk)->hmac; in sctp_pack_cookie()
1722 err = crypto_shash_setkey(tfm, ep->secret_key, in sctp_pack_cookie()
1723 sizeof(ep->secret_key)) ?: in sctp_pack_cookie()
1724 crypto_shash_tfm_digest(tfm, (u8 *)&cookie->c, bodysize, in sctp_pack_cookie()
1725 cookie->signature); in sctp_pack_cookie()
1749 struct sk_buff *skb = chunk->skb; in sctp_unpack_cookie()
1751 __u8 *digest = ep->digest; in sctp_unpack_cookie()
1760 (sizeof(struct sctp_signed_cookie) - in sctp_unpack_cookie()
1762 bodysize = ntohs(chunk->chunk_hdr->length) - headersize; in sctp_unpack_cookie()
1769 len = ntohs(chunk->chunk_hdr->length); in sctp_unpack_cookie()
1778 cookie = chunk->subh.cookie_hdr; in sctp_unpack_cookie()
1779 bear_cookie = &cookie->c; in sctp_unpack_cookie()
1781 if (!sctp_sk(ep->base.sk)->hmac) in sctp_unpack_cookie()
1786 struct crypto_shash *tfm = sctp_sk(ep->base.sk)->hmac; in sctp_unpack_cookie()
1789 err = crypto_shash_setkey(tfm, ep->secret_key, in sctp_unpack_cookie()
1790 sizeof(ep->secret_key)) ?: in sctp_unpack_cookie()
1794 *error = -SCTP_IERROR_NOMEM; in sctp_unpack_cookie()
1799 if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) { in sctp_unpack_cookie()
1800 *error = -SCTP_IERROR_BAD_SIG; in sctp_unpack_cookie()
1812 if (ntohl(chunk->sctp_hdr->vtag) != bear_cookie->my_vtag) { in sctp_unpack_cookie()
1813 *error = -SCTP_IERROR_BAD_TAG; in sctp_unpack_cookie()
1817 if (chunk->sctp_hdr->source != bear_cookie->peer_addr.v4.sin_port || in sctp_unpack_cookie()
1818 ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) { in sctp_unpack_cookie()
1819 *error = -SCTP_IERROR_BAD_PORTS; in sctp_unpack_cookie()
1831 if (sock_flag(ep->base.sk, SOCK_TIMESTAMP)) in sctp_unpack_cookie()
1836 if (!asoc && ktime_before(bear_cookie->expiration, kt)) { in sctp_unpack_cookie()
1837 suseconds_t usecs = ktime_to_us(ktime_sub(kt, bear_cookie->expiration)); in sctp_unpack_cookie()
1844 * --------------- in sctp_unpack_cookie()
1852 *error = -SCTP_IERROR_STALE_COOKIE; in sctp_unpack_cookie()
1854 *error = -SCTP_IERROR_NOMEM; in sctp_unpack_cookie()
1861 retval = sctp_association_new(ep, ep->base.sk, scope, gfp); in sctp_unpack_cookie()
1863 *error = -SCTP_IERROR_NOMEM; in sctp_unpack_cookie()
1868 retval->peer.port = ntohs(chunk->sctp_hdr->source); in sctp_unpack_cookie()
1871 memcpy(&retval->c, bear_cookie, sizeof(*bear_cookie)); in sctp_unpack_cookie()
1875 *error = -SCTP_IERROR_NOMEM; in sctp_unpack_cookie()
1880 if (list_empty(&retval->base.bind_addr.address_list)) { in sctp_unpack_cookie()
1881 sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest, in sctp_unpack_cookie()
1882 sizeof(chunk->dest), SCTP_ADDR_SRC, in sctp_unpack_cookie()
1886 retval->next_tsn = retval->c.initial_tsn; in sctp_unpack_cookie()
1887 retval->ctsn_ack_point = retval->next_tsn - 1; in sctp_unpack_cookie()
1888 retval->addip_serial = retval->c.initial_tsn; in sctp_unpack_cookie()
1889 retval->strreset_outseq = retval->c.initial_tsn; in sctp_unpack_cookie()
1890 retval->adv_peer_ack_point = retval->ctsn_ack_point; in sctp_unpack_cookie()
1891 retval->peer.prsctp_capable = retval->c.prsctp_capable; in sctp_unpack_cookie()
1892 retval->peer.adaptation_ind = retval->c.adaptation_ind; in sctp_unpack_cookie()
1907 *error = -SCTP_IERROR_MALFORMED; in sctp_unpack_cookie()
1973 /* This is a fatal error. Any accumulated non-fatal errors are in sctp_process_inv_paramlength()
1994 __u16 len = ntohs(param.p->length); in sctp_process_hn_param()
1997 * ABORT. If we've accumulated any non-fatal errors, they in sctp_process_hn_param()
2015 __u16 num_ext = ntohs(param.p->length) - sizeof(struct sctp_paramhdr); in sctp_verify_ext_param()
2021 switch (param.ext->chunks[i]) { in sctp_verify_ext_param()
2032 /* ADD-IP Security: The draft requires us to ABORT or ignore the in sctp_verify_ext_param()
2033 * INIT/INIT-ACK if ADD-IP is listed, but AUTH is not. Do this in sctp_verify_ext_param()
2034 * only if ADD-IP is turned on and we are not backward-compatible in sctp_verify_ext_param()
2037 if (net->sctp.addip_noauth) in sctp_verify_ext_param()
2040 if (ep->asconf_enable && !have_auth && have_asconf) in sctp_verify_ext_param()
2049 __u16 num_ext = ntohs(param.p->length) - sizeof(struct sctp_paramhdr); in sctp_process_ext_param()
2053 switch (param.ext->chunks[i]) { in sctp_process_ext_param()
2055 if (asoc->ep->reconf_enable) in sctp_process_ext_param()
2056 asoc->peer.reconf_capable = 1; in sctp_process_ext_param()
2059 if (asoc->ep->prsctp_enable) in sctp_process_ext_param()
2060 asoc->peer.prsctp_capable = 1; in sctp_process_ext_param()
2066 if (asoc->ep->auth_enable) in sctp_process_ext_param()
2067 asoc->peer.auth_capable = 1; in sctp_process_ext_param()
2071 if (asoc->ep->asconf_enable) in sctp_process_ext_param()
2072 asoc->peer.asconf_capable = 1; in sctp_process_ext_param()
2075 if (asoc->ep->intl_enable) in sctp_process_ext_param()
2076 asoc->peer.intl_capable = 1; in sctp_process_ext_param()
2087 * highest-order two bits specify the action that must be
2091 * 00 - Stop processing this parameter; do not process any further
2094 * 01 - Stop processing this parameter, do not process any further
2098 * 10 - Skip this parameter and continue processing.
2100 * 11 - Skip this parameter and continue processing but
2105 * SCTP_IERROR_NO_ERROR - continue with the chunk
2106 * SCTP_IERROR_ERROR - stop and report an error.
2107 * SCTP_IERROR_NOMEME - out of memory.
2117 switch (param.p->type & SCTP_PARAM_ACTION_MASK) { in sctp_process_unk_param()
2144 ntohs(param.p->length))) in sctp_process_unk_param()
2145 sctp_addto_chunk(*errp, ntohs(param.p->length), in sctp_process_unk_param()
2157 * SCTP_IERROR_ABORT - trigger an ABORT
2158 * SCTP_IERROR_NOMEM - out of memory (abort)
2159 * SCTP_IERROR_ERROR - stop processing, trigger an ERROR
2160 * SCTP_IERROR_NO_ERROR - continue with the chunk
2175 /* FIXME - This routine is not looking at each parameter per the in sctp_verify_param()
2180 switch (param.p->type) { in sctp_verify_param()
2198 if (!ep->asconf_enable) in sctp_verify_param()
2201 if (ntohs(param.p->length) < sizeof(struct sctp_addip_param) + in sctp_verify_param()
2216 if (ep->prsctp_enable) in sctp_verify_param()
2221 if (!ep->auth_enable) in sctp_verify_param()
2224 /* SCTP-AUTH: Secion 6.1 in sctp_verify_param()
2229 if (SCTP_AUTH_RANDOM_LENGTH != ntohs(param.p->length) - in sctp_verify_param()
2238 if (!ep->auth_enable) in sctp_verify_param()
2241 /* SCTP-AUTH: Section 3.2 in sctp_verify_param()
2243 * INIT-ACK chunk if the sender wants to receive authenticated in sctp_verify_param()
2246 if (260 < ntohs(param.p->length)) { in sctp_verify_param()
2254 if (!ep->auth_enable) in sctp_verify_param()
2258 n_elt = (ntohs(param.p->length) - in sctp_verify_param()
2261 /* SCTP-AUTH: Section 6.1 in sctp_verify_param()
2262 * The HMAC algorithm based on SHA-1 MUST be supported and in sctp_verify_param()
2263 * included in the HMAC-ALGO parameter. in sctp_verify_param()
2266 id = ntohs(hmacs->hmac_ids[i]); in sctp_verify_param()
2281 __func__, ntohs(param.p->type), cid); in sctp_verify_param()
2301 * is 0..2**32-1. RFC4960, section 3.3.3. in sctp_verify_init()
2303 if (peer_init->init_hdr.num_outbound_streams == 0 || in sctp_verify_init()
2304 peer_init->init_hdr.num_inbound_streams == 0 || in sctp_verify_init()
2305 peer_init->init_hdr.init_tag == 0 || in sctp_verify_init()
2306 ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW) in sctp_verify_init()
2310 if (param.p->type == SCTP_PARAM_STATE_COOKIE) in sctp_verify_init()
2321 if (param.v != (void *)chunk->chunk_end) in sctp_verify_init()
2325 * the state cookie for an INIT-ACK chunk. in sctp_verify_init()
2376 asoc->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port; in sctp_process_init()
2386 (param.p->type == SCTP_PARAM_IPV4_ADDRESS || in sctp_process_init()
2387 param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { in sctp_process_init()
2388 af = sctp_get_af_specific(param_type2af(param.p->type)); in sctp_process_init()
2389 if (!af->from_addr_param(&addr, param.addr, in sctp_process_init()
2390 chunk->sctp_hdr->source, 0)) in sctp_process_init()
2407 if (asoc->peer.auth_capable && (!asoc->peer.peer_random || in sctp_process_init()
2408 !asoc->peer.peer_hmacs)) in sctp_process_init()
2409 asoc->peer.auth_capable = 0; in sctp_process_init()
2411 /* In a non-backward compatible mode, if the peer claims in sctp_process_init()
2412 * support for ADD-IP but not AUTH, the ADD-IP spec states in sctp_process_init()
2417 if (!asoc->base.net->sctp.addip_noauth && in sctp_process_init()
2418 (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { in sctp_process_init()
2419 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | in sctp_process_init()
2422 asoc->peer.asconf_capable = 0; in sctp_process_init()
2427 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { in sctp_process_init()
2429 if (transport->state == SCTP_UNKNOWN) { in sctp_process_init()
2437 asoc->peer.i.init_tag = in sctp_process_init()
2438 ntohl(peer_init->init_hdr.init_tag); in sctp_process_init()
2439 asoc->peer.i.a_rwnd = in sctp_process_init()
2440 ntohl(peer_init->init_hdr.a_rwnd); in sctp_process_init()
2441 asoc->peer.i.num_outbound_streams = in sctp_process_init()
2442 ntohs(peer_init->init_hdr.num_outbound_streams); in sctp_process_init()
2443 asoc->peer.i.num_inbound_streams = in sctp_process_init()
2444 ntohs(peer_init->init_hdr.num_inbound_streams); in sctp_process_init()
2445 asoc->peer.i.initial_tsn = in sctp_process_init()
2446 ntohl(peer_init->init_hdr.initial_tsn); in sctp_process_init()
2448 asoc->strreset_inseq = asoc->peer.i.initial_tsn; in sctp_process_init()
2453 if (asoc->c.sinit_num_ostreams > in sctp_process_init()
2454 ntohs(peer_init->init_hdr.num_inbound_streams)) { in sctp_process_init()
2455 asoc->c.sinit_num_ostreams = in sctp_process_init()
2456 ntohs(peer_init->init_hdr.num_inbound_streams); in sctp_process_init()
2459 if (asoc->c.sinit_max_instreams > in sctp_process_init()
2460 ntohs(peer_init->init_hdr.num_outbound_streams)) { in sctp_process_init()
2461 asoc->c.sinit_max_instreams = in sctp_process_init()
2462 ntohs(peer_init->init_hdr.num_outbound_streams); in sctp_process_init()
2466 asoc->c.peer_vtag = asoc->peer.i.init_tag; in sctp_process_init()
2469 asoc->peer.rwnd = asoc->peer.i.a_rwnd; in sctp_process_init()
2475 list_for_each_entry(transport, &asoc->peer.transport_addr_list, in sctp_process_init()
2477 transport->ssthresh = asoc->peer.i.a_rwnd; in sctp_process_init()
2481 if (!sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, in sctp_process_init()
2482 asoc->peer.i.initial_tsn, gfp)) in sctp_process_init()
2493 if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams, in sctp_process_init()
2494 asoc->c.sinit_max_instreams, gfp)) in sctp_process_init()
2500 if (!asoc->temp && sctp_assoc_set_id(asoc, gfp)) in sctp_process_init()
2513 asoc->peer.addip_serial = asoc->peer.i.initial_tsn - 1; in sctp_process_init()
2518 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { in sctp_process_init()
2520 if (transport->state != SCTP_ACTIVE) in sctp_process_init()
2545 struct sctp_endpoint *ep = asoc->ep; in sctp_process_param()
2547 struct net *net = asoc->base.net; in sctp_process_param()
2560 switch (param.p->type) { in sctp_process_param()
2562 if (PF_INET6 != asoc->base.sk->sk_family) in sctp_process_param()
2567 /* v4 addresses are not allowed on v6-only socket */ in sctp_process_param()
2568 if (ipv6_only_sock(asoc->base.sk)) in sctp_process_param()
2571 af = sctp_get_af_specific(param_type2af(param.p->type)); in sctp_process_param()
2572 if (!af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0)) in sctp_process_param()
2581 if (!net->sctp.cookie_preserve_enable) in sctp_process_param()
2584 stale = ntohl(param.life->lifespan_increment); in sctp_process_param()
2589 asoc->cookie_life = ktime_add_ms(asoc->cookie_life, stale); in sctp_process_param()
2596 asoc->peer.ipv4_address = 0; in sctp_process_param()
2597 asoc->peer.ipv6_address = 0; in sctp_process_param()
2602 if (peer_addr->sa.sa_family == AF_INET6) in sctp_process_param()
2603 asoc->peer.ipv6_address = 1; in sctp_process_param()
2604 else if (peer_addr->sa.sa_family == AF_INET) in sctp_process_param()
2605 asoc->peer.ipv4_address = 1; in sctp_process_param()
2608 sat = ntohs(param.p->length) - sizeof(struct sctp_paramhdr); in sctp_process_param()
2613 switch (param.sat->types[i]) { in sctp_process_param()
2615 asoc->peer.ipv4_address = 1; in sctp_process_param()
2619 if (PF_INET6 == asoc->base.sk->sk_family) in sctp_process_param()
2620 asoc->peer.ipv6_address = 1; in sctp_process_param()
2630 asoc->peer.cookie_len = in sctp_process_param()
2631 ntohs(param.p->length) - sizeof(struct sctp_paramhdr); in sctp_process_param()
2632 kfree(asoc->peer.cookie); in sctp_process_param()
2633 asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp); in sctp_process_param()
2634 if (!asoc->peer.cookie) in sctp_process_param()
2647 if (asoc->ep->ecn_enable) { in sctp_process_param()
2648 asoc->peer.ecn_capable = 1; in sctp_process_param()
2656 asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind); in sctp_process_param()
2660 if (!ep->asconf_enable) in sctp_process_param()
2665 af = sctp_get_af_specific(param_type2af(addr_param->p.type)); in sctp_process_param()
2669 if (!af->from_addr_param(&addr, addr_param, in sctp_process_param()
2670 htons(asoc->peer.port), 0)) in sctp_process_param()
2673 if (!af->addr_valid(&addr, NULL, NULL)) in sctp_process_param()
2688 if (asoc->ep->prsctp_enable) { in sctp_process_param()
2689 asoc->peer.prsctp_capable = 1; in sctp_process_param()
2696 if (!ep->auth_enable) in sctp_process_param()
2700 kfree(asoc->peer.peer_random); in sctp_process_param()
2701 asoc->peer.peer_random = kmemdup(param.p, in sctp_process_param()
2702 ntohs(param.p->length), gfp); in sctp_process_param()
2703 if (!asoc->peer.peer_random) { in sctp_process_param()
2710 if (!ep->auth_enable) in sctp_process_param()
2714 kfree(asoc->peer.peer_hmacs); in sctp_process_param()
2715 asoc->peer.peer_hmacs = kmemdup(param.p, in sctp_process_param()
2716 ntohs(param.p->length), gfp); in sctp_process_param()
2717 if (!asoc->peer.peer_hmacs) { in sctp_process_param()
2727 if (!ep->auth_enable) in sctp_process_param()
2730 kfree(asoc->peer.peer_chunks); in sctp_process_param()
2731 asoc->peer.peer_chunks = kmemdup(param.p, in sctp_process_param()
2732 ntohs(param.p->length), gfp); in sctp_process_param()
2733 if (!asoc->peer.peer_chunks) in sctp_process_param()
2744 __func__, ntohs(param.p->type), asoc); in sctp_process_param()
2779 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2781 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2783 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2785 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2787 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2791 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2793 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2806 struct sctp_af *af = sctp_get_af_specific(addr->v4.sin_family); in sctp_make_asconf()
2808 addrlen = af->to_addr_param(addr, &addrparam); in sctp_make_asconf()
2819 asconf.serial = htonl(asoc->addip_serial++); in sctp_make_asconf()
2821 retval->subh.addip_hdr = in sctp_make_asconf()
2823 retval->param_hdr.v = in sctp_make_asconf()
2833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2836 * | ASCONF-Request Correlation ID |
2837 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2839 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2844 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2846 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2847 * | ASCONF-Request Correlation ID |
2848 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2850 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2873 af = sctp_get_af_specific(addr->v4.sin_family); in sctp_make_asconf_update_ip()
2874 addr_param_len = af->to_addr_param(addr, &addr_param); in sctp_make_asconf_update_ip()
2879 addr_buf += af->sockaddr_len; in sctp_make_asconf_update_ip()
2880 if (asoc->asconf_addr_del_pending && !del_pickup) { in sctp_make_asconf_update_ip()
2886 pr_debug("%s: picked same-scope del_pending addr, " in sctp_make_asconf_update_ip()
2901 af = sctp_get_af_specific(addr->v4.sin_family); in sctp_make_asconf_update_ip()
2902 addr_param_len = af->to_addr_param(addr, &addr_param); in sctp_make_asconf_update_ip()
2910 addr_buf += af->sockaddr_len; in sctp_make_asconf_update_ip()
2913 addr = asoc->asconf_addr_del_pending; in sctp_make_asconf_update_ip()
2914 af = sctp_get_af_specific(addr->v4.sin_family); in sctp_make_asconf_update_ip()
2915 addr_param_len = af->to_addr_param(addr, &addr_param); in sctp_make_asconf_update_ip()
2930 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2932 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2933 * | ASCONF-Request Correlation ID |
2934 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2936 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2943 struct sctp_af *af = sctp_get_af_specific(addr->v4.sin_family); in sctp_make_asconf_set_prim()
2950 addrlen = af->to_addr_param(addr, &addrparam); in sctp_make_asconf_set_prim()
2970 /* ADDIP 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
2973 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2975 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2977 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2979 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2983 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2985 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3004 retval->subh.addip_hdr = in sctp_make_asconf_ack()
3028 ntohs(asconf_param->param_hdr.length); in sctp_add_asconf_response()
3064 if (asconf_param->param_hdr.type != SCTP_PARAM_ADD_IP && in sctp_process_asconf_param()
3065 asconf_param->param_hdr.type != SCTP_PARAM_DEL_IP && in sctp_process_asconf_param()
3066 asconf_param->param_hdr.type != SCTP_PARAM_SET_PRIMARY) in sctp_process_asconf_param()
3069 switch (addr_param->p.type) { in sctp_process_asconf_param()
3071 if (!asoc->peer.ipv6_address) in sctp_process_asconf_param()
3075 if (!asoc->peer.ipv4_address) in sctp_process_asconf_param()
3082 af = sctp_get_af_specific(param_type2af(addr_param->p.type)); in sctp_process_asconf_param()
3086 if (!af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0)) in sctp_process_asconf_param()
3094 if (!af->is_any(&addr) && !af->addr_valid(&addr, NULL, asconf->skb)) in sctp_process_asconf_param()
3097 switch (asconf_param->param_hdr.type) { in sctp_process_asconf_param()
3103 if (af->is_any(&addr)) in sctp_process_asconf_param()
3104 memcpy(&addr, &asconf->source, sizeof(addr)); in sctp_process_asconf_param()
3106 if (security_sctp_bind_connect(asoc->ep->base.sk, in sctp_process_asconf_param()
3109 af->sockaddr_len)) in sctp_process_asconf_param()
3125 asoc->new_transport = peer; in sctp_process_asconf_param()
3133 if (asoc->peer.transport_count == 1) in sctp_process_asconf_param()
3143 if (sctp_cmp_addr_exact(&asconf->source, &addr)) in sctp_process_asconf_param()
3151 if (af->is_any(&addr)) { in sctp_process_asconf_param()
3152 sctp_assoc_set_primary(asoc, asconf->transport); in sctp_process_asconf_param()
3154 asconf->transport); in sctp_process_asconf_param()
3159 * ASCONF-ACK with Error Cause Indication Parameter in sctp_process_asconf_param()
3175 if (af->is_any(&addr)) in sctp_process_asconf_param()
3178 if (security_sctp_bind_connect(asoc->ep->base.sk, in sctp_process_asconf_param()
3181 af->sockaddr_len)) in sctp_process_asconf_param()
3204 addip = (struct sctp_addip_chunk *)chunk->chunk_hdr; in sctp_verify_asconf()
3206 size_t length = ntohs(param.p->length); in sctp_verify_asconf()
3209 switch (param.p->type) { in sctp_verify_asconf()
3235 length = ntohs(param.addip->param_hdr.length); in sctp_verify_asconf()
3256 if (param.v != chunk->chunk_end) in sctp_verify_asconf()
3278 addip = (struct sctp_addip_chunk *)asconf->chunk_hdr; in sctp_process_asconf()
3279 chunk_len = ntohs(asconf->chunk_hdr->length) - in sctp_process_asconf()
3281 hdr = (struct sctp_addiphdr *)asconf->skb->data; in sctp_process_asconf()
3282 serial = ntohl(hdr->serial); in sctp_process_asconf()
3286 addr_param = (union sctp_addr_param *)(asconf->skb->data + length); in sctp_process_asconf()
3287 chunk_len -= length; in sctp_process_asconf()
3292 length = ntohs(addr_param->p.length); in sctp_process_asconf()
3293 chunk_len -= length; in sctp_process_asconf()
3307 if (param.p->type == SCTP_PARAM_IPV4_ADDRESS || in sctp_process_asconf()
3308 param.p->type == SCTP_PARAM_IPV6_ADDRESS) in sctp_process_asconf()
3323 sctp_add_asconf_response(asconf_ack, param.addip->crr_id, in sctp_process_asconf()
3335 asoc->peer.addip_serial++; in sctp_process_asconf()
3342 list_add_tail(&asconf_ack->transmitted_list, in sctp_process_asconf()
3343 &asoc->asconf_ack_list); in sctp_process_asconf()
3353 struct sctp_bind_addr *bp = &asoc->base.bind_addr; in sctp_asconf_param_success()
3363 af = sctp_get_af_specific(param_type2af(addr_param->p.type)); in sctp_asconf_param_success()
3364 if (!af->from_addr_param(&addr, addr_param, htons(bp->port), 0)) in sctp_asconf_param_success()
3367 switch (asconf_param->param_hdr.type) { in sctp_asconf_param_success()
3373 list_for_each_entry(saddr, &bp->address_list, list) { in sctp_asconf_param_success()
3374 if (sctp_cmp_addr_exact(&saddr->a, &addr)) in sctp_asconf_param_success()
3375 saddr->state = SCTP_ADDR_SRC; in sctp_asconf_param_success()
3378 list_for_each_entry(transport, &asoc->peer.transport_addr_list, in sctp_asconf_param_success()
3386 if (asoc->asconf_addr_del_pending != NULL && in sctp_asconf_param_success()
3387 sctp_cmp_addr_exact(asoc->asconf_addr_del_pending, &addr)) { in sctp_asconf_param_success()
3388 kfree(asoc->asconf_addr_del_pending); in sctp_asconf_param_success()
3389 asoc->asconf_addr_del_pending = NULL; in sctp_asconf_param_success()
3392 list_for_each_entry(transport, &asoc->peer.transport_addr_list, in sctp_asconf_param_success()
3426 asconf_ack_len = ntohs(asconf_ack->chunk_hdr->length) - in sctp_get_asconf_response()
3433 asconf_ack_param = (struct sctp_addip_param *)(asconf_ack->skb->data + in sctp_get_asconf_response()
3435 asconf_ack_len -= length; in sctp_get_asconf_response()
3438 if (asconf_ack_param->crr_id == asconf_param->crr_id) { in sctp_get_asconf_response()
3439 switch (asconf_ack_param->param_hdr.type) { in sctp_get_asconf_response()
3445 asconf_ack_len -= length; in sctp_get_asconf_response()
3447 return err_param->cause; in sctp_get_asconf_response()
3456 length = ntohs(asconf_ack_param->param_hdr.length); in sctp_get_asconf_response()
3458 asconf_ack_len -= length; in sctp_get_asconf_response()
3468 struct sctp_chunk *asconf = asoc->addip_last_asconf; in sctp_process_asconf_ack()
3472 int asconf_len = asconf->skb->len; in sctp_process_asconf_ack()
3482 addr_param = (union sctp_addr_param *)(asconf->skb->data + length); in sctp_process_asconf_ack()
3483 asconf_len -= length; in sctp_process_asconf_ack()
3488 length = ntohs(addr_param->p.length); in sctp_process_asconf_ack()
3490 asconf_len -= length; in sctp_process_asconf_ack()
3497 if (asconf_ack->skb->len == sizeof(struct sctp_addiphdr)) in sctp_process_asconf_ack()
3525 asoc->peer.addip_disabled_mask |= in sctp_process_asconf_ack()
3526 asconf_param->param_hdr.type; in sctp_process_asconf_ack()
3539 length = ntohs(asconf_param->param_hdr.length); in sctp_process_asconf_ack()
3541 asconf_len -= length; in sctp_process_asconf_ack()
3544 if (no_err && asoc->src_out_of_asoc_ok) { in sctp_process_asconf_ack()
3545 asoc->src_out_of_asoc_ok = 0; in sctp_process_asconf_ack()
3546 sctp_transport_immediate_rtx(asoc->peer.primary_path); in sctp_process_asconf_ack()
3550 list_del_init(&asconf->transmitted_list); in sctp_process_asconf_ack()
3552 asoc->addip_last_asconf = NULL; in sctp_process_asconf_ack()
3576 retval->subh.fwdtsn_hdr = in sctp_make_fwdtsn()
3604 retval->subh.ifwdtsn_hdr = in sctp_make_ifwdtsn()
3612 /* RE-CONFIG 3.1 (RE-CONFIG chunk)
3615 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3617 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3619 * / Re-configuration Parameter /
3621 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3623 * / Re-configuration Parameter (optional) /
3625 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3638 reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr; in sctp_make_reconf()
3639 retval->param_hdr.v = (u8 *)(reconf + 1); in sctp_make_reconf()
3644 /* RE-CONFIG 4.1 (STREAM OUT RESET)
3647 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3649 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3650 * | Re-configuration Request Sequence Number |
3651 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3652 * | Re-configuration Response Sequence Number |
3653 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3655 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3657 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3659 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3660 * | Stream Number N-1 (optional) | Stream Number N (optional) |
3661 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3663 * RE-CONFIG 4.2 (STREAM IN RESET)
3666 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3668 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3669 * | Re-configuration Request Sequence Number |
3670 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3672 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3674 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3675 * | Stream Number N-1 (optional) | Stream Number N (optional) |
3676 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3699 outreq.request_seq = htonl(asoc->strreset_outseq); in sctp_make_strreset_req()
3700 outreq.response_seq = htonl(asoc->strreset_inseq - 1); in sctp_make_strreset_req()
3701 outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1); in sctp_make_strreset_req()
3712 inreq.request_seq = htonl(asoc->strreset_outseq + out); in sctp_make_strreset_req()
3723 /* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
3726 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3728 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3729 * | Re-configuration Request Sequence Number |
3730 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3745 tsnreq.request_seq = htonl(asoc->strreset_outseq); in sctp_make_strreset_tsnreq()
3752 /* RE-CONFIG 4.5/4.6 (ADD STREAM)
3755 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3757 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3758 * | Re-configuration Request Sequence Number |
3759 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3761 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3779 addstrm.request_seq = htonl(asoc->strreset_outseq); in sctp_make_strreset_addstrm()
3789 addstrm.request_seq = htonl(asoc->strreset_outseq + !!out); in sctp_make_strreset_addstrm()
3798 /* RE-CONFIG 4.4 (RESP)
3801 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3803 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3804 * | Re-configuration Response Sequence Number |
3805 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3807 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3830 /* RE-CONFIG 4.4 OPTIONAL (TSNRESP)
3833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3836 * | Re-configuration Response Sequence Number |
3837 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3839 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3841 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3843 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
3880 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; in sctp_verify_reconf()
3882 __u16 length = ntohs(param.p->length); in sctp_verify_reconf()
3887 switch (param.p->type) { in sctp_verify_reconf()
3925 last = param.p->type; in sctp_verify_reconf()