Lines Matching refs:asoc
73 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
86 static int sctp_send_asconf(struct sctp_association *asoc,
105 static inline int sctp_wspace(struct sctp_association *asoc)
107 struct sock *sk = asoc->base.sk;
109 return asoc->ep->sndbuf_policy ? sk->sk_sndbuf - asoc->sndbuf_used
124 struct sctp_association *asoc = chunk->asoc;
125 struct sock *sk = asoc->base.sk;
128 sctp_association_hold(asoc);
140 asoc->sndbuf_used += chunk->skb->truesize + sizeof(struct sctp_chunk);
156 if ((clear && asoc->base.sk == c->skb->sk) || \
157 (!clear && asoc->base.sk != c->skb->sk)) \
163 static void sctp_for_each_tx_datachunk(struct sctp_association *asoc,
169 struct sctp_outq *q = &asoc->outqueue;
173 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports)
190 static void sctp_for_each_rx_skb(struct sctp_association *asoc, struct sock *sk,
196 sctp_skb_for_each(skb, &asoc->ulpq.lobby, tmp)
199 sctp_skb_for_each(skb, &asoc->ulpq.reasm, tmp)
202 sctp_skb_for_each(skb, &asoc->ulpq.reasm_uo, tmp)
232 struct sctp_association *asoc = NULL;
245 asoc = list_entry(sctp_sk(sk)->ep->asocs.next,
247 return asoc;
255 asoc = (struct sctp_association *)idr_find(&sctp_assocs_id, (int)id);
256 if (asoc && (asoc->base.sk != sk || asoc->base.dead))
257 asoc = NULL;
260 return asoc;
465 static int sctp_send_asconf(struct sctp_association *asoc,
473 if (asoc->addip_last_asconf) {
474 list_add_tail(&chunk->list, &asoc->addip_chunk_list);
480 retval = sctp_primitive_ASCONF(asoc->base.net, asoc, chunk);
484 asoc->addip_last_asconf = chunk;
558 struct sctp_association *asoc;
579 list_for_each_entry(asoc, &ep->asocs, asocs) {
580 if (!asoc->peer.asconf_capable)
583 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_ADD_IP)
586 if (!sctp_state(asoc, ESTABLISHED))
603 if (sctp_assoc_lookup_laddr(asoc, addr))
614 bp = &asoc->base.bind_addr;
617 chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs,
637 if (asoc->src_out_of_asoc_ok) {
641 &asoc->peer.transport_addr_list, transports) {
642 trans->cwnd = min(4*asoc->pathmtu, max_t(__u32,
643 2*asoc->pathmtu, 4380));
644 trans->ssthresh = asoc->peer.i.a_rwnd;
645 trans->rto = asoc->rto_initial;
646 sctp_max_rto(asoc, trans);
650 sctp_sk(asoc->base.sk));
653 retval = sctp_send_asconf(asoc, chunk);
760 struct sctp_association *asoc;
782 list_for_each_entry(asoc, &ep->asocs, asocs) {
784 if (!asoc->peer.asconf_capable)
787 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_DEL_IP)
790 if (!sctp_state(asoc, ESTABLISHED))
807 if (!sctp_assoc_lookup_laddr(asoc, laddr))
820 bp = &asoc->base.bind_addr;
824 if (asoc->asconf_addr_del_pending)
826 asoc->asconf_addr_del_pending =
828 if (asoc->asconf_addr_del_pending == NULL) {
832 asoc->asconf_addr_del_pending->sa.sa_family =
834 asoc->asconf_addr_del_pending->v4.sin_port =
840 asoc->asconf_addr_del_pending->v4.sin_addr.s_addr = sin->sin_addr.s_addr;
845 asoc->asconf_addr_del_pending->v6.sin6_addr = sin6->sin6_addr;
848 pr_debug("%s: keep the last address asoc:%p %pISc at %p\n",
849 __func__, asoc, &asoc->asconf_addr_del_pending->sa,
850 asoc->asconf_addr_del_pending);
852 asoc->src_out_of_asoc_ok = 1;
864 chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt,
890 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
893 sctp_sk(asoc->base.sk));
899 retval = sctp_send_asconf(asoc, chunk);
1069 struct sctp_association *asoc;
1088 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
1089 if (!asoc)
1092 err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, GFP_KERNEL);
1096 *tp = sctp_assoc_add_peer(asoc, daddr, GFP_KERNEL, SCTP_UNKNOWN);
1108 asoc->c.sinit_num_ostreams = outcnt;
1110 err = sctp_stream_init(&asoc->stream, outcnt, 0, GFP_KERNEL);
1116 asoc->c.sinit_max_instreams = init->sinit_max_instreams;
1119 asoc->max_init_attempts = init->sinit_max_attempts;
1122 asoc->max_init_timeo =
1127 sctp_association_free(asoc);
1131 static int sctp_connect_add_peer(struct sctp_association *asoc,
1134 struct sctp_endpoint *ep = asoc->ep;
1144 if (old && old != asoc)
1151 t = sctp_assoc_add_peer(asoc, daddr, GFP_KERNEL, SCTP_UNKNOWN);
1169 struct sctp_association *asoc;
1189 asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
1190 if (asoc)
1191 return asoc->state >= SCTP_STATE_ESTABLISHED ? -EISCONN
1197 asoc = transport->asoc;
1211 if (asoc->peer.port != ntohs(daddr->v4.sin_port))
1214 err = sctp_connect_add_peer(asoc, daddr, af->sockaddr_len);
1226 err = sctp_assoc_set_id(asoc, GFP_KERNEL);
1231 err = sctp_primitive_ASSOCIATE(sock_net(sk), asoc, NULL);
1236 inet_sk(sk)->inet_dport = htons(asoc->peer.port);
1241 *assoc_id = asoc->assoc_id;
1244 return sctp_wait_for_connect(asoc, &timeo);
1247 pr_debug("%s: took out_free path with asoc:%p kaddrs:%p err:%d\n",
1248 __func__, asoc, kaddrs, err);
1249 sctp_association_free(asoc);
1257 * sctp_assoc_t *asoc);
1484 struct sctp_association *asoc;
1502 asoc = list_entry(pos, struct sctp_association, asocs);
1510 if (sctp_state(asoc, CLOSED)) {
1511 sctp_association_free(asoc);
1516 if (data_was_unread || !skb_queue_empty(&asoc->ulpq.lobby) ||
1517 !skb_queue_empty(&asoc->ulpq.reasm) ||
1518 !skb_queue_empty(&asoc->ulpq.reasm_uo) ||
1522 chunk = sctp_make_abort_user(asoc, NULL, 0);
1523 sctp_primitive_ABORT(net, asoc, chunk);
1525 sctp_primitive_SHUTDOWN(net, asoc, NULL);
1660 struct sctp_association *asoc;
1693 asoc = (*tp)->asoc;
1722 daddr->v4.sin_port = htons(asoc->peer.port);
1733 daddr->v6.sin6_port = htons(asoc->peer.port);
1737 err = sctp_connect_add_peer(asoc, daddr, sizeof(*daddr));
1745 sctp_association_free(asoc);
1749 static int sctp_sendmsg_check_sflags(struct sctp_association *asoc,
1753 struct sock *sk = asoc->base.sk;
1756 if (sctp_state(asoc, CLOSED) && sctp_style(sk, TCP))
1760 !sctp_state(asoc, ESTABLISHED))
1764 pr_debug("%s: shutting down association:%p\n", __func__, asoc);
1765 sctp_primitive_SHUTDOWN(net, asoc, NULL);
1773 chunk = sctp_make_abort_user(asoc, msg, msg_len);
1777 pr_debug("%s: aborting association:%p\n", __func__, asoc);
1778 sctp_primitive_ABORT(net, asoc, chunk);
1787 static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1792 struct sock *sk = asoc->base.sk;
1801 if (sinfo->sinfo_stream >= asoc->stream.outcnt) {
1806 if (unlikely(!SCTP_SO(&asoc->stream, sinfo->sinfo_stream)->ext)) {
1807 err = sctp_stream_init_ext(&asoc->stream, sinfo->sinfo_stream);
1812 if (sp->disable_fragments && msg_len > asoc->frag_point) {
1817 if (asoc->pmtu_pending) {
1819 sctp_assoc_sync_pmtu(asoc);
1820 asoc->pmtu_pending = 0;
1823 if (sctp_wspace(asoc) < (int)msg_len)
1824 sctp_prsctp_prune(asoc, sinfo, msg_len - sctp_wspace(asoc));
1829 if (sctp_wspace(asoc) <= 0 || !sk_wmem_schedule(sk, msg_len)) {
1831 err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
1834 if (unlikely(sinfo->sinfo_stream >= asoc->stream.outcnt)) {
1840 if (sctp_state(asoc, CLOSED)) {
1841 err = sctp_primitive_ASSOCIATE(net, asoc, NULL);
1845 if (asoc->ep->intl_enable) {
1847 err = sctp_wait_for_connect(asoc, &timeo);
1859 datamsg = sctp_datamsg_from_user(asoc, sinfo, &msg->msg_iter);
1865 asoc->force_delay = !!(msg->msg_flags & MSG_MORE);
1873 err = sctp_primitive_SEND(net, asoc, datamsg);
1885 sctp_wait_for_connect(asoc, &timeo);
1917 static void sctp_sendmsg_update_sinfo(struct sctp_association *asoc,
1922 sinfo->sinfo_stream = asoc->default_stream;
1923 sinfo->sinfo_ppid = asoc->default_ppid;
1924 sinfo->sinfo_context = asoc->default_context;
1925 sinfo->sinfo_assoc_id = sctp_assoc2id(asoc);
1928 sinfo->sinfo_flags = asoc->default_flags;
1932 sinfo->sinfo_timetolive = asoc->default_timetolive;
1948 struct sctp_association *asoc, *tmp;
1974 list_for_each_entry_safe(asoc, tmp, &ep->asocs, asocs) {
1975 err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
1982 sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);
1984 err = sctp_sendmsg_to_asoc(asoc, msg, msg_len,
1995 /* Get and check or create asoc */
1997 asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
1998 if (asoc) {
1999 err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
2009 asoc = transport->asoc;
2016 asoc = sctp_id2assoc(sk, sinfo->sinfo_assoc_id);
2017 if (!asoc) {
2022 err = sctp_sendmsg_check_sflags(asoc, sflags, msg, msg_len);
2027 /* Update snd_info with the asoc */
2028 sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);
2030 /* Send msg to the asoc */
2031 err = sctp_sendmsg_to_asoc(asoc, msg, msg_len, transport, sinfo);
2033 sctp_association_free(asoc);
2172 sctp_assoc_rwnd_increase(event->asoc, copied);
2218 struct sctp_association *asoc;
2228 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
2229 asoc->subscribe = sctp_sk(sk)->subscribe;
2238 asoc = sctp_id2assoc(sk, 0);
2239 if (asoc && sctp_outq_is_empty(&asoc->outqueue)) {
2240 event = sctp_ulpevent_make_sender_dry_event(asoc,
2245 asoc->stream.si->enqueue_event(&asoc->ulpq, event);
2422 struct sctp_association *asoc,
2431 error = sctp_primitive_REQUESTHEARTBEAT(trans->asoc->base.net,
2432 trans->asoc, trans);
2456 } else if (asoc) {
2457 asoc->hbinterval =
2469 } else if (asoc) {
2470 asoc->param_flags =
2471 (asoc->param_flags & ~SPP_HB) | hb_change;
2486 sctp_assoc_sync_pmtu(asoc);
2487 } else if (asoc) {
2488 sctp_assoc_set_pmtu(asoc, params->spp_pathmtu);
2502 sctp_assoc_sync_pmtu(asoc);
2504 } else if (asoc) {
2505 asoc->param_flags =
2506 (asoc->param_flags & ~SPP_PMTUD) | pmtud_change;
2521 } else if (asoc) {
2522 asoc->sackdelay =
2534 } else if (asoc) {
2535 asoc->param_flags =
2536 (asoc->param_flags & ~SPP_SACKDELAY) |
2551 } else if (asoc) {
2552 asoc->pathmaxrxt = params->spp_pathmaxrxt;
2565 } else if (asoc) {
2568 list_for_each_entry(t, &asoc->peer.transport_addr_list,
2576 asoc->flowlabel = params->spp_ipv6_flowlabel &
2578 asoc->flowlabel |= SCTP_FLOWLABEL_SET_MASK;
2590 } else if (asoc) {
2593 list_for_each_entry(t, &asoc->peer.transport_addr_list,
2599 asoc->dscp = params->spp_dscp & SCTP_DSCP_VAL_MASK;
2600 asoc->dscp |= SCTP_DSCP_SET_MASK;
2615 struct sctp_association *asoc = NULL;
2655 asoc = sctp_id2assoc(sk, params->spp_assoc_id);
2656 if (!asoc && params->spp_assoc_id != SCTP_FUTURE_ASSOC &&
2663 if (params->spp_flags & SPP_HB_DEMAND && !trans && !asoc)
2667 error = sctp_apply_peer_addr_params(params, trans, asoc, sp,
2677 if (!trans && asoc) {
2678 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2680 sctp_apply_peer_addr_params(params, trans, asoc, sp,
2700 struct sctp_association *asoc)
2705 asoc->sackdelay = msecs_to_jiffies(params->sack_delay);
2706 asoc->param_flags =
2707 sctp_spp_sackdelay_enable(asoc->param_flags);
2710 asoc->param_flags =
2711 sctp_spp_sackdelay_disable(asoc->param_flags);
2713 asoc->sackfreq = params->sack_freq;
2714 asoc->param_flags =
2715 sctp_spp_sackdelay_enable(asoc->param_flags);
2718 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2775 struct sctp_association *asoc;
2785 asoc = sctp_id2assoc(sk, params->sack_assoc_id);
2786 if (!asoc && params->sack_assoc_id > SCTP_ALL_ASSOC &&
2790 if (asoc) {
2791 sctp_apply_asoc_delayed_ack(params, asoc);
2818 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
2819 sctp_apply_asoc_delayed_ack(params, asoc);
2901 struct sctp_association *asoc;
2910 asoc = sctp_id2assoc(sk, info->sinfo_assoc_id);
2911 if (!asoc && info->sinfo_assoc_id > SCTP_ALL_ASSOC &&
2915 if (asoc) {
2916 asoc->default_stream = info->sinfo_stream;
2917 asoc->default_flags = info->sinfo_flags;
2918 asoc->default_ppid = info->sinfo_ppid;
2919 asoc->default_context = info->sinfo_context;
2920 asoc->default_timetolive = info->sinfo_timetolive;
2939 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
2940 asoc->default_stream = info->sinfo_stream;
2941 asoc->default_flags = info->sinfo_flags;
2942 asoc->default_ppid = info->sinfo_ppid;
2943 asoc->default_context = info->sinfo_context;
2944 asoc->default_timetolive = info->sinfo_timetolive;
2959 struct sctp_association *asoc;
2968 asoc = sctp_id2assoc(sk, info->snd_assoc_id);
2969 if (!asoc && info->snd_assoc_id > SCTP_ALL_ASSOC &&
2973 if (asoc) {
2974 asoc->default_stream = info->snd_sid;
2975 asoc->default_flags = info->snd_flags;
2976 asoc->default_ppid = info->snd_ppid;
2977 asoc->default_context = info->snd_context;
2995 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
2996 asoc->default_stream = info->snd_sid;
2997 asoc->default_flags = info->snd_flags;
2998 asoc->default_ppid = info->snd_ppid;
2999 asoc->default_context = info->snd_context;
3037 sctp_assoc_set_primary(trans->asoc, trans);
3075 struct sctp_association *asoc;
3082 asoc = sctp_id2assoc(sk, rtoinfo->srto_assoc_id);
3085 if (!asoc && rtoinfo->srto_assoc_id != SCTP_FUTURE_ASSOC &&
3093 rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max;
3095 rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max;
3098 rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min;
3100 rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min;
3105 if (asoc) {
3107 asoc->rto_initial =
3109 asoc->rto_max = rto_max;
3110 asoc->rto_min = rto_min;
3140 struct sctp_association *asoc;
3145 asoc = sctp_id2assoc(sk, assocparams->sasoc_assoc_id);
3147 if (!asoc && assocparams->sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
3152 if (asoc) {
3158 list_for_each_entry(peer_addr, &asoc->peer.transport_addr_list,
3173 asoc->max_retrans = assocparams->sasoc_asocmaxrxt;
3177 asoc->cookie_life =
3250 struct sctp_association *asoc;
3269 asoc = sctp_id2assoc(sk, assoc_id);
3270 if (!asoc && assoc_id != SCTP_FUTURE_ASSOC &&
3276 __u16 datasize = asoc ? sctp_datachk_len(&asoc->stream) :
3286 if (asoc) {
3287 asoc->user_frag = val;
3288 sctp_assoc_update_frag_point(asoc);
3310 struct sctp_association *asoc = NULL;
3323 asoc = sctp_id2assoc(sk, prim->sspp_assoc_id);
3324 if (!asoc)
3327 if (!asoc->peer.asconf_capable)
3330 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_SET_PRIMARY)
3333 if (!sctp_state(asoc, ESTABLISHED))
3343 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim->sspp_addr))
3354 chunk = sctp_make_asconf_set_prim(asoc,
3359 err = sctp_send_asconf(asoc, chunk);
3397 struct sctp_association *asoc;
3402 asoc = sctp_id2assoc(sk, params->assoc_id);
3403 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
3407 if (asoc) {
3408 asoc->default_rcv_context = params->assoc_value;
3422 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
3423 asoc->default_rcv_context = params->assoc_value;
3516 struct sctp_association *asoc;
3534 asoc = sctp_id2assoc(sk, assoc_id);
3535 if (!asoc && assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP))
3538 if (asoc) {
3539 asoc->max_burst = assoc_value;
3551 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
3552 asoc->max_burst = assoc_value;
3628 struct sctp_association *asoc;
3641 asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
3642 if (!asoc && authkey->sca_assoc_id > SCTP_ALL_ASSOC &&
3646 if (asoc) {
3647 ret = sctp_auth_set_key(ep, asoc, authkey);
3656 ret = sctp_auth_set_key(ep, asoc, authkey);
3665 list_for_each_entry(asoc, &ep->asocs, asocs) {
3666 int res = sctp_auth_set_key(ep, asoc, authkey);
3689 struct sctp_association *asoc;
3695 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3696 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3700 if (asoc)
3701 return sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
3708 ret = sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
3715 list_for_each_entry(asoc, &ep->asocs, asocs) {
3716 int res = sctp_auth_set_active_key(ep, asoc,
3737 struct sctp_association *asoc;
3743 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3744 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3748 if (asoc)
3749 return sctp_auth_del_key_id(ep, asoc, val->scact_keynumber);
3756 ret = sctp_auth_del_key_id(ep, asoc, val->scact_keynumber);
3763 list_for_each_entry(asoc, &ep->asocs, asocs) {
3764 int res = sctp_auth_del_key_id(ep, asoc,
3785 struct sctp_association *asoc;
3791 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3792 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3796 if (asoc)
3797 return sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber);
3804 ret = sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber);
3811 list_for_each_entry(asoc, &ep->asocs, asocs) {
3812 int res = sctp_auth_deact_key_id(ep, asoc,
3874 struct sctp_association *asoc;
3899 asoc = sctp_id2assoc(sk, val->spt_assoc_id);
3900 if (!asoc && val->spt_assoc_id != SCTP_FUTURE_ASSOC &&
3904 if (asoc) {
3905 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
3915 asoc->pathmaxrxt = val->spt_pathmaxrxt;
3917 asoc->ps_retrans = val->spt_pathcpthld;
3918 asoc->pf_retrans = val->spt_pathpfthld;
3958 struct sctp_association *asoc;
3963 asoc = sctp_id2assoc(sk, params->assoc_id);
3964 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
3978 struct sctp_association *asoc;
3990 asoc = sctp_id2assoc(sk, info->pr_assoc_id);
3991 if (!asoc && info->pr_assoc_id > SCTP_ALL_ASSOC &&
3997 if (asoc) {
3998 SCTP_PR_SET_POLICY(asoc->default_flags, info->pr_policy);
3999 asoc->default_timetolive = info->pr_value;
4014 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4015 SCTP_PR_SET_POLICY(asoc->default_flags,
4017 asoc->default_timetolive = info->pr_value;
4029 struct sctp_association *asoc;
4035 asoc = sctp_id2assoc(sk, params->assoc_id);
4036 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4053 struct sctp_association *asoc;
4062 asoc = sctp_id2assoc(sk, params->assoc_id);
4063 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
4069 if (asoc) {
4070 asoc->strreset_enable = params->assoc_value;
4083 list_for_each_entry(asoc, &ep->asocs, asocs)
4084 asoc->strreset_enable = params->assoc_value;
4094 struct sctp_association *asoc;
4106 asoc = sctp_id2assoc(sk, params->srs_assoc_id);
4107 if (!asoc)
4110 return sctp_send_reset_streams(asoc, params);
4116 struct sctp_association *asoc;
4121 asoc = sctp_id2assoc(sk, *associd);
4122 if (!asoc)
4125 return sctp_send_reset_assoc(asoc);
4132 struct sctp_association *asoc;
4137 asoc = sctp_id2assoc(sk, params->sas_assoc_id);
4138 if (!asoc)
4141 return sctp_send_add_streams(asoc, params);
4149 struct sctp_association *asoc;
4158 asoc = sctp_id2assoc(sk, params->assoc_id);
4159 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
4163 if (asoc)
4164 return sctp_sched_set_sched(asoc, params->assoc_value);
4175 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4176 int ret = sctp_sched_set_sched(asoc,
4191 struct sctp_association *asoc;
4197 asoc = sctp_id2assoc(sk, params->assoc_id);
4198 if (!asoc && params->assoc_id != SCTP_CURRENT_ASSOC &&
4202 if (asoc) {
4203 retval = sctp_sched_set_value(asoc, params->stream_id,
4210 list_for_each_entry(asoc, &sctp_sk(sk)->ep->asocs, asocs) {
4211 int ret = sctp_sched_set_value(asoc, params->stream_id,
4227 struct sctp_association *asoc;
4232 asoc = sctp_id2assoc(sk, p->assoc_id);
4233 if (!asoc && p->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP))
4262 struct sctp_association *asoc)
4266 sctp_ulpevent_type_set(&asoc->subscribe, param->se_type, param->se_on);
4269 if (sctp_outq_is_empty(&asoc->outqueue)) {
4270 event = sctp_ulpevent_make_sender_dry_event(asoc,
4275 asoc->stream.si->enqueue_event(&asoc->ulpq, event);
4286 struct sctp_association *asoc;
4296 asoc = sctp_id2assoc(sk, param->se_assoc_id);
4297 if (!asoc && param->se_assoc_id > SCTP_ALL_ASSOC &&
4301 if (asoc)
4302 return sctp_assoc_ulpevent_type_set(param, asoc);
4314 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4315 int ret = sctp_assoc_ulpevent_type_set(param, asoc);
4329 struct sctp_association *asoc;
4336 asoc = sctp_id2assoc(sk, params->assoc_id);
4337 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4359 struct sctp_association *asoc;
4366 asoc = sctp_id2assoc(sk, params->assoc_id);
4367 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4393 struct sctp_association *asoc;
4399 asoc = sctp_id2assoc(sk, params->assoc_id);
4400 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4415 struct sctp_association *asoc;
4424 asoc = sctp_id2assoc(sk, params->assoc_id);
4425 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4429 if (asoc)
4430 asoc->pf_expose = params->assoc_value;
4737 struct sctp_association *asoc;
4765 asoc = list_entry(ep->asocs.next, struct sctp_association, asocs);
4767 newsk = sp->pf->create_accept_sk(sk, asoc, kern);
4774 * asoc to the newsk.
4776 error = sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP);
5039 struct sctp_association *asoc;
5042 asoc = list_entry(ep->asocs.next,
5044 sctp_primitive_SHUTDOWN(net, asoc, NULL);
5048 int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc,
5056 if (!asoc) {
5071 info->sctpi_tag = asoc->c.my_vtag;
5072 info->sctpi_state = asoc->state;
5073 info->sctpi_rwnd = asoc->a_rwnd;
5074 info->sctpi_unackdata = asoc->unack_data;
5075 info->sctpi_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map);
5076 info->sctpi_instrms = asoc->stream.incnt;
5077 info->sctpi_outstrms = asoc->stream.outcnt;
5078 list_for_each(pos, &asoc->base.inqueue.in_chunk_list)
5080 list_for_each(pos, &asoc->outqueue.out_chunk_list)
5082 info->sctpi_overall_error = asoc->overall_error_count;
5083 info->sctpi_max_burst = asoc->max_burst;
5084 info->sctpi_maxseg = asoc->frag_point;
5085 info->sctpi_peer_rwnd = asoc->peer.rwnd;
5086 info->sctpi_peer_tag = asoc->c.peer_vtag;
5088 mask = asoc->peer.ecn_capable << 1;
5089 mask = (mask | asoc->peer.ipv4_address) << 1;
5090 mask = (mask | asoc->peer.ipv6_address) << 1;
5091 mask = (mask | asoc->peer.hostname_address) << 1;
5092 mask = (mask | asoc->peer.asconf_capable) << 1;
5093 mask = (mask | asoc->peer.prsctp_capable) << 1;
5094 mask = (mask | asoc->peer.auth_capable);
5096 mask = asoc->peer.sack_needed << 1;
5097 mask = (mask | asoc->peer.sack_generation) << 1;
5098 mask = (mask | asoc->peer.zero_window_announced);
5101 info->sctpi_isacks = asoc->stats.isacks;
5102 info->sctpi_osacks = asoc->stats.osacks;
5103 info->sctpi_opackets = asoc->stats.opackets;
5104 info->sctpi_ipackets = asoc->stats.ipackets;
5105 info->sctpi_rtxchunks = asoc->stats.rtxchunks;
5106 info->sctpi_outofseqtsns = asoc->stats.outofseqtsns;
5107 info->sctpi_idupchunks = asoc->stats.idupchunks;
5108 info->sctpi_gapcnt = asoc->stats.gapcnt;
5109 info->sctpi_ouodchunks = asoc->stats.ouodchunks;
5110 info->sctpi_iuodchunks = asoc->stats.iuodchunks;
5111 info->sctpi_oodchunks = asoc->stats.oodchunks;
5112 info->sctpi_iodchunks = asoc->stats.iodchunks;
5113 info->sctpi_octrlchunks = asoc->stats.octrlchunks;
5114 info->sctpi_ictrlchunks = asoc->stats.ictrlchunks;
5116 prim = asoc->peer.primary_path;
5164 if (net_eq(t->asoc->base.net, net) &&
5165 t->asoc->peer.primary_path == t)
5249 ep = tsp->asoc->ep;
5250 if (sctp_endpoint_hold(ep)) { /* asoc can be peeled off */
5288 struct sctp_association *asoc = NULL;
5305 asoc = sctp_id2assoc(sk, associd);
5306 if (!asoc) {
5311 transport = asoc->peer.primary_path;
5313 status.sstat_assoc_id = sctp_assoc2id(asoc);
5314 status.sstat_state = sctp_assoc_to_state(asoc);
5315 status.sstat_rwnd = asoc->peer.rwnd;
5316 status.sstat_unackdata = asoc->unack_data;
5318 status.sstat_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map);
5319 status.sstat_instrms = asoc->stream.incnt;
5320 status.sstat_outstrms = asoc->stream.outcnt;
5321 status.sstat_fragmentation_point = asoc->frag_point;
5322 status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
5390 transport->asoc->pf_expose == SCTP_PF_EXPOSE_DISABLE) {
5395 pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
5501 struct sctp_association *asoc = sctp_id2assoc(sk, id);
5510 if (!asoc)
5524 sctp_copy_sock(sock->sk, sk, asoc);
5530 sp->pf->to_sk_daddr(&asoc->peer.primary_addr, sock->sk);
5534 * asoc to the newsk.
5536 err = sctp_sock_migrate(sk, sock->sk, asoc,
5790 struct sctp_association *asoc = NULL;
5821 asoc = sctp_id2assoc(sk, params.spp_assoc_id);
5822 if (!asoc && params.spp_assoc_id != SCTP_FUTURE_ASSOC &&
5846 } else if (asoc) {
5848 params.spp_hbinterval = jiffies_to_msecs(asoc->hbinterval);
5849 params.spp_pathmtu = asoc->pathmtu;
5850 params.spp_pathmaxrxt = asoc->pathmaxrxt;
5851 params.spp_sackdelay = jiffies_to_msecs(asoc->sackdelay);
5854 params.spp_flags = asoc->param_flags;
5855 if (asoc->flowlabel & SCTP_FLOWLABEL_SET_MASK) {
5856 params.spp_ipv6_flowlabel = asoc->flowlabel &
5860 if (asoc->dscp & SCTP_DSCP_SET_MASK) {
5861 params.spp_dscp = asoc->dscp & SCTP_DSCP_VAL_MASK;
5933 struct sctp_association *asoc = NULL;
5956 asoc = sctp_id2assoc(sk, params.sack_assoc_id);
5957 if (!asoc && params.sack_assoc_id != SCTP_FUTURE_ASSOC &&
5961 if (asoc) {
5963 if (asoc->param_flags & SPP_SACKDELAY_ENABLE) {
5964 params.sack_delay = jiffies_to_msecs(asoc->sackdelay);
5965 params.sack_freq = asoc->sackfreq;
6018 struct sctp_association *asoc;
6036 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
6037 if (!asoc)
6043 list_for_each_entry(from, &asoc->peer.transport_addr_list,
6115 struct sctp_association *asoc;
6144 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
6145 if (!asoc)
6147 bp = &asoc->base.bind_addr;
6223 struct sctp_association *asoc;
6234 asoc = sctp_id2assoc(sk, prim.ssp_assoc_id);
6235 if (!asoc)
6238 if (!asoc->peer.primary_path)
6241 memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr,
6242 asoc->peer.primary_path->af_specific->sockaddr_len);
6305 struct sctp_association *asoc;
6316 asoc = sctp_id2assoc(sk, info.sinfo_assoc_id);
6317 if (!asoc && info.sinfo_assoc_id != SCTP_FUTURE_ASSOC &&
6321 if (asoc) {
6322 info.sinfo_stream = asoc->default_stream;
6323 info.sinfo_flags = asoc->default_flags;
6324 info.sinfo_ppid = asoc->default_ppid;
6325 info.sinfo_context = asoc->default_context;
6326 info.sinfo_timetolive = asoc->default_timetolive;
6351 struct sctp_association *asoc;
6362 asoc = sctp_id2assoc(sk, info.snd_assoc_id);
6363 if (!asoc && info.snd_assoc_id != SCTP_FUTURE_ASSOC &&
6367 if (asoc) {
6368 info.snd_sid = asoc->default_stream;
6369 info.snd_flags = asoc->default_flags;
6370 info.snd_ppid = asoc->default_ppid;
6371 info.snd_context = asoc->default_context;
6430 struct sctp_association *asoc;
6440 asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id);
6442 if (!asoc && rtoinfo.srto_assoc_id != SCTP_FUTURE_ASSOC &&
6447 if (asoc) {
6448 rtoinfo.srto_initial = jiffies_to_msecs(asoc->rto_initial);
6449 rtoinfo.srto_max = jiffies_to_msecs(asoc->rto_max);
6450 rtoinfo.srto_min = jiffies_to_msecs(asoc->rto_min);
6486 struct sctp_association *asoc;
6498 asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id);
6500 if (!asoc && assocparams.sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
6505 if (asoc) {
6506 assocparams.sasoc_asocmaxrxt = asoc->max_retrans;
6507 assocparams.sasoc_peer_rwnd = asoc->peer.rwnd;
6508 assocparams.sasoc_local_rwnd = asoc->a_rwnd;
6509 assocparams.sasoc_cookie_life = ktime_to_ms(asoc->cookie_life);
6511 list_for_each(pos, &asoc->peer.transport_addr_list) {
6576 struct sctp_association *asoc;
6586 asoc = sctp_id2assoc(sk, params.assoc_id);
6587 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6591 params.assoc_value = asoc ? asoc->default_rcv_context
6633 struct sctp_association *asoc;
6649 asoc = sctp_id2assoc(sk, params.assoc_id);
6650 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6654 if (asoc)
6655 params.assoc_value = asoc->frag_point;
6728 struct sctp_association *asoc;
6744 asoc = sctp_id2assoc(sk, params.assoc_id);
6745 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6749 params.assoc_value = asoc ? asoc->max_burst : sctp_sk(sk)->max_burst;
6804 struct sctp_association *asoc;
6813 asoc = sctp_id2assoc(sk, val.scact_assoc_id);
6814 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP))
6817 if (asoc) {
6818 if (!asoc->peer.auth_capable)
6820 val.scact_keynumber = asoc->active_key_id;
6840 struct sctp_association *asoc;
6852 asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
6853 if (!asoc)
6856 if (!asoc->peer.auth_capable)
6859 ch = asoc->peer.peer_chunks;
6885 struct sctp_association *asoc;
6897 asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
6898 if (!asoc && val.gauth_assoc_id != SCTP_FUTURE_ASSOC &&
6902 if (asoc) {
6903 if (!asoc->peer.auth_capable)
6905 ch = (struct sctp_chunks_param *)asoc->c.auth_chunks;
6939 struct sctp_association *asoc;
6950 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
6995 struct sctp_association *asoc;
7005 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7020 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7021 ids->gaids_assoc_id[num++] = asoc->assoc_id;
7046 struct sctp_association *asoc;
7069 asoc = sctp_id2assoc(sk, val.spt_assoc_id);
7070 if (!asoc && val.spt_assoc_id != SCTP_FUTURE_ASSOC &&
7074 if (asoc) {
7075 val.spt_pathpfthld = asoc->pf_retrans;
7076 val.spt_pathmaxrxt = asoc->pathmaxrxt;
7077 val.spt_pathcpthld = asoc->ps_retrans;
7104 struct sctp_association *asoc = NULL;
7116 asoc = sctp_id2assoc(sk, sas.sas_assoc_id);
7117 if (!asoc)
7120 sas.sas_rtxchunks = asoc->stats.rtxchunks;
7121 sas.sas_gapcnt = asoc->stats.gapcnt;
7122 sas.sas_outofseqtsns = asoc->stats.outofseqtsns;
7123 sas.sas_osacks = asoc->stats.osacks;
7124 sas.sas_isacks = asoc->stats.isacks;
7125 sas.sas_octrlchunks = asoc->stats.octrlchunks;
7126 sas.sas_ictrlchunks = asoc->stats.ictrlchunks;
7127 sas.sas_oodchunks = asoc->stats.oodchunks;
7128 sas.sas_iodchunks = asoc->stats.iodchunks;
7129 sas.sas_ouodchunks = asoc->stats.ouodchunks;
7130 sas.sas_iuodchunks = asoc->stats.iuodchunks;
7131 sas.sas_idupchunks = asoc->stats.idupchunks;
7132 sas.sas_opackets = asoc->stats.opackets;
7133 sas.sas_ipackets = asoc->stats.ipackets;
7139 sas.sas_maxrto = asoc->stats.max_obs_rto;
7140 memcpy(&sas.sas_obs_rto_ipaddr, &asoc->stats.obs_rto_ipaddr,
7144 asoc->stats.max_obs_rto = asoc->rto_min;
7202 struct sctp_association *asoc;
7214 asoc = sctp_id2assoc(sk, params.assoc_id);
7215 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7221 params.assoc_value = asoc ? asoc->peer.prsctp_capable
7241 struct sctp_association *asoc;
7253 asoc = sctp_id2assoc(sk, info.pr_assoc_id);
7254 if (!asoc && info.pr_assoc_id != SCTP_FUTURE_ASSOC &&
7260 if (asoc) {
7261 info.pr_policy = SCTP_PR_POLICY(asoc->default_flags);
7262 info.pr_value = asoc->default_timetolive;
7287 struct sctp_association *asoc;
7305 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7306 if (!asoc)
7314 asoc->abandoned_unsent[policy];
7316 asoc->abandoned_sent[policy];
7320 asoc->abandoned_unsent[__SCTP_PR_INDEX(policy)];
7322 asoc->abandoned_sent[__SCTP_PR_INDEX(policy)];
7346 struct sctp_association *asoc;
7365 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7366 if (!asoc || params.sprstat_sid >= asoc->stream.outcnt)
7369 streamoute = SCTP_SO(&asoc->stream, params.sprstat_sid)->ext;
7410 struct sctp_association *asoc;
7422 asoc = sctp_id2assoc(sk, params.assoc_id);
7423 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7429 params.assoc_value = asoc ? asoc->peer.reconf_capable
7449 struct sctp_association *asoc;
7461 asoc = sctp_id2assoc(sk, params.assoc_id);
7462 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7468 params.assoc_value = asoc ? asoc->strreset_enable
7488 struct sctp_association *asoc;
7500 asoc = sctp_id2assoc(sk, params.assoc_id);
7501 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7507 params.assoc_value = asoc ? sctp_sched_get_sched(asoc)
7527 struct sctp_association *asoc;
7539 asoc = sctp_id2assoc(sk, params.assoc_id);
7540 if (!asoc) {
7545 retval = sctp_sched_get_value(asoc, params.stream_id,
7569 struct sctp_association *asoc;
7581 asoc = sctp_id2assoc(sk, params.assoc_id);
7582 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7588 params.assoc_value = asoc ? asoc->peer.intl_capable
7626 struct sctp_association *asoc;
7641 asoc = sctp_id2assoc(sk, param.se_assoc_id);
7642 if (!asoc && param.se_assoc_id != SCTP_FUTURE_ASSOC &&
7646 subscribe = asoc ? asoc->subscribe : sctp_sk(sk)->subscribe;
7663 struct sctp_association *asoc;
7675 asoc = sctp_id2assoc(sk, params.assoc_id);
7676 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7682 params.assoc_value = asoc ? asoc->peer.asconf_capable
7702 struct sctp_association *asoc;
7714 asoc = sctp_id2assoc(sk, params.assoc_id);
7715 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7721 params.assoc_value = asoc ? asoc->peer.auth_capable
7741 struct sctp_association *asoc;
7753 asoc = sctp_id2assoc(sk, params.assoc_id);
7754 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7760 params.assoc_value = asoc ? asoc->peer.ecn_capable
7780 struct sctp_association *asoc;
7792 asoc = sctp_id2assoc(sk, params.assoc_id);
7793 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7799 params.assoc_value = asoc ? asoc->pf_expose
8823 static void __sctp_write_space(struct sctp_association *asoc)
8825 struct sock *sk = asoc->base.sk;
8827 if (sctp_wspace(asoc) <= 0)
8830 if (waitqueue_active(&asoc->wait))
8831 wake_up_interruptible(&asoc->wait);
8854 struct sctp_association *asoc)
8856 struct sctp_association *tmp = asoc;
8861 if (asoc->ep->sndbuf_policy)
8862 return __sctp_write_space(asoc);
8867 if (asoc->base.dead)
8888 if (tmp == asoc)
8900 struct sctp_association *asoc = chunk->asoc;
8901 struct sock *sk = asoc->base.sk;
8905 asoc->sndbuf_used -= skb->truesize + sizeof(struct sctp_chunk);
8920 ev = sctp_ulpevent_make_authkey(asoc, shkey->key_id,
8924 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
8930 sctp_wake_up_waiters(sk, asoc);
8932 sctp_association_put(asoc);
8955 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
8958 struct sock *sk = asoc->base.sk;
8963 pr_debug("%s: asoc:%p, timeo:%ld, msg_len:%zu\n", __func__, asoc,
8967 sctp_association_hold(asoc);
8971 prepare_to_wait_exclusive(&asoc->wait, &wait,
8973 if (asoc->base.dead)
8977 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING)
8983 if ((int)msg_len <= sctp_wspace(asoc) &&
8993 if (sk != asoc->base.sk)
9000 finish_wait(&asoc->wait, &wait);
9003 sctp_association_put(asoc);
9040 struct sctp_association *asoc;
9043 list_for_each_entry(asoc, &((sctp_sk(sk))->ep->asocs), asocs) {
9044 __sctp_write_space(asoc);
9067 static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)
9069 struct sock *sk = asoc->base.sk;
9074 pr_debug("%s: asoc:%p, timeo:%ld\n", __func__, asoc, *timeo_p);
9077 sctp_association_hold(asoc);
9080 prepare_to_wait_exclusive(&asoc->wait, &wait,
9086 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||
9087 asoc->base.dead)
9092 if (sctp_state(asoc, ESTABLISHED))
9106 finish_wait(&asoc->wait, &wait);
9109 sctp_association_put(asoc);
9114 if (asoc->init_err_counter + 1 > asoc->max_init_attempts)
9202 struct sctp_association *asoc)
9238 newinet->inet_dport = htons(asoc->peer.port);
9332 if (event->asoc == assoc) {
9361 if (event->asoc == assoc) {