Lines Matching refs:asoc
74 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
87 static int sctp_send_asconf(struct sctp_association *asoc,
107 static inline int sctp_wspace(struct sctp_association *asoc)
109 struct sock *sk = asoc->base.sk;
111 return asoc->ep->sndbuf_policy ? sk->sk_sndbuf - asoc->sndbuf_used
126 struct sctp_association *asoc = chunk->asoc;
127 struct sock *sk = asoc->base.sk;
130 sctp_association_hold(asoc);
142 asoc->sndbuf_used += chunk->skb->truesize + sizeof(struct sctp_chunk);
158 if ((clear && asoc->base.sk == c->skb->sk) || \
159 (!clear && asoc->base.sk != c->skb->sk)) \
165 static void sctp_for_each_tx_datachunk(struct sctp_association *asoc,
171 struct sctp_outq *q = &asoc->outqueue;
175 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports)
192 static void sctp_for_each_rx_skb(struct sctp_association *asoc, struct sock *sk,
198 sctp_skb_for_each(skb, &asoc->ulpq.lobby, tmp)
201 sctp_skb_for_each(skb, &asoc->ulpq.reasm, tmp)
204 sctp_skb_for_each(skb, &asoc->ulpq.reasm_uo, tmp)
234 struct sctp_association *asoc = NULL;
247 asoc = list_entry(sctp_sk(sk)->ep->asocs.next,
249 return asoc;
257 asoc = (struct sctp_association *)idr_find(&sctp_assocs_id, (int)id);
258 if (asoc && (asoc->base.sk != sk || asoc->base.dead))
259 asoc = NULL;
262 return asoc;
467 static int sctp_send_asconf(struct sctp_association *asoc,
475 if (asoc->addip_last_asconf) {
476 list_add_tail(&chunk->list, &asoc->addip_chunk_list);
482 retval = sctp_primitive_ASCONF(asoc->base.net, asoc, chunk);
486 asoc->addip_last_asconf = chunk;
560 struct sctp_association *asoc;
581 list_for_each_entry(asoc, &ep->asocs, asocs) {
582 if (!asoc->peer.asconf_capable)
585 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_ADD_IP)
588 if (!sctp_state(asoc, ESTABLISHED))
605 if (sctp_assoc_lookup_laddr(asoc, addr))
616 bp = &asoc->base.bind_addr;
619 chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs,
639 if (asoc->src_out_of_asoc_ok) {
643 &asoc->peer.transport_addr_list, transports) {
644 trans->cwnd = min(4*asoc->pathmtu, max_t(__u32,
645 2*asoc->pathmtu, 4380));
646 trans->ssthresh = asoc->peer.i.a_rwnd;
647 trans->rto = asoc->rto_initial;
648 sctp_max_rto(asoc, trans);
652 sctp_sk(asoc->base.sk));
655 retval = sctp_send_asconf(asoc, chunk);
762 struct sctp_association *asoc;
784 list_for_each_entry(asoc, &ep->asocs, asocs) {
786 if (!asoc->peer.asconf_capable)
789 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_DEL_IP)
792 if (!sctp_state(asoc, ESTABLISHED))
809 if (!sctp_assoc_lookup_laddr(asoc, laddr))
822 bp = &asoc->base.bind_addr;
826 if (asoc->asconf_addr_del_pending)
828 asoc->asconf_addr_del_pending =
830 if (asoc->asconf_addr_del_pending == NULL) {
834 asoc->asconf_addr_del_pending->sa.sa_family =
836 asoc->asconf_addr_del_pending->v4.sin_port =
842 asoc->asconf_addr_del_pending->v4.sin_addr.s_addr = sin->sin_addr.s_addr;
847 asoc->asconf_addr_del_pending->v6.sin6_addr = sin6->sin6_addr;
850 pr_debug("%s: keep the last address asoc:%p %pISc at %p\n",
851 __func__, asoc, &asoc->asconf_addr_del_pending->sa,
852 asoc->asconf_addr_del_pending);
854 asoc->src_out_of_asoc_ok = 1;
866 chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt,
892 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
895 sctp_sk(asoc->base.sk));
901 retval = sctp_send_asconf(asoc, chunk);
1071 struct sctp_association *asoc;
1090 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
1091 if (!asoc)
1094 err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, GFP_KERNEL);
1098 *tp = sctp_assoc_add_peer(asoc, daddr, GFP_KERNEL, SCTP_UNKNOWN);
1110 asoc->c.sinit_num_ostreams = outcnt;
1112 err = sctp_stream_init(&asoc->stream, outcnt, 0, GFP_KERNEL);
1118 asoc->c.sinit_max_instreams = init->sinit_max_instreams;
1121 asoc->max_init_attempts = init->sinit_max_attempts;
1124 asoc->max_init_timeo =
1129 sctp_association_free(asoc);
1133 static int sctp_connect_add_peer(struct sctp_association *asoc,
1136 struct sctp_endpoint *ep = asoc->ep;
1146 if (old && old != asoc)
1153 t = sctp_assoc_add_peer(asoc, daddr, GFP_KERNEL, SCTP_UNKNOWN);
1171 struct sctp_association *asoc;
1191 asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
1192 if (asoc)
1193 return asoc->state >= SCTP_STATE_ESTABLISHED ? -EISCONN
1199 asoc = transport->asoc;
1213 if (asoc->peer.port != ntohs(daddr->v4.sin_port))
1216 err = sctp_connect_add_peer(asoc, daddr, af->sockaddr_len);
1228 err = sctp_assoc_set_id(asoc, GFP_KERNEL);
1233 err = sctp_primitive_ASSOCIATE(sock_net(sk), asoc, NULL);
1238 inet_sk(sk)->inet_dport = htons(asoc->peer.port);
1243 *assoc_id = asoc->assoc_id;
1246 return sctp_wait_for_connect(asoc, &timeo);
1249 pr_debug("%s: took out_free path with asoc:%p kaddrs:%p err:%d\n",
1250 __func__, asoc, kaddrs, err);
1251 sctp_association_free(asoc);
1259 * sctp_assoc_t *asoc);
1486 struct sctp_association *asoc;
1504 asoc = list_entry(pos, struct sctp_association, asocs);
1512 if (sctp_state(asoc, CLOSED)) {
1513 sctp_association_free(asoc);
1518 if (data_was_unread || !skb_queue_empty(&asoc->ulpq.lobby) ||
1519 !skb_queue_empty(&asoc->ulpq.reasm) ||
1520 !skb_queue_empty(&asoc->ulpq.reasm_uo) ||
1524 chunk = sctp_make_abort_user(asoc, NULL, 0);
1525 sctp_primitive_ABORT(net, asoc, chunk);
1527 sctp_primitive_SHUTDOWN(net, asoc, NULL);
1662 struct sctp_association *asoc;
1695 asoc = (*tp)->asoc;
1724 daddr->v4.sin_port = htons(asoc->peer.port);
1735 daddr->v6.sin6_port = htons(asoc->peer.port);
1739 err = sctp_connect_add_peer(asoc, daddr, sizeof(*daddr));
1747 sctp_association_free(asoc);
1751 static int sctp_sendmsg_check_sflags(struct sctp_association *asoc,
1755 struct sock *sk = asoc->base.sk;
1758 if (sctp_state(asoc, CLOSED) && sctp_style(sk, TCP))
1762 !sctp_state(asoc, ESTABLISHED))
1766 pr_debug("%s: shutting down association:%p\n", __func__, asoc);
1767 sctp_primitive_SHUTDOWN(net, asoc, NULL);
1775 chunk = sctp_make_abort_user(asoc, msg, msg_len);
1779 pr_debug("%s: aborting association:%p\n", __func__, asoc);
1780 sctp_primitive_ABORT(net, asoc, chunk);
1789 static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1794 struct sock *sk = asoc->base.sk;
1803 if (sinfo->sinfo_stream >= asoc->stream.outcnt) {
1808 if (unlikely(!SCTP_SO(&asoc->stream, sinfo->sinfo_stream)->ext)) {
1809 err = sctp_stream_init_ext(&asoc->stream, sinfo->sinfo_stream);
1814 if (sp->disable_fragments && msg_len > asoc->frag_point) {
1819 if (asoc->pmtu_pending) {
1821 sctp_assoc_sync_pmtu(asoc);
1822 asoc->pmtu_pending = 0;
1825 if (sctp_wspace(asoc) < (int)msg_len)
1826 sctp_prsctp_prune(asoc, sinfo, msg_len - sctp_wspace(asoc));
1828 if (sctp_wspace(asoc) <= 0 || !sk_wmem_schedule(sk, msg_len)) {
1830 err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
1833 if (unlikely(sinfo->sinfo_stream >= asoc->stream.outcnt)) {
1839 if (sctp_state(asoc, CLOSED)) {
1840 err = sctp_primitive_ASSOCIATE(net, asoc, NULL);
1844 if (asoc->ep->intl_enable) {
1846 err = sctp_wait_for_connect(asoc, &timeo);
1858 datamsg = sctp_datamsg_from_user(asoc, sinfo, &msg->msg_iter);
1864 asoc->force_delay = !!(msg->msg_flags & MSG_MORE);
1872 err = sctp_primitive_SEND(net, asoc, datamsg);
1884 sctp_wait_for_connect(asoc, &timeo);
1916 static void sctp_sendmsg_update_sinfo(struct sctp_association *asoc,
1921 sinfo->sinfo_stream = asoc->default_stream;
1922 sinfo->sinfo_ppid = asoc->default_ppid;
1923 sinfo->sinfo_context = asoc->default_context;
1924 sinfo->sinfo_assoc_id = sctp_assoc2id(asoc);
1927 sinfo->sinfo_flags = asoc->default_flags;
1931 sinfo->sinfo_timetolive = asoc->default_timetolive;
1947 struct sctp_association *asoc, *tmp;
1973 list_for_each_entry_safe(asoc, tmp, &ep->asocs, asocs) {
1974 err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
1981 sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);
1983 err = sctp_sendmsg_to_asoc(asoc, msg, msg_len,
1994 /* Get and check or create asoc */
1996 asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
1997 if (asoc) {
1998 err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
2008 asoc = transport->asoc;
2015 asoc = sctp_id2assoc(sk, sinfo->sinfo_assoc_id);
2016 if (!asoc) {
2021 err = sctp_sendmsg_check_sflags(asoc, sflags, msg, msg_len);
2026 /* Update snd_info with the asoc */
2027 sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);
2029 /* Send msg to the asoc */
2030 err = sctp_sendmsg_to_asoc(asoc, msg, msg_len, transport, sinfo);
2032 sctp_association_free(asoc);
2177 sctp_assoc_rwnd_increase(event->asoc, copied);
2223 struct sctp_association *asoc;
2233 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
2234 asoc->subscribe = sctp_sk(sk)->subscribe;
2243 asoc = sctp_id2assoc(sk, 0);
2244 if (asoc && sctp_outq_is_empty(&asoc->outqueue)) {
2245 event = sctp_ulpevent_make_sender_dry_event(asoc,
2250 asoc->stream.si->enqueue_event(&asoc->ulpq, event);
2427 struct sctp_association *asoc,
2436 error = sctp_primitive_REQUESTHEARTBEAT(trans->asoc->base.net,
2437 trans->asoc, trans);
2461 } else if (asoc) {
2462 asoc->hbinterval =
2474 } else if (asoc) {
2475 asoc->param_flags =
2476 (asoc->param_flags & ~SPP_HB) | hb_change;
2491 sctp_assoc_sync_pmtu(asoc);
2492 } else if (asoc) {
2493 sctp_assoc_set_pmtu(asoc, params->spp_pathmtu);
2507 sctp_assoc_sync_pmtu(asoc);
2510 } else if (asoc) {
2511 asoc->param_flags =
2512 (asoc->param_flags & ~SPP_PMTUD) | pmtud_change;
2527 } else if (asoc) {
2528 asoc->sackdelay =
2540 } else if (asoc) {
2541 asoc->param_flags =
2542 (asoc->param_flags & ~SPP_SACKDELAY) |
2557 } else if (asoc) {
2558 asoc->pathmaxrxt = params->spp_pathmaxrxt;
2571 } else if (asoc) {
2574 list_for_each_entry(t, &asoc->peer.transport_addr_list,
2582 asoc->flowlabel = params->spp_ipv6_flowlabel &
2584 asoc->flowlabel |= SCTP_FLOWLABEL_SET_MASK;
2596 } else if (asoc) {
2599 list_for_each_entry(t, &asoc->peer.transport_addr_list,
2605 asoc->dscp = params->spp_dscp & SCTP_DSCP_VAL_MASK;
2606 asoc->dscp |= SCTP_DSCP_SET_MASK;
2621 struct sctp_association *asoc = NULL;
2661 asoc = sctp_id2assoc(sk, params->spp_assoc_id);
2662 if (!asoc && params->spp_assoc_id != SCTP_FUTURE_ASSOC &&
2669 if (params->spp_flags & SPP_HB_DEMAND && !trans && !asoc)
2673 error = sctp_apply_peer_addr_params(params, trans, asoc, sp,
2683 if (!trans && asoc) {
2684 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2686 sctp_apply_peer_addr_params(params, trans, asoc, sp,
2706 struct sctp_association *asoc)
2711 asoc->sackdelay = msecs_to_jiffies(params->sack_delay);
2712 asoc->param_flags =
2713 sctp_spp_sackdelay_enable(asoc->param_flags);
2716 asoc->param_flags =
2717 sctp_spp_sackdelay_disable(asoc->param_flags);
2719 asoc->sackfreq = params->sack_freq;
2720 asoc->param_flags =
2721 sctp_spp_sackdelay_enable(asoc->param_flags);
2724 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2781 struct sctp_association *asoc;
2791 asoc = sctp_id2assoc(sk, params->sack_assoc_id);
2792 if (!asoc && params->sack_assoc_id > SCTP_ALL_ASSOC &&
2796 if (asoc) {
2797 sctp_apply_asoc_delayed_ack(params, asoc);
2824 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
2825 sctp_apply_asoc_delayed_ack(params, asoc);
2907 struct sctp_association *asoc;
2916 asoc = sctp_id2assoc(sk, info->sinfo_assoc_id);
2917 if (!asoc && info->sinfo_assoc_id > SCTP_ALL_ASSOC &&
2921 if (asoc) {
2922 asoc->default_stream = info->sinfo_stream;
2923 asoc->default_flags = info->sinfo_flags;
2924 asoc->default_ppid = info->sinfo_ppid;
2925 asoc->default_context = info->sinfo_context;
2926 asoc->default_timetolive = info->sinfo_timetolive;
2945 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
2946 asoc->default_stream = info->sinfo_stream;
2947 asoc->default_flags = info->sinfo_flags;
2948 asoc->default_ppid = info->sinfo_ppid;
2949 asoc->default_context = info->sinfo_context;
2950 asoc->default_timetolive = info->sinfo_timetolive;
2965 struct sctp_association *asoc;
2974 asoc = sctp_id2assoc(sk, info->snd_assoc_id);
2975 if (!asoc && info->snd_assoc_id > SCTP_ALL_ASSOC &&
2979 if (asoc) {
2980 asoc->default_stream = info->snd_sid;
2981 asoc->default_flags = info->snd_flags;
2982 asoc->default_ppid = info->snd_ppid;
2983 asoc->default_context = info->snd_context;
3001 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
3002 asoc->default_stream = info->snd_sid;
3003 asoc->default_flags = info->snd_flags;
3004 asoc->default_ppid = info->snd_ppid;
3005 asoc->default_context = info->snd_context;
3043 sctp_assoc_set_primary(trans->asoc, trans);
3081 struct sctp_association *asoc;
3088 asoc = sctp_id2assoc(sk, rtoinfo->srto_assoc_id);
3091 if (!asoc && rtoinfo->srto_assoc_id != SCTP_FUTURE_ASSOC &&
3099 rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max;
3101 rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max;
3104 rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min;
3106 rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min;
3111 if (asoc) {
3113 asoc->rto_initial =
3115 asoc->rto_max = rto_max;
3116 asoc->rto_min = rto_min;
3146 struct sctp_association *asoc;
3151 asoc = sctp_id2assoc(sk, assocparams->sasoc_assoc_id);
3153 if (!asoc && assocparams->sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
3158 if (asoc) {
3164 list_for_each_entry(peer_addr, &asoc->peer.transport_addr_list,
3179 asoc->max_retrans = assocparams->sasoc_asocmaxrxt;
3183 asoc->cookie_life =
3256 struct sctp_association *asoc;
3275 asoc = sctp_id2assoc(sk, assoc_id);
3276 if (!asoc && assoc_id != SCTP_FUTURE_ASSOC &&
3282 __u16 datasize = asoc ? sctp_datachk_len(&asoc->stream) :
3292 if (asoc) {
3293 asoc->user_frag = val;
3294 sctp_assoc_update_frag_point(asoc);
3316 struct sctp_association *asoc = NULL;
3329 asoc = sctp_id2assoc(sk, prim->sspp_assoc_id);
3330 if (!asoc)
3333 if (!asoc->peer.asconf_capable)
3336 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_SET_PRIMARY)
3339 if (!sctp_state(asoc, ESTABLISHED))
3349 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim->sspp_addr))
3360 chunk = sctp_make_asconf_set_prim(asoc,
3365 err = sctp_send_asconf(asoc, chunk);
3403 struct sctp_association *asoc;
3408 asoc = sctp_id2assoc(sk, params->assoc_id);
3409 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
3413 if (asoc) {
3414 asoc->default_rcv_context = params->assoc_value;
3428 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
3429 asoc->default_rcv_context = params->assoc_value;
3522 struct sctp_association *asoc;
3540 asoc = sctp_id2assoc(sk, assoc_id);
3541 if (!asoc && assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP))
3544 if (asoc) {
3545 asoc->max_burst = assoc_value;
3557 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
3558 asoc->max_burst = assoc_value;
3634 struct sctp_association *asoc;
3647 asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
3648 if (!asoc && authkey->sca_assoc_id > SCTP_ALL_ASSOC &&
3652 if (asoc) {
3653 ret = sctp_auth_set_key(ep, asoc, authkey);
3662 ret = sctp_auth_set_key(ep, asoc, authkey);
3671 list_for_each_entry(asoc, &ep->asocs, asocs) {
3672 int res = sctp_auth_set_key(ep, asoc, authkey);
3695 struct sctp_association *asoc;
3701 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3702 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3706 if (asoc)
3707 return sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
3714 ret = sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
3721 list_for_each_entry(asoc, &ep->asocs, asocs) {
3722 int res = sctp_auth_set_active_key(ep, asoc,
3743 struct sctp_association *asoc;
3749 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3750 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3754 if (asoc)
3755 return sctp_auth_del_key_id(ep, asoc, val->scact_keynumber);
3762 ret = sctp_auth_del_key_id(ep, asoc, val->scact_keynumber);
3769 list_for_each_entry(asoc, &ep->asocs, asocs) {
3770 int res = sctp_auth_del_key_id(ep, asoc,
3791 struct sctp_association *asoc;
3797 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3798 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3802 if (asoc)
3803 return sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber);
3810 ret = sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber);
3817 list_for_each_entry(asoc, &ep->asocs, asocs) {
3818 int res = sctp_auth_deact_key_id(ep, asoc,
3880 struct sctp_association *asoc;
3905 asoc = sctp_id2assoc(sk, val->spt_assoc_id);
3906 if (!asoc && val->spt_assoc_id != SCTP_FUTURE_ASSOC &&
3910 if (asoc) {
3911 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
3921 asoc->pathmaxrxt = val->spt_pathmaxrxt;
3923 asoc->ps_retrans = val->spt_pathcpthld;
3924 asoc->pf_retrans = val->spt_pathpfthld;
3964 struct sctp_association *asoc;
3969 asoc = sctp_id2assoc(sk, params->assoc_id);
3970 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
3984 struct sctp_association *asoc;
3996 asoc = sctp_id2assoc(sk, info->pr_assoc_id);
3997 if (!asoc && info->pr_assoc_id > SCTP_ALL_ASSOC &&
4003 if (asoc) {
4004 SCTP_PR_SET_POLICY(asoc->default_flags, info->pr_policy);
4005 asoc->default_timetolive = info->pr_value;
4020 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4021 SCTP_PR_SET_POLICY(asoc->default_flags,
4023 asoc->default_timetolive = info->pr_value;
4035 struct sctp_association *asoc;
4041 asoc = sctp_id2assoc(sk, params->assoc_id);
4042 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4059 struct sctp_association *asoc;
4068 asoc = sctp_id2assoc(sk, params->assoc_id);
4069 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
4075 if (asoc) {
4076 asoc->strreset_enable = params->assoc_value;
4089 list_for_each_entry(asoc, &ep->asocs, asocs)
4090 asoc->strreset_enable = params->assoc_value;
4100 struct sctp_association *asoc;
4112 asoc = sctp_id2assoc(sk, params->srs_assoc_id);
4113 if (!asoc)
4116 return sctp_send_reset_streams(asoc, params);
4122 struct sctp_association *asoc;
4127 asoc = sctp_id2assoc(sk, *associd);
4128 if (!asoc)
4131 return sctp_send_reset_assoc(asoc);
4138 struct sctp_association *asoc;
4143 asoc = sctp_id2assoc(sk, params->sas_assoc_id);
4144 if (!asoc)
4147 return sctp_send_add_streams(asoc, params);
4155 struct sctp_association *asoc;
4164 asoc = sctp_id2assoc(sk, params->assoc_id);
4165 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
4169 if (asoc)
4170 return sctp_sched_set_sched(asoc, params->assoc_value);
4181 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4182 int ret = sctp_sched_set_sched(asoc,
4197 struct sctp_association *asoc;
4203 asoc = sctp_id2assoc(sk, params->assoc_id);
4204 if (!asoc && params->assoc_id != SCTP_CURRENT_ASSOC &&
4208 if (asoc) {
4209 retval = sctp_sched_set_value(asoc, params->stream_id,
4216 list_for_each_entry(asoc, &sctp_sk(sk)->ep->asocs, asocs) {
4217 int ret = sctp_sched_set_value(asoc, params->stream_id,
4233 struct sctp_association *asoc;
4238 asoc = sctp_id2assoc(sk, p->assoc_id);
4239 if (!asoc && p->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP))
4268 struct sctp_association *asoc)
4272 sctp_ulpevent_type_set(&asoc->subscribe, param->se_type, param->se_on);
4275 if (sctp_outq_is_empty(&asoc->outqueue)) {
4276 event = sctp_ulpevent_make_sender_dry_event(asoc,
4281 asoc->stream.si->enqueue_event(&asoc->ulpq, event);
4292 struct sctp_association *asoc;
4302 asoc = sctp_id2assoc(sk, param->se_assoc_id);
4303 if (!asoc && param->se_assoc_id > SCTP_ALL_ASSOC &&
4307 if (asoc)
4308 return sctp_assoc_ulpevent_type_set(param, asoc);
4320 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4321 int ret = sctp_assoc_ulpevent_type_set(param, asoc);
4335 struct sctp_association *asoc;
4342 asoc = sctp_id2assoc(sk, params->assoc_id);
4343 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4365 struct sctp_association *asoc;
4372 asoc = sctp_id2assoc(sk, params->assoc_id);
4373 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4399 struct sctp_association *asoc;
4405 asoc = sctp_id2assoc(sk, params->assoc_id);
4406 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4421 struct sctp_association *asoc;
4430 asoc = sctp_id2assoc(sk, params->assoc_id);
4431 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4435 if (asoc)
4436 asoc->pf_expose = params->assoc_value;
4449 struct sctp_association *asoc;
4474 asoc = sctp_id2assoc(sk, encap->sue_assoc_id);
4475 if (!asoc && encap->sue_assoc_id != SCTP_FUTURE_ASSOC &&
4482 if (asoc) {
4483 list_for_each_entry(t, &asoc->peer.transport_addr_list,
4487 asoc->encap_port = encap_port;
4499 struct sctp_association *asoc;
4528 asoc = sctp_id2assoc(sk, params->spi_assoc_id);
4529 if (!asoc && params->spi_assoc_id != SCTP_FUTURE_ASSOC &&
4536 if (asoc) {
4537 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
4542 asoc->probe_interval = msecs_to_jiffies(probe_interval);
4854 struct sctp_association *asoc;
4882 asoc = list_entry(ep->asocs.next, struct sctp_association, asocs);
4884 newsk = sp->pf->create_accept_sk(sk, asoc, kern);
4891 * asoc to the newsk.
4893 error = sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP);
5154 struct sctp_association *asoc;
5157 asoc = list_entry(ep->asocs.next,
5159 sctp_primitive_SHUTDOWN(net, asoc, NULL);
5163 int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc,
5171 if (!asoc) {
5186 info->sctpi_tag = asoc->c.my_vtag;
5187 info->sctpi_state = asoc->state;
5188 info->sctpi_rwnd = asoc->a_rwnd;
5189 info->sctpi_unackdata = asoc->unack_data;
5190 info->sctpi_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map);
5191 info->sctpi_instrms = asoc->stream.incnt;
5192 info->sctpi_outstrms = asoc->stream.outcnt;
5193 list_for_each(pos, &asoc->base.inqueue.in_chunk_list)
5195 list_for_each(pos, &asoc->outqueue.out_chunk_list)
5197 info->sctpi_overall_error = asoc->overall_error_count;
5198 info->sctpi_max_burst = asoc->max_burst;
5199 info->sctpi_maxseg = asoc->frag_point;
5200 info->sctpi_peer_rwnd = asoc->peer.rwnd;
5201 info->sctpi_peer_tag = asoc->c.peer_vtag;
5203 mask = asoc->peer.intl_capable << 1;
5204 mask = (mask | asoc->peer.ecn_capable) << 1;
5205 mask = (mask | asoc->peer.ipv4_address) << 1;
5206 mask = (mask | asoc->peer.ipv6_address) << 1;
5207 mask = (mask | asoc->peer.reconf_capable) << 1;
5208 mask = (mask | asoc->peer.asconf_capable) << 1;
5209 mask = (mask | asoc->peer.prsctp_capable) << 1;
5210 mask = (mask | asoc->peer.auth_capable);
5212 mask = asoc->peer.sack_needed << 1;
5213 mask = (mask | asoc->peer.sack_generation) << 1;
5214 mask = (mask | asoc->peer.zero_window_announced);
5217 info->sctpi_isacks = asoc->stats.isacks;
5218 info->sctpi_osacks = asoc->stats.osacks;
5219 info->sctpi_opackets = asoc->stats.opackets;
5220 info->sctpi_ipackets = asoc->stats.ipackets;
5221 info->sctpi_rtxchunks = asoc->stats.rtxchunks;
5222 info->sctpi_outofseqtsns = asoc->stats.outofseqtsns;
5223 info->sctpi_idupchunks = asoc->stats.idupchunks;
5224 info->sctpi_gapcnt = asoc->stats.gapcnt;
5225 info->sctpi_ouodchunks = asoc->stats.ouodchunks;
5226 info->sctpi_iuodchunks = asoc->stats.iuodchunks;
5227 info->sctpi_oodchunks = asoc->stats.oodchunks;
5228 info->sctpi_iodchunks = asoc->stats.iodchunks;
5229 info->sctpi_octrlchunks = asoc->stats.octrlchunks;
5230 info->sctpi_ictrlchunks = asoc->stats.ictrlchunks;
5232 prim = asoc->peer.primary_path;
5280 if (net_eq(t->asoc->base.net, net) &&
5281 t->asoc->peer.primary_path == t)
5344 ep = transport->asoc->ep;
5345 if (!sctp_endpoint_hold(ep)) { /* asoc can be peeled off */
5373 ep = tsp->asoc->ep;
5374 if (sctp_endpoint_hold(ep)) { /* asoc can be peeled off */
5412 struct sctp_association *asoc = NULL;
5429 asoc = sctp_id2assoc(sk, associd);
5430 if (!asoc) {
5435 transport = asoc->peer.primary_path;
5437 status.sstat_assoc_id = sctp_assoc2id(asoc);
5438 status.sstat_state = sctp_assoc_to_state(asoc);
5439 status.sstat_rwnd = asoc->peer.rwnd;
5440 status.sstat_unackdata = asoc->unack_data;
5442 status.sstat_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map);
5443 status.sstat_instrms = asoc->stream.incnt;
5444 status.sstat_outstrms = asoc->stream.outcnt;
5445 status.sstat_fragmentation_point = asoc->frag_point;
5446 status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
5514 transport->asoc->pf_expose == SCTP_PF_EXPOSE_DISABLE) {
5519 pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
5625 struct sctp_association *asoc = sctp_id2assoc(sk, id);
5634 if (!asoc)
5648 sctp_copy_sock(sock->sk, sk, asoc);
5654 sp->pf->to_sk_daddr(&asoc->peer.primary_addr, sock->sk);
5658 * asoc to the newsk.
5660 err = sctp_sock_migrate(sk, sock->sk, asoc,
5914 struct sctp_association *asoc = NULL;
5945 asoc = sctp_id2assoc(sk, params.spp_assoc_id);
5946 if (!asoc && params.spp_assoc_id != SCTP_FUTURE_ASSOC &&
5970 } else if (asoc) {
5972 params.spp_hbinterval = jiffies_to_msecs(asoc->hbinterval);
5973 params.spp_pathmtu = asoc->pathmtu;
5974 params.spp_pathmaxrxt = asoc->pathmaxrxt;
5975 params.spp_sackdelay = jiffies_to_msecs(asoc->sackdelay);
5978 params.spp_flags = asoc->param_flags;
5979 if (asoc->flowlabel & SCTP_FLOWLABEL_SET_MASK) {
5980 params.spp_ipv6_flowlabel = asoc->flowlabel &
5984 if (asoc->dscp & SCTP_DSCP_SET_MASK) {
5985 params.spp_dscp = asoc->dscp & SCTP_DSCP_VAL_MASK;
6057 struct sctp_association *asoc = NULL;
6080 asoc = sctp_id2assoc(sk, params.sack_assoc_id);
6081 if (!asoc && params.sack_assoc_id != SCTP_FUTURE_ASSOC &&
6085 if (asoc) {
6087 if (asoc->param_flags & SPP_SACKDELAY_ENABLE) {
6088 params.sack_delay = jiffies_to_msecs(asoc->sackdelay);
6089 params.sack_freq = asoc->sackfreq;
6142 struct sctp_association *asoc;
6160 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
6161 if (!asoc)
6167 list_for_each_entry(from, &asoc->peer.transport_addr_list,
6239 struct sctp_association *asoc;
6268 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
6269 if (!asoc)
6271 bp = &asoc->base.bind_addr;
6347 struct sctp_association *asoc;
6358 asoc = sctp_id2assoc(sk, prim.ssp_assoc_id);
6359 if (!asoc)
6362 if (!asoc->peer.primary_path)
6365 memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr,
6366 asoc->peer.primary_path->af_specific->sockaddr_len);
6429 struct sctp_association *asoc;
6440 asoc = sctp_id2assoc(sk, info.sinfo_assoc_id);
6441 if (!asoc && info.sinfo_assoc_id != SCTP_FUTURE_ASSOC &&
6445 if (asoc) {
6446 info.sinfo_stream = asoc->default_stream;
6447 info.sinfo_flags = asoc->default_flags;
6448 info.sinfo_ppid = asoc->default_ppid;
6449 info.sinfo_context = asoc->default_context;
6450 info.sinfo_timetolive = asoc->default_timetolive;
6475 struct sctp_association *asoc;
6486 asoc = sctp_id2assoc(sk, info.snd_assoc_id);
6487 if (!asoc && info.snd_assoc_id != SCTP_FUTURE_ASSOC &&
6491 if (asoc) {
6492 info.snd_sid = asoc->default_stream;
6493 info.snd_flags = asoc->default_flags;
6494 info.snd_ppid = asoc->default_ppid;
6495 info.snd_context = asoc->default_context;
6554 struct sctp_association *asoc;
6564 asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id);
6566 if (!asoc && rtoinfo.srto_assoc_id != SCTP_FUTURE_ASSOC &&
6571 if (asoc) {
6572 rtoinfo.srto_initial = jiffies_to_msecs(asoc->rto_initial);
6573 rtoinfo.srto_max = jiffies_to_msecs(asoc->rto_max);
6574 rtoinfo.srto_min = jiffies_to_msecs(asoc->rto_min);
6610 struct sctp_association *asoc;
6622 asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id);
6624 if (!asoc && assocparams.sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
6629 if (asoc) {
6630 assocparams.sasoc_asocmaxrxt = asoc->max_retrans;
6631 assocparams.sasoc_peer_rwnd = asoc->peer.rwnd;
6632 assocparams.sasoc_local_rwnd = asoc->a_rwnd;
6633 assocparams.sasoc_cookie_life = ktime_to_ms(asoc->cookie_life);
6635 list_for_each(pos, &asoc->peer.transport_addr_list) {
6700 struct sctp_association *asoc;
6710 asoc = sctp_id2assoc(sk, params.assoc_id);
6711 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6715 params.assoc_value = asoc ? asoc->default_rcv_context
6757 struct sctp_association *asoc;
6773 asoc = sctp_id2assoc(sk, params.assoc_id);
6774 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6778 if (asoc)
6779 params.assoc_value = asoc->frag_point;
6852 struct sctp_association *asoc;
6868 asoc = sctp_id2assoc(sk, params.assoc_id);
6869 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6873 params.assoc_value = asoc ? asoc->max_burst : sctp_sk(sk)->max_burst;
6928 struct sctp_association *asoc;
6937 asoc = sctp_id2assoc(sk, val.scact_assoc_id);
6938 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP))
6941 if (asoc) {
6942 if (!asoc->peer.auth_capable)
6944 val.scact_keynumber = asoc->active_key_id;
6964 struct sctp_association *asoc;
6976 asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
6977 if (!asoc)
6980 if (!asoc->peer.auth_capable)
6983 ch = asoc->peer.peer_chunks;
7009 struct sctp_association *asoc;
7021 asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
7022 if (!asoc && val.gauth_assoc_id != SCTP_FUTURE_ASSOC &&
7026 if (asoc) {
7027 if (!asoc->peer.auth_capable)
7029 ch = (struct sctp_chunks_param *)asoc->c.auth_chunks;
7063 struct sctp_association *asoc;
7074 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7119 struct sctp_association *asoc;
7129 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7144 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7145 ids->gaids_assoc_id[num++] = asoc->assoc_id;
7170 struct sctp_association *asoc;
7193 asoc = sctp_id2assoc(sk, val.spt_assoc_id);
7194 if (!asoc && val.spt_assoc_id != SCTP_FUTURE_ASSOC &&
7198 if (asoc) {
7199 val.spt_pathpfthld = asoc->pf_retrans;
7200 val.spt_pathmaxrxt = asoc->pathmaxrxt;
7201 val.spt_pathcpthld = asoc->ps_retrans;
7228 struct sctp_association *asoc = NULL;
7240 asoc = sctp_id2assoc(sk, sas.sas_assoc_id);
7241 if (!asoc)
7244 sas.sas_rtxchunks = asoc->stats.rtxchunks;
7245 sas.sas_gapcnt = asoc->stats.gapcnt;
7246 sas.sas_outofseqtsns = asoc->stats.outofseqtsns;
7247 sas.sas_osacks = asoc->stats.osacks;
7248 sas.sas_isacks = asoc->stats.isacks;
7249 sas.sas_octrlchunks = asoc->stats.octrlchunks;
7250 sas.sas_ictrlchunks = asoc->stats.ictrlchunks;
7251 sas.sas_oodchunks = asoc->stats.oodchunks;
7252 sas.sas_iodchunks = asoc->stats.iodchunks;
7253 sas.sas_ouodchunks = asoc->stats.ouodchunks;
7254 sas.sas_iuodchunks = asoc->stats.iuodchunks;
7255 sas.sas_idupchunks = asoc->stats.idupchunks;
7256 sas.sas_opackets = asoc->stats.opackets;
7257 sas.sas_ipackets = asoc->stats.ipackets;
7263 sas.sas_maxrto = asoc->stats.max_obs_rto;
7264 memcpy(&sas.sas_obs_rto_ipaddr, &asoc->stats.obs_rto_ipaddr,
7268 asoc->stats.max_obs_rto = asoc->rto_min;
7326 struct sctp_association *asoc;
7338 asoc = sctp_id2assoc(sk, params.assoc_id);
7339 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7345 params.assoc_value = asoc ? asoc->peer.prsctp_capable
7365 struct sctp_association *asoc;
7377 asoc = sctp_id2assoc(sk, info.pr_assoc_id);
7378 if (!asoc && info.pr_assoc_id != SCTP_FUTURE_ASSOC &&
7384 if (asoc) {
7385 info.pr_policy = SCTP_PR_POLICY(asoc->default_flags);
7386 info.pr_value = asoc->default_timetolive;
7411 struct sctp_association *asoc;
7429 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7430 if (!asoc)
7438 asoc->abandoned_unsent[policy];
7440 asoc->abandoned_sent[policy];
7444 asoc->abandoned_unsent[__SCTP_PR_INDEX(policy)];
7446 asoc->abandoned_sent[__SCTP_PR_INDEX(policy)];
7470 struct sctp_association *asoc;
7489 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7490 if (!asoc || params.sprstat_sid >= asoc->stream.outcnt)
7493 streamoute = SCTP_SO(&asoc->stream, params.sprstat_sid)->ext;
7534 struct sctp_association *asoc;
7546 asoc = sctp_id2assoc(sk, params.assoc_id);
7547 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7553 params.assoc_value = asoc ? asoc->peer.reconf_capable
7573 struct sctp_association *asoc;
7585 asoc = sctp_id2assoc(sk, params.assoc_id);
7586 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7592 params.assoc_value = asoc ? asoc->strreset_enable
7612 struct sctp_association *asoc;
7624 asoc = sctp_id2assoc(sk, params.assoc_id);
7625 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7631 params.assoc_value = asoc ? sctp_sched_get_sched(asoc)
7651 struct sctp_association *asoc;
7663 asoc = sctp_id2assoc(sk, params.assoc_id);
7664 if (!asoc) {
7669 retval = sctp_sched_get_value(asoc, params.stream_id,
7693 struct sctp_association *asoc;
7705 asoc = sctp_id2assoc(sk, params.assoc_id);
7706 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7712 params.assoc_value = asoc ? asoc->peer.intl_capable
7750 struct sctp_association *asoc;
7765 asoc = sctp_id2assoc(sk, param.se_assoc_id);
7766 if (!asoc && param.se_assoc_id != SCTP_FUTURE_ASSOC &&
7770 subscribe = asoc ? asoc->subscribe : sctp_sk(sk)->subscribe;
7787 struct sctp_association *asoc;
7799 asoc = sctp_id2assoc(sk, params.assoc_id);
7800 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7806 params.assoc_value = asoc ? asoc->peer.asconf_capable
7826 struct sctp_association *asoc;
7838 asoc = sctp_id2assoc(sk, params.assoc_id);
7839 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7845 params.assoc_value = asoc ? asoc->peer.auth_capable
7865 struct sctp_association *asoc;
7877 asoc = sctp_id2assoc(sk, params.assoc_id);
7878 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7884 params.assoc_value = asoc ? asoc->peer.ecn_capable
7904 struct sctp_association *asoc;
7916 asoc = sctp_id2assoc(sk, params.assoc_id);
7917 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7923 params.assoc_value = asoc ? asoc->pf_expose
7941 struct sctp_association *asoc;
7972 asoc = sctp_id2assoc(sk, encap.sue_assoc_id);
7973 if (!asoc && encap.sue_assoc_id != SCTP_FUTURE_ASSOC &&
7979 if (asoc) {
7980 encap_port = asoc->encap_port;
8002 struct sctp_association *asoc;
8032 asoc = sctp_id2assoc(sk, params.spi_assoc_id);
8033 if (!asoc && params.spi_assoc_id != SCTP_FUTURE_ASSOC &&
8039 if (asoc) {
8040 probe_interval = jiffies_to_msecs(asoc->probe_interval);
9068 static void __sctp_write_space(struct sctp_association *asoc)
9070 struct sock *sk = asoc->base.sk;
9072 if (sctp_wspace(asoc) <= 0)
9075 if (waitqueue_active(&asoc->wait))
9076 wake_up_interruptible(&asoc->wait);
9099 struct sctp_association *asoc)
9101 struct sctp_association *tmp = asoc;
9106 if (asoc->ep->sndbuf_policy)
9107 return __sctp_write_space(asoc);
9112 if (asoc->base.dead)
9133 if (tmp == asoc)
9145 struct sctp_association *asoc = chunk->asoc;
9146 struct sock *sk = asoc->base.sk;
9150 asoc->sndbuf_used -= skb->truesize + sizeof(struct sctp_chunk);
9165 ev = sctp_ulpevent_make_authkey(asoc, shkey->key_id,
9169 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
9175 sctp_wake_up_waiters(sk, asoc);
9177 sctp_association_put(asoc);
9200 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
9203 struct sock *sk = asoc->base.sk;
9208 pr_debug("%s: asoc:%p, timeo:%ld, msg_len:%zu\n", __func__, asoc,
9212 sctp_association_hold(asoc);
9216 prepare_to_wait_exclusive(&asoc->wait, &wait,
9218 if (asoc->base.dead)
9222 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING)
9226 if ((int)msg_len <= sctp_wspace(asoc) &&
9236 if (sk != asoc->base.sk)
9243 finish_wait(&asoc->wait, &wait);
9246 sctp_association_put(asoc);
9285 struct sctp_association *asoc;
9288 list_for_each_entry(asoc, &((sctp_sk(sk))->ep->asocs), asocs) {
9289 __sctp_write_space(asoc);
9312 static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)
9314 struct sock *sk = asoc->base.sk;
9319 pr_debug("%s: asoc:%p, timeo:%ld\n", __func__, asoc, *timeo_p);
9322 sctp_association_hold(asoc);
9325 prepare_to_wait_exclusive(&asoc->wait, &wait,
9331 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||
9332 asoc->base.dead)
9337 if (sctp_state(asoc, ESTABLISHED))
9351 finish_wait(&asoc->wait, &wait);
9354 sctp_association_put(asoc);
9359 if (asoc->init_err_counter + 1 > asoc->max_init_attempts)
9447 struct sctp_association *asoc)
9482 newinet->inet_dport = htons(asoc->peer.port);
9496 * security attribute from asoc.
9498 security_sctp_sk_clone(asoc, sk, newsk);
9576 if (event->asoc == assoc) {
9605 if (event->asoc == assoc) {