Lines Matching defs: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 ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);
864 retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN, 0,
878 struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,
883 retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_ACK, 0, 0,
902 const struct sctp_association *asoc,
911 flags |= asoc ? 0 : SCTP_CHUNK_FLAG_T;
913 retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_COMPLETE, flags,
935 struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc,
945 if (!asoc) {
953 retval = sctp_make_control(asoc, SCTP_CID_ABORT, flags, hint,
973 const struct sctp_association *asoc,
980 retval = sctp_make_abort(asoc, chunk,
1008 struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *asoc,
1016 retval = sctp_make_abort(asoc, NULL,
1074 const struct sctp_association *asoc,
1082 retval = sctp_make_abort(asoc, chunk, sizeof(struct sctp_errhdr) +
1100 const struct sctp_association *asoc,
1109 retval = sctp_make_abort(asoc, chunk, payload_len);
1123 const struct sctp_association *asoc,
1130 retval = sctp_make_abort(asoc, chunk, payload_len);
1141 struct sctp_chunk *sctp_make_new_encap_port(const struct sctp_association *asoc,
1147 retval = sctp_make_abort(asoc, chunk,
1162 struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
1169 retval = sctp_make_control(asoc, SCTP_CID_HEARTBEAT, 0,
1194 struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *asoc,
1201 retval = sctp_make_control(asoc, SCTP_CID_HEARTBEAT_ACK, 0, paylen,
1235 struct sctp_chunk *sctp_make_pad(const struct sctp_association *asoc, int len)
1239 retval = sctp_make_control(asoc, SCTP_CID_PAD, 0, len, GFP_ATOMIC);
1254 const struct sctp_association *asoc,
1260 retval = sctp_make_control(asoc, SCTP_CID_ERROR, 0,
1282 * min(asoc->pathmtu, SCTP_DEFAULT_MAXSEGMENT) - overheads.
1289 const struct sctp_association *asoc,
1295 if (asoc) {
1296 size = min_t(size_t, size, asoc->pathmtu);
1297 sp = sctp_sk(asoc->base.sk);
1302 return sctp_make_op_error_space(asoc, chunk, size);
1306 struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,
1313 retval = sctp_make_op_error_space(asoc, chunk, paylen + reserve_tail);
1326 struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc,
1334 hmac_desc = sctp_auth_asoc_get_hmac(asoc);
1338 retval = sctp_make_control(asoc, SCTP_CID_AUTH, 0,
1376 const struct sctp_association *asoc,
1390 retval->asoc = (struct sctp_association *)asoc;
1428 static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
1453 sk = asoc ? asoc->base.sk : NULL;
1454 retval = sctp_chunkify(skb, asoc, sk, gfp);
1464 if (sctp_auth_send_cid(type, asoc))
1472 static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc,
1475 return _sctp_make_chunk(asoc, SCTP_CID_DATA, flags, paylen, gfp);
1478 struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc,
1481 return _sctp_make_chunk(asoc, SCTP_CID_I_DATA, flags, paylen, gfp);
1484 static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc,
1490 chunk = _sctp_make_chunk(asoc, type, flags, paylen, gfp);
1591 stream = &chunk->asoc->stream;
1622 htonl(sctp_association_get_next_tsn(chunk->asoc));
1632 struct sctp_association *asoc;
1638 asoc = sctp_association_new(ep, ep->base.sk, scope, gfp);
1639 if (!asoc)
1641 asoc->temp = 1;
1644 SCTP_INPUT_CB(skb)->af->from_skb(&asoc->c.peer_addr, skb, 1);
1647 return asoc;
1650 /* Build a cookie representing asoc.
1655 const struct sctp_association *asoc,
1695 cookie->c = asoc->c;
1700 cookie->c.prsctp_capable = asoc->peer.prsctp_capable;
1703 cookie->c.adaptation_ind = asoc->peer.adaptation_ind;
1706 cookie->c.expiration = ktime_add(asoc->cookie_life,
1742 const struct sctp_association *asoc,
1836 if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
1848 *errp = sctp_make_op_error(asoc, chunk,
1923 static int sctp_process_missing_param(const struct sctp_association *asoc,
1937 *errp = sctp_make_op_error_space(asoc, chunk, len);
1952 static int sctp_process_inv_mandatory(const struct sctp_association *asoc,
1959 *errp = sctp_make_op_error_space(asoc, chunk, 0);
1968 static int sctp_process_inv_paramlength(const struct sctp_association *asoc,
1980 *errp = sctp_make_violation_paramlen(asoc, chunk, param);
1989 static int sctp_process_hn_param(const struct sctp_association *asoc,
2004 *errp = sctp_make_op_error(asoc, chunk, SCTP_ERROR_DNS_FAILED,
2046 static void sctp_process_ext_param(struct sctp_association *asoc,
2055 if (asoc->ep->reconf_enable)
2056 asoc->peer.reconf_capable = 1;
2059 if (asoc->ep->prsctp_enable)
2060 asoc->peer.prsctp_capable = 1;
2066 if (asoc->ep->auth_enable)
2067 asoc->peer.auth_capable = 1;
2071 if (asoc->ep->asconf_enable)
2072 asoc->peer.asconf_capable = 1;
2075 if (asoc->ep->intl_enable)
2076 asoc->peer.intl_capable = 1;
2110 const struct sctp_association *asoc,
2131 *errp = sctp_make_op_error_limited(asoc, chunk);
2164 const struct sctp_association *asoc,
2203 sctp_process_inv_paramlength(asoc, param.p,
2211 sctp_process_hn_param(asoc, param, chunk, err_chunk);
2231 sctp_process_inv_paramlength(asoc, param.p,
2247 sctp_process_inv_paramlength(asoc, param.p,
2273 sctp_process_inv_paramlength(asoc, param.p, chunk,
2283 retval = sctp_process_unk_param(asoc, param, chunk, err_chunk);
2291 const struct sctp_association *asoc, enum sctp_cid cid,
2307 return sctp_process_inv_mandatory(asoc, chunk, errp);
2322 return sctp_process_inv_paramlength(asoc, param.p, chunk, errp);
2328 return sctp_process_missing_param(asoc, SCTP_PARAM_STATE_COOKIE,
2333 result = sctp_verify_param(net, ep, asoc, param, cid,
2355 int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
2376 asoc->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
2377 if (!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
2396 if (!sctp_process_param(asoc, param, peer_addr, gfp))
2407 if (asoc->peer.auth_capable && (!asoc->peer.peer_random ||
2408 !asoc->peer.peer_hmacs))
2409 asoc->peer.auth_capable = 0;
2417 if (!asoc->base.net->sctp.addip_noauth &&
2418 (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) {
2419 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP |
2422 asoc->peer.asconf_capable = 0;
2427 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
2430 sctp_assoc_rm_peer(asoc, transport);
2437 asoc->peer.i.init_tag =
2439 asoc->peer.i.a_rwnd =
2441 asoc->peer.i.num_outbound_streams =
2443 asoc->peer.i.num_inbound_streams =
2445 asoc->peer.i.initial_tsn =
2448 asoc->strreset_inseq = asoc->peer.i.initial_tsn;
2453 if (asoc->c.sinit_num_ostreams >
2455 asoc->c.sinit_num_ostreams =
2459 if (asoc->c.sinit_max_instreams >
2461 asoc->c.sinit_max_instreams =
2466 asoc->c.peer_vtag = asoc->peer.i.init_tag;
2469 asoc->peer.rwnd = asoc->peer.i.a_rwnd;
2475 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
2477 transport->ssthresh = asoc->peer.i.a_rwnd;
2481 if (!sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL,
2482 asoc->peer.i.initial_tsn, gfp))
2493 if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams,
2494 asoc->c.sinit_max_instreams, gfp))
2498 sctp_assoc_update_frag_point(asoc);
2500 if (!asoc->temp && sctp_assoc_set_id(asoc, gfp))
2513 asoc->peer.addip_serial = asoc->peer.i.initial_tsn - 1;
2518 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
2521 sctp_assoc_rm_peer(asoc, transport);
2529 /* Update asoc with the option described in param.
2533 * asoc is the association to update.
2540 static int sctp_process_param(struct sctp_association *asoc,
2545 struct sctp_endpoint *ep = asoc->ep;
2547 struct net *net = asoc->base.net;
2562 if (PF_INET6 != asoc->base.sk->sk_family)
2568 if (ipv6_only_sock(asoc->base.sk))
2572 if (!af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0))
2576 if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
2589 asoc->cookie_life = ktime_add_ms(asoc->cookie_life, stale);
2596 asoc->peer.ipv4_address = 0;
2597 asoc->peer.ipv6_address = 0;
2603 asoc->peer.ipv6_address = 1;
2605 asoc->peer.ipv4_address = 1;
2615 asoc->peer.ipv4_address = 1;
2619 if (PF_INET6 == asoc->base.sk->sk_family)
2620 asoc->peer.ipv6_address = 1;
2630 asoc->peer.cookie_len =
2632 kfree(asoc->peer.cookie);
2633 asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp);
2634 if (!asoc->peer.cookie)
2647 if (asoc->ep->ecn_enable) {
2648 asoc->peer.ecn_capable = 1;
2656 asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind);
2670 htons(asoc->peer.port), 0))
2676 t = sctp_assoc_lookup_paddr(asoc, &addr);
2680 sctp_assoc_set_primary(asoc, t);
2684 sctp_process_ext_param(asoc, param);
2688 if (asoc->ep->prsctp_enable) {
2689 asoc->peer.prsctp_capable = 1;
2700 kfree(asoc->peer.peer_random);
2701 asoc->peer.peer_random = kmemdup(param.p,
2703 if (!asoc->peer.peer_random) {
2714 kfree(asoc->peer.peer_hmacs);
2715 asoc->peer.peer_hmacs = kmemdup(param.p,
2717 if (!asoc->peer.peer_hmacs) {
2723 sctp_auth_asoc_set_default_hmac(asoc, param.hmac_algo);
2730 kfree(asoc->peer.peer_chunks);
2731 asoc->peer.peer_chunks = kmemdup(param.p,
2733 if (!asoc->peer.peer_chunks)
2744 __func__, ntohs(param.p->type), asoc);
2797 static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
2814 retval = sctp_make_control(asoc, SCTP_CID_ASCONF, 0, length,
2819 asconf.serial = htonl(asoc->addip_serial++);
2853 struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
2880 if (asoc->asconf_addr_del_pending && !del_pickup) {
2893 retval = sctp_make_asconf(asoc, laddr, totallen);
2913 addr = asoc->asconf_addr_del_pending;
2940 struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
2956 retval = sctp_make_asconf(asoc, addr, len);
2989 static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc,
2997 retval = sctp_make_control(asoc, SCTP_CID_ASCONF_ACK, 0, length,
3053 static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
3071 if (!asoc->peer.ipv6_address)
3075 if (!asoc->peer.ipv4_address)
3086 if (!af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0))
3106 if (security_sctp_bind_connect(asoc->ep->base.sk,
3119 peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
3125 asoc->new_transport = peer;
3133 if (asoc->peer.transport_count == 1)
3152 sctp_assoc_set_primary(asoc, asconf->transport);
3153 sctp_assoc_del_nonprimary_peers(asoc,
3163 peer = sctp_assoc_lookup_paddr(asoc, &addr);
3167 sctp_assoc_rm_peer(asoc, peer);
3178 if (security_sctp_bind_connect(asoc->ep->base.sk,
3184 peer = sctp_assoc_lookup_paddr(asoc, &addr);
3188 sctp_assoc_set_primary(asoc, peer);
3196 bool sctp_verify_asconf(const struct sctp_association *asoc,
3265 struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
3300 asconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 4);
3311 err_code = sctp_process_asconf_param(asoc, asconf,
3335 asoc->peer.addip_serial++;
3343 &asoc->asconf_ack_list);
3350 static void sctp_asconf_param_success(struct sctp_association *asoc,
3353 struct sctp_bind_addr *bp = &asoc->base.bind_addr;
3378 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
3386 if (asoc->asconf_addr_del_pending != NULL &&
3387 sctp_cmp_addr_exact(asoc->asconf_addr_del_pending, &addr)) {
3388 kfree(asoc->asconf_addr_del_pending);
3389 asoc->asconf_addr_del_pending = NULL;
3392 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
3465 int sctp_process_asconf_ack(struct sctp_association *asoc,
3468 struct sctp_chunk *asconf = asoc->addip_last_asconf;
3514 sctp_asconf_param_success(asoc, asconf_param);
3525 asoc->peer.addip_disabled_mask |=
3544 if (no_err && asoc->src_out_of_asoc_ok) {
3545 asoc->src_out_of_asoc_ok = 0;
3546 sctp_transport_immediate_rtx(asoc->peer.primary_path);
3552 asoc->addip_last_asconf = NULL;
3558 struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
3570 retval = sctp_make_control(asoc, SCTP_CID_FWD_TSN, 0, hint, GFP_ATOMIC);
3588 struct sctp_chunk *sctp_make_ifwdtsn(const struct sctp_association *asoc,
3598 retval = sctp_make_control(asoc, SCTP_CID_I_FWD_TSN, 0, hint,
3627 static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc,
3633 retval = sctp_make_control(asoc, SCTP_CID_RECONF, 0, length,
3679 const struct sctp_association *asoc,
3692 retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen));
3699 outreq.request_seq = htonl(asoc->strreset_outseq);
3700 outreq.response_seq = htonl(asoc->strreset_inseq - 1);
3701 outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);
3712 inreq.request_seq = htonl(asoc->strreset_outseq + out);
3733 const struct sctp_association *asoc)
3739 retval = sctp_make_reconf(asoc, length);
3745 tsnreq.request_seq = htonl(asoc->strreset_outseq);
3764 const struct sctp_association *asoc,
3771 retval = sctp_make_reconf(asoc, (!!out + !!in) * size);
3779 addstrm.request_seq = htonl(asoc->strreset_outseq);
3789 addstrm.request_seq = htonl(asoc->strreset_outseq + !!out);
3809 struct sctp_chunk *sctp_make_strreset_resp(const struct sctp_association *asoc,
3816 retval = sctp_make_reconf(asoc, length);
3845 struct sctp_chunk *sctp_make_strreset_tsnresp(struct sctp_association *asoc,
3854 retval = sctp_make_reconf(asoc, length);
3871 bool sctp_verify_reconf(const struct sctp_association *asoc,