Lines Matching refs:asoc
49 static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc,
52 static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc,
54 static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
59 const struct sctp_association *asoc,
63 static int sctp_process_param(struct sctp_association *asoc,
77 struct sctp_association *asoc = chunk->asoc;
87 ev = sctp_ulpevent_make_authkey(asoc, shkey->key_id,
91 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
99 struct sctp_association *asoc = chunk->asoc;
110 chunk->shkey = asoc->shkey;
113 skb->sk = asoc ? asoc->base.sk : NULL;
206 struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
215 struct sctp_endpoint *ep = asoc->ep;
235 init.init_tag = htonl(asoc->c.my_vtag);
236 init.a_rwnd = htonl(asoc->rwnd);
237 init.num_outbound_streams = htons(asoc->c.sinit_num_ostreams);
238 init.num_inbound_streams = htons(asoc->c.sinit_max_instreams);
239 init.initial_tsn = htonl(asoc->c.initial_tsn);
242 sp = sctp_sk(asoc->base.sk);
248 if (asoc->ep->ecn_enable)
251 if (asoc->ep->prsctp_enable)
259 if (asoc->ep->asconf_enable) {
265 if (asoc->ep->reconf_enable) {
273 if (asoc->ep->intl_enable) {
283 chunksize += sizeof(asoc->c.auth_random);
286 auth_hmacs = (struct sctp_paramhdr *)asoc->c.auth_hmacs;
293 auth_chunks = (struct sctp_paramhdr *)asoc->c.auth_chunks;
319 retval = sctp_make_control(asoc, SCTP_CID_INIT, 0, chunksize, gfp);
340 if (asoc->ep->ecn_enable)
353 if (asoc->ep->prsctp_enable)
365 sctp_addto_chunk(retval, sizeof(asoc->c.auth_random),
366 asoc->c.auth_random);
379 struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
400 addrs = sctp_bind_addrs_to_raw(&asoc->base.bind_addr, &addrs_len, gfp);
402 initack.init_tag = htonl(asoc->c.my_vtag);
403 initack.a_rwnd = htonl(asoc->rwnd);
404 initack.num_outbound_streams = htons(asoc->c.sinit_num_ostreams);
405 initack.num_inbound_streams = htons(asoc->c.sinit_max_instreams);
406 initack.initial_tsn = htonl(asoc->c.initial_tsn);
411 cookie = sctp_pack_cookie(asoc->ep, asoc, chunk, &cookie_len,
419 sp = sctp_sk(asoc->base.sk);
423 if (asoc->peer.ecn_capable)
426 if (asoc->peer.prsctp_capable)
429 if (asoc->peer.asconf_capable) {
435 if (asoc->peer.reconf_capable) {
443 if (asoc->peer.intl_capable) {
448 if (asoc->peer.auth_capable) {
449 auth_random = (struct sctp_paramhdr *)asoc->c.auth_random;
452 auth_hmacs = (struct sctp_paramhdr *)asoc->c.auth_hmacs;
458 auth_chunks = (struct sctp_paramhdr *)asoc->c.auth_chunks;
472 retval = sctp_make_control(asoc, SCTP_CID_INIT_ACK, 0, chunksize, gfp);
487 sctp_assoc_lookup_paddr(asoc,
494 if (asoc->peer.ecn_capable)
502 if (asoc->peer.prsctp_capable)
512 if (asoc->peer.auth_capable) {
524 retval->asoc = (struct sctp_association *) asoc;
567 struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *asoc,
574 cookie = asoc->peer.cookie;
575 cookie_len = asoc->peer.cookie_len;
578 retval = sctp_make_control(asoc, SCTP_CID_COOKIE_ECHO, 0,
619 struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
624 retval = sctp_make_control(asoc, SCTP_CID_COOKIE_ACK, 0, 0, GFP_ATOMIC);
637 sctp_assoc_lookup_paddr(asoc,
666 struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc,
674 retval = sctp_make_control(asoc, SCTP_CID_ECN_CWR, 0,
701 struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc,
708 retval = sctp_make_control(asoc, SCTP_CID_ECN_ECNE, 0,
722 struct sctp_chunk *sctp_make_datafrag_empty(const struct sctp_association *asoc,
740 retval = sctp_make_data(asoc, flags, sizeof(dp) + len, gfp);
754 struct sctp_chunk *sctp_make_sack(struct sctp_association *asoc)
756 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map;
776 sack.a_rwnd = htonl(asoc->a_rwnd);
785 retval = sctp_make_control(asoc, SCTP_CID_SACK, 0, len, GFP_ATOMIC);
819 retval->transport = asoc->peer.last_data_from;
831 asoc->stats.idupchunks += num_dup_tsns;
843 if (++asoc->peer.sack_generation == 0) {
844 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
847 asoc->peer.sack_generation = 1;
854 struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc,
861 if (chunk && chunk->asoc)
862 ctsn = sctp_tsnmap_get_ctsn(&chunk->asoc->peer.tsn_map);
864 ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);
868 retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN, 0,
882 struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,
887 retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_ACK, 0, 0,
906 const struct sctp_association *asoc,
915 flags |= asoc ? 0 : SCTP_CHUNK_FLAG_T;
917 retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_COMPLETE, flags,
939 struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc,
949 if (!asoc) {
957 retval = sctp_make_control(asoc, SCTP_CID_ABORT, flags, hint,
977 const struct sctp_association *asoc,
984 retval = sctp_make_abort(asoc, chunk,
1012 struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *asoc,
1020 retval = sctp_make_abort(asoc, NULL,
1078 const struct sctp_association *asoc,
1086 retval = sctp_make_abort(asoc, chunk, sizeof(struct sctp_errhdr) +
1104 const struct sctp_association *asoc,
1113 retval = sctp_make_abort(asoc, chunk, payload_len);
1127 const struct sctp_association *asoc,
1134 retval = sctp_make_abort(asoc, chunk, payload_len);
1146 struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
1152 retval = sctp_make_control(asoc, SCTP_CID_HEARTBEAT, 0,
1175 struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *asoc,
1182 retval = sctp_make_control(asoc, SCTP_CID_HEARTBEAT_ACK, 0, paylen,
1209 const struct sctp_association *asoc,
1215 retval = sctp_make_control(asoc, SCTP_CID_ERROR, 0,
1237 * min(asoc->pathmtu, SCTP_DEFAULT_MAXSEGMENT) - overheads.
1244 const struct sctp_association *asoc,
1250 if (asoc) {
1251 size = min_t(size_t, size, asoc->pathmtu);
1252 sp = sctp_sk(asoc->base.sk);
1257 return sctp_make_op_error_space(asoc, chunk, size);
1261 struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,
1268 retval = sctp_make_op_error_space(asoc, chunk, paylen + reserve_tail);
1281 struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc,
1289 hmac_desc = sctp_auth_asoc_get_hmac(asoc);
1293 retval = sctp_make_control(asoc, SCTP_CID_AUTH, 0,
1331 const struct sctp_association *asoc,
1345 retval->asoc = (struct sctp_association *)asoc;
1383 static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
1408 sk = asoc ? asoc->base.sk : NULL;
1409 retval = sctp_chunkify(skb, asoc, sk, gfp);
1419 if (sctp_auth_send_cid(type, asoc))
1427 static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc,
1430 return _sctp_make_chunk(asoc, SCTP_CID_DATA, flags, paylen, gfp);
1433 struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc,
1436 return _sctp_make_chunk(asoc, SCTP_CID_I_DATA, flags, paylen, gfp);
1439 static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc,
1445 chunk = _sctp_make_chunk(asoc, type, flags, paylen, gfp);
1546 stream = &chunk->asoc->stream;
1577 htonl(sctp_association_get_next_tsn(chunk->asoc));
1587 struct sctp_association *asoc;
1593 asoc = sctp_association_new(ep, ep->base.sk, scope, gfp);
1594 if (!asoc)
1596 asoc->temp = 1;
1599 SCTP_INPUT_CB(skb)->af->from_skb(&asoc->c.peer_addr, skb, 1);
1602 return asoc;
1605 /* Build a cookie representing asoc.
1610 const struct sctp_association *asoc,
1650 cookie->c = asoc->c;
1655 cookie->c.prsctp_capable = asoc->peer.prsctp_capable;
1658 cookie->c.adaptation_ind = asoc->peer.adaptation_ind;
1661 cookie->c.expiration = ktime_add(asoc->cookie_life,
1697 const struct sctp_association *asoc,
1791 if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
1803 *errp = sctp_make_op_error(asoc, chunk,
1878 static int sctp_process_missing_param(const struct sctp_association *asoc,
1892 *errp = sctp_make_op_error_space(asoc, chunk, len);
1907 static int sctp_process_inv_mandatory(const struct sctp_association *asoc,
1914 *errp = sctp_make_op_error_space(asoc, chunk, 0);
1923 static int sctp_process_inv_paramlength(const struct sctp_association *asoc,
1935 *errp = sctp_make_violation_paramlen(asoc, chunk, param);
1944 static int sctp_process_hn_param(const struct sctp_association *asoc,
1959 *errp = sctp_make_op_error(asoc, chunk, SCTP_ERROR_DNS_FAILED,
2001 static void sctp_process_ext_param(struct sctp_association *asoc,
2010 if (asoc->ep->reconf_enable)
2011 asoc->peer.reconf_capable = 1;
2014 if (asoc->ep->prsctp_enable)
2015 asoc->peer.prsctp_capable = 1;
2021 if (asoc->ep->auth_enable)
2022 asoc->peer.auth_capable = 1;
2026 if (asoc->ep->asconf_enable)
2027 asoc->peer.asconf_capable = 1;
2030 if (asoc->ep->intl_enable)
2031 asoc->peer.intl_capable = 1;
2065 const struct sctp_association *asoc,
2086 *errp = sctp_make_op_error_limited(asoc, chunk);
2119 const struct sctp_association *asoc,
2158 sctp_process_inv_paramlength(asoc, param.p,
2166 sctp_process_hn_param(asoc, param, chunk, err_chunk);
2186 sctp_process_inv_paramlength(asoc, param.p,
2202 sctp_process_inv_paramlength(asoc, param.p,
2228 sctp_process_inv_paramlength(asoc, param.p, chunk,
2238 retval = sctp_process_unk_param(asoc, param, chunk, err_chunk);
2246 const struct sctp_association *asoc, enum sctp_cid cid,
2262 return sctp_process_inv_mandatory(asoc, chunk, errp);
2277 return sctp_process_inv_paramlength(asoc, param.p, chunk, errp);
2283 return sctp_process_missing_param(asoc, SCTP_PARAM_STATE_COOKIE,
2288 result = sctp_verify_param(net, ep, asoc, param, cid,
2310 int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
2331 if (!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
2350 if (!sctp_process_param(asoc, param, peer_addr, gfp))
2361 if (asoc->peer.auth_capable && (!asoc->peer.peer_random ||
2362 !asoc->peer.peer_hmacs))
2363 asoc->peer.auth_capable = 0;
2371 if (!asoc->base.net->sctp.addip_noauth &&
2372 (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) {
2373 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP |
2376 asoc->peer.asconf_capable = 0;
2381 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
2384 sctp_assoc_rm_peer(asoc, transport);
2391 asoc->peer.i.init_tag =
2393 asoc->peer.i.a_rwnd =
2395 asoc->peer.i.num_outbound_streams =
2397 asoc->peer.i.num_inbound_streams =
2399 asoc->peer.i.initial_tsn =
2402 asoc->strreset_inseq = asoc->peer.i.initial_tsn;
2407 if (asoc->c.sinit_num_ostreams >
2409 asoc->c.sinit_num_ostreams =
2413 if (asoc->c.sinit_max_instreams >
2415 asoc->c.sinit_max_instreams =
2420 asoc->c.peer_vtag = asoc->peer.i.init_tag;
2423 asoc->peer.rwnd = asoc->peer.i.a_rwnd;
2429 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
2431 transport->ssthresh = asoc->peer.i.a_rwnd;
2435 if (!sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL,
2436 asoc->peer.i.initial_tsn, gfp))
2447 if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams,
2448 asoc->c.sinit_max_instreams, gfp))
2452 sctp_assoc_update_frag_point(asoc);
2454 if (!asoc->temp && sctp_assoc_set_id(asoc, gfp))
2467 asoc->peer.addip_serial = asoc->peer.i.initial_tsn - 1;
2472 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
2475 sctp_assoc_rm_peer(asoc, transport);
2483 /* Update asoc with the option described in param.
2487 * asoc is the association to update.
2494 static int sctp_process_param(struct sctp_association *asoc,
2499 struct sctp_endpoint *ep = asoc->ep;
2501 struct net *net = asoc->base.net;
2516 if (PF_INET6 != asoc->base.sk->sk_family)
2522 if (ipv6_only_sock(asoc->base.sk))
2526 if (!af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0))
2530 if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
2543 asoc->cookie_life = ktime_add_ms(asoc->cookie_life, stale);
2554 asoc->peer.ipv4_address = 0;
2555 asoc->peer.ipv6_address = 0;
2561 asoc->peer.ipv6_address = 1;
2563 asoc->peer.ipv4_address = 1;
2573 asoc->peer.ipv4_address = 1;
2577 if (PF_INET6 == asoc->base.sk->sk_family)
2578 asoc->peer.ipv6_address = 1;
2582 asoc->peer.hostname_address = 1;
2592 asoc->peer.cookie_len =
2594 kfree(asoc->peer.cookie);
2595 asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp);
2596 if (!asoc->peer.cookie)
2609 if (asoc->ep->ecn_enable) {
2610 asoc->peer.ecn_capable = 1;
2618 asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind);
2632 htons(asoc->peer.port), 0))
2638 t = sctp_assoc_lookup_paddr(asoc, &addr);
2642 sctp_assoc_set_primary(asoc, t);
2646 sctp_process_ext_param(asoc, param);
2650 if (asoc->ep->prsctp_enable) {
2651 asoc->peer.prsctp_capable = 1;
2662 kfree(asoc->peer.peer_random);
2663 asoc->peer.peer_random = kmemdup(param.p,
2665 if (!asoc->peer.peer_random) {
2676 kfree(asoc->peer.peer_hmacs);
2677 asoc->peer.peer_hmacs = kmemdup(param.p,
2679 if (!asoc->peer.peer_hmacs) {
2685 sctp_auth_asoc_set_default_hmac(asoc, param.hmac_algo);
2692 kfree(asoc->peer.peer_chunks);
2693 asoc->peer.peer_chunks = kmemdup(param.p,
2695 if (!asoc->peer.peer_chunks)
2706 __func__, ntohs(param.p->type), asoc);
2759 static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
2776 retval = sctp_make_control(asoc, SCTP_CID_ASCONF, 0, length,
2781 asconf.serial = htonl(asoc->addip_serial++);
2815 struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
2842 if (asoc->asconf_addr_del_pending && !del_pickup) {
2855 retval = sctp_make_asconf(asoc, laddr, totallen);
2875 addr = asoc->asconf_addr_del_pending;
2902 struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
2918 retval = sctp_make_asconf(asoc, addr, len);
2951 static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc,
2959 retval = sctp_make_control(asoc, SCTP_CID_ASCONF_ACK, 0, length,
3015 static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
3033 if (!asoc->peer.ipv6_address)
3037 if (!asoc->peer.ipv4_address)
3048 if (!af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0))
3068 if (security_sctp_bind_connect(asoc->ep->base.sk,
3081 peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
3087 asoc->new_transport = peer;
3095 if (asoc->peer.transport_count == 1)
3114 sctp_assoc_set_primary(asoc, asconf->transport);
3115 sctp_assoc_del_nonprimary_peers(asoc,
3125 peer = sctp_assoc_lookup_paddr(asoc, &addr);
3129 sctp_assoc_rm_peer(asoc, peer);
3140 if (security_sctp_bind_connect(asoc->ep->base.sk,
3146 peer = sctp_assoc_lookup_paddr(asoc, &addr);
3150 sctp_assoc_set_primary(asoc, peer);
3158 bool sctp_verify_asconf(const struct sctp_association *asoc,
3227 struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
3262 asconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 4);
3273 err_code = sctp_process_asconf_param(asoc, asconf,
3297 asoc->peer.addip_serial++;
3305 &asoc->asconf_ack_list);
3312 static void sctp_asconf_param_success(struct sctp_association *asoc,
3315 struct sctp_bind_addr *bp = &asoc->base.bind_addr;
3340 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
3348 if (asoc->asconf_addr_del_pending != NULL &&
3349 sctp_cmp_addr_exact(asoc->asconf_addr_del_pending, &addr)) {
3350 kfree(asoc->asconf_addr_del_pending);
3351 asoc->asconf_addr_del_pending = NULL;
3354 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
3427 int sctp_process_asconf_ack(struct sctp_association *asoc,
3430 struct sctp_chunk *asconf = asoc->addip_last_asconf;
3476 sctp_asconf_param_success(asoc, asconf_param);
3487 asoc->peer.addip_disabled_mask |=
3506 if (no_err && asoc->src_out_of_asoc_ok) {
3507 asoc->src_out_of_asoc_ok = 0;
3508 sctp_transport_immediate_rtx(asoc->peer.primary_path);
3514 asoc->addip_last_asconf = NULL;
3520 struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
3532 retval = sctp_make_control(asoc, SCTP_CID_FWD_TSN, 0, hint, GFP_ATOMIC);
3550 struct sctp_chunk *sctp_make_ifwdtsn(const struct sctp_association *asoc,
3560 retval = sctp_make_control(asoc, SCTP_CID_I_FWD_TSN, 0, hint,
3589 static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc,
3595 retval = sctp_make_control(asoc, SCTP_CID_RECONF, 0, length,
3641 const struct sctp_association *asoc,
3654 retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen));
3661 outreq.request_seq = htonl(asoc->strreset_outseq);
3662 outreq.response_seq = htonl(asoc->strreset_inseq - 1);
3663 outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);
3674 inreq.request_seq = htonl(asoc->strreset_outseq + out);
3695 const struct sctp_association *asoc)
3701 retval = sctp_make_reconf(asoc, length);
3707 tsnreq.request_seq = htonl(asoc->strreset_outseq);
3726 const struct sctp_association *asoc,
3733 retval = sctp_make_reconf(asoc, (!!out + !!in) * size);
3741 addstrm.request_seq = htonl(asoc->strreset_outseq);
3751 addstrm.request_seq = htonl(asoc->strreset_outseq + !!out);
3771 struct sctp_chunk *sctp_make_strreset_resp(const struct sctp_association *asoc,
3778 retval = sctp_make_reconf(asoc, length);
3807 struct sctp_chunk *sctp_make_strreset_tsnresp(struct sctp_association *asoc,
3816 retval = sctp_make_reconf(asoc, length);
3833 bool sctp_verify_reconf(const struct sctp_association *asoc,