Lines Matching refs:asoc

75 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
88 static int sctp_send_asconf(struct sctp_association *asoc,
108 static inline int sctp_wspace(struct sctp_association *asoc)
110 struct sock *sk = asoc->base.sk;
112 return asoc->ep->sndbuf_policy ? sk->sk_sndbuf - asoc->sndbuf_used
127 struct sctp_association *asoc = chunk->asoc;
128 struct sock *sk = asoc->base.sk;
131 sctp_association_hold(asoc);
143 asoc->sndbuf_used += chunk->skb->truesize + sizeof(struct sctp_chunk);
159 if ((clear && asoc->base.sk == c->skb->sk) || \
160 (!clear && asoc->base.sk != c->skb->sk)) \
166 static void sctp_for_each_tx_datachunk(struct sctp_association *asoc,
172 struct sctp_outq *q = &asoc->outqueue;
176 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports)
193 static void sctp_for_each_rx_skb(struct sctp_association *asoc, struct sock *sk,
199 sctp_skb_for_each(skb, &asoc->ulpq.lobby, tmp)
202 sctp_skb_for_each(skb, &asoc->ulpq.reasm, tmp)
205 sctp_skb_for_each(skb, &asoc->ulpq.reasm_uo, tmp)
235 struct sctp_association *asoc = NULL;
248 asoc = list_entry(sctp_sk(sk)->ep->asocs.next,
250 return asoc;
258 asoc = (struct sctp_association *)idr_find(&sctp_assocs_id, (int)id);
259 if (asoc && (asoc->base.sk != sk || asoc->base.dead))
260 asoc = NULL;
263 return asoc;
468 static int sctp_send_asconf(struct sctp_association *asoc,
476 if (asoc->addip_last_asconf) {
477 list_add_tail(&chunk->list, &asoc->addip_chunk_list);
483 retval = sctp_primitive_ASCONF(asoc->base.net, asoc, chunk);
487 asoc->addip_last_asconf = chunk;
561 struct sctp_association *asoc;
582 list_for_each_entry(asoc, &ep->asocs, asocs) {
583 if (!asoc->peer.asconf_capable)
586 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_ADD_IP)
589 if (!sctp_state(asoc, ESTABLISHED))
606 if (sctp_assoc_lookup_laddr(asoc, addr))
617 bp = &asoc->base.bind_addr;
620 chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs,
640 if (asoc->src_out_of_asoc_ok) {
644 &asoc->peer.transport_addr_list, transports) {
645 trans->cwnd = min(4*asoc->pathmtu, max_t(__u32,
646 2*asoc->pathmtu, 4380));
647 trans->ssthresh = asoc->peer.i.a_rwnd;
648 trans->rto = asoc->rto_initial;
649 sctp_max_rto(asoc, trans);
653 sctp_sk(asoc->base.sk));
656 retval = sctp_send_asconf(asoc, chunk);
763 struct sctp_association *asoc;
785 list_for_each_entry(asoc, &ep->asocs, asocs) {
787 if (!asoc->peer.asconf_capable)
790 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_DEL_IP)
793 if (!sctp_state(asoc, ESTABLISHED))
810 if (!sctp_assoc_lookup_laddr(asoc, laddr))
823 bp = &asoc->base.bind_addr;
827 if (asoc->asconf_addr_del_pending)
829 asoc->asconf_addr_del_pending =
831 if (asoc->asconf_addr_del_pending == NULL) {
835 asoc->asconf_addr_del_pending->sa.sa_family =
837 asoc->asconf_addr_del_pending->v4.sin_port =
843 asoc->asconf_addr_del_pending->v4.sin_addr.s_addr = sin->sin_addr.s_addr;
848 asoc->asconf_addr_del_pending->v6.sin6_addr = sin6->sin6_addr;
851 pr_debug("%s: keep the last address asoc:%p %pISc at %p\n",
852 __func__, asoc, &asoc->asconf_addr_del_pending->sa,
853 asoc->asconf_addr_del_pending);
855 asoc->src_out_of_asoc_ok = 1;
867 chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt,
893 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
896 sctp_sk(asoc->base.sk));
902 retval = sctp_send_asconf(asoc, chunk);
1072 struct sctp_association *asoc;
1091 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
1092 if (!asoc)
1095 err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, GFP_KERNEL);
1099 *tp = sctp_assoc_add_peer(asoc, daddr, GFP_KERNEL, SCTP_UNKNOWN);
1111 asoc->c.sinit_num_ostreams = outcnt;
1113 err = sctp_stream_init(&asoc->stream, outcnt, 0, GFP_KERNEL);
1119 asoc->c.sinit_max_instreams = init->sinit_max_instreams;
1122 asoc->max_init_attempts = init->sinit_max_attempts;
1125 asoc->max_init_timeo =
1130 sctp_association_free(asoc);
1134 static int sctp_connect_add_peer(struct sctp_association *asoc,
1137 struct sctp_endpoint *ep = asoc->ep;
1147 if (old && old != asoc)
1154 t = sctp_assoc_add_peer(asoc, daddr, GFP_KERNEL, SCTP_UNKNOWN);
1172 struct sctp_association *asoc;
1192 asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
1193 if (asoc)
1194 return asoc->state >= SCTP_STATE_ESTABLISHED ? -EISCONN
1200 asoc = transport->asoc;
1214 if (asoc->peer.port != ntohs(daddr->v4.sin_port))
1217 err = sctp_connect_add_peer(asoc, daddr, af->sockaddr_len);
1229 err = sctp_assoc_set_id(asoc, GFP_KERNEL);
1234 err = sctp_primitive_ASSOCIATE(sock_net(sk), asoc, NULL);
1239 inet_sk(sk)->inet_dport = htons(asoc->peer.port);
1244 *assoc_id = asoc->assoc_id;
1247 return sctp_wait_for_connect(asoc, &timeo);
1250 pr_debug("%s: took out_free path with asoc:%p kaddrs:%p err:%d\n",
1251 __func__, asoc, kaddrs, err);
1252 sctp_association_free(asoc);
1260 * sctp_assoc_t *asoc);
1487 struct sctp_association *asoc;
1505 asoc = list_entry(pos, struct sctp_association, asocs);
1513 if (sctp_state(asoc, CLOSED)) {
1514 sctp_association_free(asoc);
1519 if (data_was_unread || !skb_queue_empty(&asoc->ulpq.lobby) ||
1520 !skb_queue_empty(&asoc->ulpq.reasm) ||
1521 !skb_queue_empty(&asoc->ulpq.reasm_uo) ||
1525 chunk = sctp_make_abort_user(asoc, NULL, 0);
1526 sctp_primitive_ABORT(net, asoc, chunk);
1528 sctp_primitive_SHUTDOWN(net, asoc, NULL);
1663 struct sctp_association *asoc;
1696 asoc = (*tp)->asoc;
1725 daddr->v4.sin_port = htons(asoc->peer.port);
1736 daddr->v6.sin6_port = htons(asoc->peer.port);
1740 err = sctp_connect_add_peer(asoc, daddr, sizeof(*daddr));
1748 sctp_association_free(asoc);
1752 static int sctp_sendmsg_check_sflags(struct sctp_association *asoc,
1756 struct sock *sk = asoc->base.sk;
1759 if (sctp_state(asoc, CLOSED) && sctp_style(sk, TCP))
1763 !sctp_state(asoc, ESTABLISHED))
1767 pr_debug("%s: shutting down association:%p\n", __func__, asoc);
1768 sctp_primitive_SHUTDOWN(net, asoc, NULL);
1776 chunk = sctp_make_abort_user(asoc, msg, msg_len);
1780 pr_debug("%s: aborting association:%p\n", __func__, asoc);
1781 sctp_primitive_ABORT(net, asoc, chunk);
1790 static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
1795 struct sock *sk = asoc->base.sk;
1804 if (sinfo->sinfo_stream >= asoc->stream.outcnt) {
1809 if (unlikely(!SCTP_SO(&asoc->stream, sinfo->sinfo_stream)->ext)) {
1810 err = sctp_stream_init_ext(&asoc->stream, sinfo->sinfo_stream);
1815 if (sp->disable_fragments && msg_len > asoc->frag_point) {
1820 if (asoc->pmtu_pending) {
1822 sctp_assoc_sync_pmtu(asoc);
1823 asoc->pmtu_pending = 0;
1826 if (sctp_wspace(asoc) < (int)msg_len)
1827 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);
2178 sctp_assoc_rwnd_increase(event->asoc, copied);
2224 struct sctp_association *asoc;
2234 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
2235 asoc->subscribe = sctp_sk(sk)->subscribe;
2244 asoc = sctp_id2assoc(sk, 0);
2245 if (asoc && sctp_outq_is_empty(&asoc->outqueue)) {
2246 event = sctp_ulpevent_make_sender_dry_event(asoc,
2251 asoc->stream.si->enqueue_event(&asoc->ulpq, event);
2428 struct sctp_association *asoc,
2437 error = sctp_primitive_REQUESTHEARTBEAT(trans->asoc->base.net,
2438 trans->asoc, trans);
2462 } else if (asoc) {
2463 asoc->hbinterval =
2475 } else if (asoc) {
2476 asoc->param_flags =
2477 (asoc->param_flags & ~SPP_HB) | hb_change;
2492 sctp_assoc_sync_pmtu(asoc);
2493 } else if (asoc) {
2494 sctp_assoc_set_pmtu(asoc, params->spp_pathmtu);
2508 sctp_assoc_sync_pmtu(asoc);
2511 } else if (asoc) {
2512 asoc->param_flags =
2513 (asoc->param_flags & ~SPP_PMTUD) | pmtud_change;
2528 } else if (asoc) {
2529 asoc->sackdelay =
2541 } else if (asoc) {
2542 asoc->param_flags =
2543 (asoc->param_flags & ~SPP_SACKDELAY) |
2558 } else if (asoc) {
2559 asoc->pathmaxrxt = params->spp_pathmaxrxt;
2572 } else if (asoc) {
2575 list_for_each_entry(t, &asoc->peer.transport_addr_list,
2583 asoc->flowlabel = params->spp_ipv6_flowlabel &
2585 asoc->flowlabel |= SCTP_FLOWLABEL_SET_MASK;
2597 } else if (asoc) {
2600 list_for_each_entry(t, &asoc->peer.transport_addr_list,
2606 asoc->dscp = params->spp_dscp & SCTP_DSCP_VAL_MASK;
2607 asoc->dscp |= SCTP_DSCP_SET_MASK;
2622 struct sctp_association *asoc = NULL;
2662 asoc = sctp_id2assoc(sk, params->spp_assoc_id);
2663 if (!asoc && params->spp_assoc_id != SCTP_FUTURE_ASSOC &&
2670 if (params->spp_flags & SPP_HB_DEMAND && !trans && !asoc)
2674 error = sctp_apply_peer_addr_params(params, trans, asoc, sp,
2684 if (!trans && asoc) {
2685 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2687 sctp_apply_peer_addr_params(params, trans, asoc, sp,
2707 struct sctp_association *asoc)
2712 asoc->sackdelay = msecs_to_jiffies(params->sack_delay);
2713 asoc->param_flags =
2714 sctp_spp_sackdelay_enable(asoc->param_flags);
2717 asoc->param_flags =
2718 sctp_spp_sackdelay_disable(asoc->param_flags);
2720 asoc->sackfreq = params->sack_freq;
2721 asoc->param_flags =
2722 sctp_spp_sackdelay_enable(asoc->param_flags);
2725 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2782 struct sctp_association *asoc;
2792 asoc = sctp_id2assoc(sk, params->sack_assoc_id);
2793 if (!asoc && params->sack_assoc_id > SCTP_ALL_ASSOC &&
2797 if (asoc) {
2798 sctp_apply_asoc_delayed_ack(params, asoc);
2825 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
2826 sctp_apply_asoc_delayed_ack(params, asoc);
2908 struct sctp_association *asoc;
2917 asoc = sctp_id2assoc(sk, info->sinfo_assoc_id);
2918 if (!asoc && info->sinfo_assoc_id > SCTP_ALL_ASSOC &&
2922 if (asoc) {
2923 asoc->default_stream = info->sinfo_stream;
2924 asoc->default_flags = info->sinfo_flags;
2925 asoc->default_ppid = info->sinfo_ppid;
2926 asoc->default_context = info->sinfo_context;
2927 asoc->default_timetolive = info->sinfo_timetolive;
2946 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
2947 asoc->default_stream = info->sinfo_stream;
2948 asoc->default_flags = info->sinfo_flags;
2949 asoc->default_ppid = info->sinfo_ppid;
2950 asoc->default_context = info->sinfo_context;
2951 asoc->default_timetolive = info->sinfo_timetolive;
2966 struct sctp_association *asoc;
2975 asoc = sctp_id2assoc(sk, info->snd_assoc_id);
2976 if (!asoc && info->snd_assoc_id > SCTP_ALL_ASSOC &&
2980 if (asoc) {
2981 asoc->default_stream = info->snd_sid;
2982 asoc->default_flags = info->snd_flags;
2983 asoc->default_ppid = info->snd_ppid;
2984 asoc->default_context = info->snd_context;
3002 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
3003 asoc->default_stream = info->snd_sid;
3004 asoc->default_flags = info->snd_flags;
3005 asoc->default_ppid = info->snd_ppid;
3006 asoc->default_context = info->snd_context;
3044 sctp_assoc_set_primary(trans->asoc, trans);
3082 struct sctp_association *asoc;
3089 asoc = sctp_id2assoc(sk, rtoinfo->srto_assoc_id);
3092 if (!asoc && rtoinfo->srto_assoc_id != SCTP_FUTURE_ASSOC &&
3100 rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max;
3102 rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max;
3105 rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min;
3107 rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min;
3112 if (asoc) {
3114 asoc->rto_initial =
3116 asoc->rto_max = rto_max;
3117 asoc->rto_min = rto_min;
3147 struct sctp_association *asoc;
3152 asoc = sctp_id2assoc(sk, assocparams->sasoc_assoc_id);
3154 if (!asoc && assocparams->sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
3159 if (asoc) {
3165 list_for_each_entry(peer_addr, &asoc->peer.transport_addr_list,
3180 asoc->max_retrans = assocparams->sasoc_asocmaxrxt;
3184 asoc->cookie_life =
3257 struct sctp_association *asoc;
3276 asoc = sctp_id2assoc(sk, assoc_id);
3277 if (!asoc && assoc_id != SCTP_FUTURE_ASSOC &&
3283 __u16 datasize = asoc ? sctp_datachk_len(&asoc->stream) :
3293 if (asoc) {
3294 asoc->user_frag = val;
3295 sctp_assoc_update_frag_point(asoc);
3317 struct sctp_association *asoc = NULL;
3330 asoc = sctp_id2assoc(sk, prim->sspp_assoc_id);
3331 if (!asoc)
3334 if (!asoc->peer.asconf_capable)
3337 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_SET_PRIMARY)
3340 if (!sctp_state(asoc, ESTABLISHED))
3350 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim->sspp_addr))
3361 chunk = sctp_make_asconf_set_prim(asoc,
3366 err = sctp_send_asconf(asoc, chunk);
3404 struct sctp_association *asoc;
3409 asoc = sctp_id2assoc(sk, params->assoc_id);
3410 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
3414 if (asoc) {
3415 asoc->default_rcv_context = params->assoc_value;
3429 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
3430 asoc->default_rcv_context = params->assoc_value;
3523 struct sctp_association *asoc;
3541 asoc = sctp_id2assoc(sk, assoc_id);
3542 if (!asoc && assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP))
3545 if (asoc) {
3546 asoc->max_burst = assoc_value;
3558 list_for_each_entry(asoc, &sp->ep->asocs, asocs)
3559 asoc->max_burst = assoc_value;
3635 struct sctp_association *asoc;
3648 asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
3649 if (!asoc && authkey->sca_assoc_id > SCTP_ALL_ASSOC &&
3653 if (asoc) {
3654 ret = sctp_auth_set_key(ep, asoc, authkey);
3663 ret = sctp_auth_set_key(ep, asoc, authkey);
3672 list_for_each_entry(asoc, &ep->asocs, asocs) {
3673 int res = sctp_auth_set_key(ep, asoc, authkey);
3696 struct sctp_association *asoc;
3702 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3703 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3707 if (asoc)
3708 return sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
3715 ret = sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
3722 list_for_each_entry(asoc, &ep->asocs, asocs) {
3723 int res = sctp_auth_set_active_key(ep, asoc,
3744 struct sctp_association *asoc;
3750 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3751 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3755 if (asoc)
3756 return sctp_auth_del_key_id(ep, asoc, val->scact_keynumber);
3763 ret = sctp_auth_del_key_id(ep, asoc, val->scact_keynumber);
3770 list_for_each_entry(asoc, &ep->asocs, asocs) {
3771 int res = sctp_auth_del_key_id(ep, asoc,
3792 struct sctp_association *asoc;
3798 asoc = sctp_id2assoc(sk, val->scact_assoc_id);
3799 if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
3803 if (asoc)
3804 return sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber);
3811 ret = sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber);
3818 list_for_each_entry(asoc, &ep->asocs, asocs) {
3819 int res = sctp_auth_deact_key_id(ep, asoc,
3881 struct sctp_association *asoc;
3906 asoc = sctp_id2assoc(sk, val->spt_assoc_id);
3907 if (!asoc && val->spt_assoc_id != SCTP_FUTURE_ASSOC &&
3911 if (asoc) {
3912 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
3922 asoc->pathmaxrxt = val->spt_pathmaxrxt;
3924 asoc->ps_retrans = val->spt_pathcpthld;
3925 asoc->pf_retrans = val->spt_pathpfthld;
3965 struct sctp_association *asoc;
3970 asoc = sctp_id2assoc(sk, params->assoc_id);
3971 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
3985 struct sctp_association *asoc;
3997 asoc = sctp_id2assoc(sk, info->pr_assoc_id);
3998 if (!asoc && info->pr_assoc_id > SCTP_ALL_ASSOC &&
4004 if (asoc) {
4005 SCTP_PR_SET_POLICY(asoc->default_flags, info->pr_policy);
4006 asoc->default_timetolive = info->pr_value;
4021 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4022 SCTP_PR_SET_POLICY(asoc->default_flags,
4024 asoc->default_timetolive = info->pr_value;
4036 struct sctp_association *asoc;
4042 asoc = sctp_id2assoc(sk, params->assoc_id);
4043 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4060 struct sctp_association *asoc;
4069 asoc = sctp_id2assoc(sk, params->assoc_id);
4070 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
4076 if (asoc) {
4077 asoc->strreset_enable = params->assoc_value;
4090 list_for_each_entry(asoc, &ep->asocs, asocs)
4091 asoc->strreset_enable = params->assoc_value;
4101 struct sctp_association *asoc;
4113 asoc = sctp_id2assoc(sk, params->srs_assoc_id);
4114 if (!asoc)
4117 return sctp_send_reset_streams(asoc, params);
4123 struct sctp_association *asoc;
4128 asoc = sctp_id2assoc(sk, *associd);
4129 if (!asoc)
4132 return sctp_send_reset_assoc(asoc);
4139 struct sctp_association *asoc;
4144 asoc = sctp_id2assoc(sk, params->sas_assoc_id);
4145 if (!asoc)
4148 return sctp_send_add_streams(asoc, params);
4156 struct sctp_association *asoc;
4165 asoc = sctp_id2assoc(sk, params->assoc_id);
4166 if (!asoc && params->assoc_id > SCTP_ALL_ASSOC &&
4170 if (asoc)
4171 return sctp_sched_set_sched(asoc, params->assoc_value);
4182 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4183 int ret = sctp_sched_set_sched(asoc,
4198 struct sctp_association *asoc;
4204 asoc = sctp_id2assoc(sk, params->assoc_id);
4205 if (!asoc && params->assoc_id != SCTP_CURRENT_ASSOC &&
4209 if (asoc) {
4210 retval = sctp_sched_set_value(asoc, params->stream_id,
4217 list_for_each_entry(asoc, &sctp_sk(sk)->ep->asocs, asocs) {
4218 int ret = sctp_sched_set_value(asoc, params->stream_id,
4234 struct sctp_association *asoc;
4239 asoc = sctp_id2assoc(sk, p->assoc_id);
4240 if (!asoc && p->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP))
4269 struct sctp_association *asoc)
4273 sctp_ulpevent_type_set(&asoc->subscribe, param->se_type, param->se_on);
4276 if (sctp_outq_is_empty(&asoc->outqueue)) {
4277 event = sctp_ulpevent_make_sender_dry_event(asoc,
4282 asoc->stream.si->enqueue_event(&asoc->ulpq, event);
4293 struct sctp_association *asoc;
4303 asoc = sctp_id2assoc(sk, param->se_assoc_id);
4304 if (!asoc && param->se_assoc_id > SCTP_ALL_ASSOC &&
4308 if (asoc)
4309 return sctp_assoc_ulpevent_type_set(param, asoc);
4321 list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
4322 int ret = sctp_assoc_ulpevent_type_set(param, asoc);
4336 struct sctp_association *asoc;
4343 asoc = sctp_id2assoc(sk, params->assoc_id);
4344 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4366 struct sctp_association *asoc;
4373 asoc = sctp_id2assoc(sk, params->assoc_id);
4374 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4400 struct sctp_association *asoc;
4406 asoc = sctp_id2assoc(sk, params->assoc_id);
4407 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4422 struct sctp_association *asoc;
4431 asoc = sctp_id2assoc(sk, params->assoc_id);
4432 if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC &&
4436 if (asoc)
4437 asoc->pf_expose = params->assoc_value;
4450 struct sctp_association *asoc;
4475 asoc = sctp_id2assoc(sk, encap->sue_assoc_id);
4476 if (!asoc && encap->sue_assoc_id != SCTP_FUTURE_ASSOC &&
4483 if (asoc) {
4484 list_for_each_entry(t, &asoc->peer.transport_addr_list,
4488 asoc->encap_port = encap_port;
4500 struct sctp_association *asoc;
4529 asoc = sctp_id2assoc(sk, params->spi_assoc_id);
4530 if (!asoc && params->spi_assoc_id != SCTP_FUTURE_ASSOC &&
4537 if (asoc) {
4538 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
4543 asoc->probe_interval = msecs_to_jiffies(probe_interval);
4855 struct sctp_association *asoc;
4883 asoc = list_entry(ep->asocs.next, struct sctp_association, asocs);
4885 newsk = sp->pf->create_accept_sk(sk, asoc, kern);
4892 * asoc to the newsk.
4894 error = sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP);
5155 struct sctp_association *asoc;
5158 asoc = list_entry(ep->asocs.next,
5160 sctp_primitive_SHUTDOWN(net, asoc, NULL);
5164 int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc,
5172 if (!asoc) {
5187 info->sctpi_tag = asoc->c.my_vtag;
5188 info->sctpi_state = asoc->state;
5189 info->sctpi_rwnd = asoc->a_rwnd;
5190 info->sctpi_unackdata = asoc->unack_data;
5191 info->sctpi_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map);
5192 info->sctpi_instrms = asoc->stream.incnt;
5193 info->sctpi_outstrms = asoc->stream.outcnt;
5194 list_for_each(pos, &asoc->base.inqueue.in_chunk_list)
5196 list_for_each(pos, &asoc->outqueue.out_chunk_list)
5198 info->sctpi_overall_error = asoc->overall_error_count;
5199 info->sctpi_max_burst = asoc->max_burst;
5200 info->sctpi_maxseg = asoc->frag_point;
5201 info->sctpi_peer_rwnd = asoc->peer.rwnd;
5202 info->sctpi_peer_tag = asoc->c.peer_vtag;
5204 mask = asoc->peer.intl_capable << 1;
5205 mask = (mask | asoc->peer.ecn_capable) << 1;
5206 mask = (mask | asoc->peer.ipv4_address) << 1;
5207 mask = (mask | asoc->peer.ipv6_address) << 1;
5208 mask = (mask | asoc->peer.reconf_capable) << 1;
5209 mask = (mask | asoc->peer.asconf_capable) << 1;
5210 mask = (mask | asoc->peer.prsctp_capable) << 1;
5211 mask = (mask | asoc->peer.auth_capable);
5213 mask = asoc->peer.sack_needed << 1;
5214 mask = (mask | asoc->peer.sack_generation) << 1;
5215 mask = (mask | asoc->peer.zero_window_announced);
5218 info->sctpi_isacks = asoc->stats.isacks;
5219 info->sctpi_osacks = asoc->stats.osacks;
5220 info->sctpi_opackets = asoc->stats.opackets;
5221 info->sctpi_ipackets = asoc->stats.ipackets;
5222 info->sctpi_rtxchunks = asoc->stats.rtxchunks;
5223 info->sctpi_outofseqtsns = asoc->stats.outofseqtsns;
5224 info->sctpi_idupchunks = asoc->stats.idupchunks;
5225 info->sctpi_gapcnt = asoc->stats.gapcnt;
5226 info->sctpi_ouodchunks = asoc->stats.ouodchunks;
5227 info->sctpi_iuodchunks = asoc->stats.iuodchunks;
5228 info->sctpi_oodchunks = asoc->stats.oodchunks;
5229 info->sctpi_iodchunks = asoc->stats.iodchunks;
5230 info->sctpi_octrlchunks = asoc->stats.octrlchunks;
5231 info->sctpi_ictrlchunks = asoc->stats.ictrlchunks;
5233 prim = asoc->peer.primary_path;
5281 if (net_eq(t->asoc->base.net, net) &&
5282 t->asoc->peer.primary_path == t)
5345 ep = transport->asoc->ep;
5346 if (!sctp_endpoint_hold(ep)) { /* asoc can be peeled off */
5374 ep = tsp->asoc->ep;
5375 if (sctp_endpoint_hold(ep)) { /* asoc can be peeled off */
5413 struct sctp_association *asoc = NULL;
5430 asoc = sctp_id2assoc(sk, associd);
5431 if (!asoc) {
5436 transport = asoc->peer.primary_path;
5438 status.sstat_assoc_id = sctp_assoc2id(asoc);
5439 status.sstat_state = sctp_assoc_to_state(asoc);
5440 status.sstat_rwnd = asoc->peer.rwnd;
5441 status.sstat_unackdata = asoc->unack_data;
5443 status.sstat_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map);
5444 status.sstat_instrms = asoc->stream.incnt;
5445 status.sstat_outstrms = asoc->stream.outcnt;
5446 status.sstat_fragmentation_point = asoc->frag_point;
5447 status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
5515 transport->asoc->pf_expose == SCTP_PF_EXPOSE_DISABLE) {
5520 pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
5626 struct sctp_association *asoc = sctp_id2assoc(sk, id);
5635 if (!asoc)
5649 sctp_copy_sock(sock->sk, sk, asoc);
5655 sp->pf->to_sk_daddr(&asoc->peer.primary_addr, sock->sk);
5659 * asoc to the newsk.
5661 err = sctp_sock_migrate(sk, sock->sk, asoc,
5915 struct sctp_association *asoc = NULL;
5946 asoc = sctp_id2assoc(sk, params.spp_assoc_id);
5947 if (!asoc && params.spp_assoc_id != SCTP_FUTURE_ASSOC &&
5971 } else if (asoc) {
5973 params.spp_hbinterval = jiffies_to_msecs(asoc->hbinterval);
5974 params.spp_pathmtu = asoc->pathmtu;
5975 params.spp_pathmaxrxt = asoc->pathmaxrxt;
5976 params.spp_sackdelay = jiffies_to_msecs(asoc->sackdelay);
5979 params.spp_flags = asoc->param_flags;
5980 if (asoc->flowlabel & SCTP_FLOWLABEL_SET_MASK) {
5981 params.spp_ipv6_flowlabel = asoc->flowlabel &
5985 if (asoc->dscp & SCTP_DSCP_SET_MASK) {
5986 params.spp_dscp = asoc->dscp & SCTP_DSCP_VAL_MASK;
6058 struct sctp_association *asoc = NULL;
6081 asoc = sctp_id2assoc(sk, params.sack_assoc_id);
6082 if (!asoc && params.sack_assoc_id != SCTP_FUTURE_ASSOC &&
6086 if (asoc) {
6088 if (asoc->param_flags & SPP_SACKDELAY_ENABLE) {
6089 params.sack_delay = jiffies_to_msecs(asoc->sackdelay);
6090 params.sack_freq = asoc->sackfreq;
6143 struct sctp_association *asoc;
6161 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
6162 if (!asoc)
6168 list_for_each_entry(from, &asoc->peer.transport_addr_list,
6240 struct sctp_association *asoc;
6269 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
6270 if (!asoc)
6272 bp = &asoc->base.bind_addr;
6348 struct sctp_association *asoc;
6359 asoc = sctp_id2assoc(sk, prim.ssp_assoc_id);
6360 if (!asoc)
6363 if (!asoc->peer.primary_path)
6366 memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr,
6367 asoc->peer.primary_path->af_specific->sockaddr_len);
6430 struct sctp_association *asoc;
6441 asoc = sctp_id2assoc(sk, info.sinfo_assoc_id);
6442 if (!asoc && info.sinfo_assoc_id != SCTP_FUTURE_ASSOC &&
6446 if (asoc) {
6447 info.sinfo_stream = asoc->default_stream;
6448 info.sinfo_flags = asoc->default_flags;
6449 info.sinfo_ppid = asoc->default_ppid;
6450 info.sinfo_context = asoc->default_context;
6451 info.sinfo_timetolive = asoc->default_timetolive;
6476 struct sctp_association *asoc;
6487 asoc = sctp_id2assoc(sk, info.snd_assoc_id);
6488 if (!asoc && info.snd_assoc_id != SCTP_FUTURE_ASSOC &&
6492 if (asoc) {
6493 info.snd_sid = asoc->default_stream;
6494 info.snd_flags = asoc->default_flags;
6495 info.snd_ppid = asoc->default_ppid;
6496 info.snd_context = asoc->default_context;
6555 struct sctp_association *asoc;
6565 asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id);
6567 if (!asoc && rtoinfo.srto_assoc_id != SCTP_FUTURE_ASSOC &&
6572 if (asoc) {
6573 rtoinfo.srto_initial = jiffies_to_msecs(asoc->rto_initial);
6574 rtoinfo.srto_max = jiffies_to_msecs(asoc->rto_max);
6575 rtoinfo.srto_min = jiffies_to_msecs(asoc->rto_min);
6611 struct sctp_association *asoc;
6623 asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id);
6625 if (!asoc && assocparams.sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
6630 if (asoc) {
6631 assocparams.sasoc_asocmaxrxt = asoc->max_retrans;
6632 assocparams.sasoc_peer_rwnd = asoc->peer.rwnd;
6633 assocparams.sasoc_local_rwnd = asoc->a_rwnd;
6634 assocparams.sasoc_cookie_life = ktime_to_ms(asoc->cookie_life);
6636 list_for_each(pos, &asoc->peer.transport_addr_list) {
6701 struct sctp_association *asoc;
6711 asoc = sctp_id2assoc(sk, params.assoc_id);
6712 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6716 params.assoc_value = asoc ? asoc->default_rcv_context
6758 struct sctp_association *asoc;
6774 asoc = sctp_id2assoc(sk, params.assoc_id);
6775 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6779 if (asoc)
6780 params.assoc_value = asoc->frag_point;
6853 struct sctp_association *asoc;
6869 asoc = sctp_id2assoc(sk, params.assoc_id);
6870 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
6874 params.assoc_value = asoc ? asoc->max_burst : sctp_sk(sk)->max_burst;
6929 struct sctp_association *asoc;
6938 asoc = sctp_id2assoc(sk, val.scact_assoc_id);
6939 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP))
6942 if (asoc) {
6943 if (!asoc->peer.auth_capable)
6945 val.scact_keynumber = asoc->active_key_id;
6965 struct sctp_association *asoc;
6977 asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
6978 if (!asoc)
6981 if (!asoc->peer.auth_capable)
6984 ch = asoc->peer.peer_chunks;
7010 struct sctp_association *asoc;
7022 asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
7023 if (!asoc && val.gauth_assoc_id != SCTP_FUTURE_ASSOC &&
7027 if (asoc) {
7028 if (!asoc->peer.auth_capable)
7030 ch = (struct sctp_chunks_param *)asoc->c.auth_chunks;
7064 struct sctp_association *asoc;
7075 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7120 struct sctp_association *asoc;
7130 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7145 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
7146 ids->gaids_assoc_id[num++] = asoc->assoc_id;
7171 struct sctp_association *asoc;
7194 asoc = sctp_id2assoc(sk, val.spt_assoc_id);
7195 if (!asoc && val.spt_assoc_id != SCTP_FUTURE_ASSOC &&
7199 if (asoc) {
7200 val.spt_pathpfthld = asoc->pf_retrans;
7201 val.spt_pathmaxrxt = asoc->pathmaxrxt;
7202 val.spt_pathcpthld = asoc->ps_retrans;
7229 struct sctp_association *asoc = NULL;
7241 asoc = sctp_id2assoc(sk, sas.sas_assoc_id);
7242 if (!asoc)
7245 sas.sas_rtxchunks = asoc->stats.rtxchunks;
7246 sas.sas_gapcnt = asoc->stats.gapcnt;
7247 sas.sas_outofseqtsns = asoc->stats.outofseqtsns;
7248 sas.sas_osacks = asoc->stats.osacks;
7249 sas.sas_isacks = asoc->stats.isacks;
7250 sas.sas_octrlchunks = asoc->stats.octrlchunks;
7251 sas.sas_ictrlchunks = asoc->stats.ictrlchunks;
7252 sas.sas_oodchunks = asoc->stats.oodchunks;
7253 sas.sas_iodchunks = asoc->stats.iodchunks;
7254 sas.sas_ouodchunks = asoc->stats.ouodchunks;
7255 sas.sas_iuodchunks = asoc->stats.iuodchunks;
7256 sas.sas_idupchunks = asoc->stats.idupchunks;
7257 sas.sas_opackets = asoc->stats.opackets;
7258 sas.sas_ipackets = asoc->stats.ipackets;
7264 sas.sas_maxrto = asoc->stats.max_obs_rto;
7265 memcpy(&sas.sas_obs_rto_ipaddr, &asoc->stats.obs_rto_ipaddr,
7269 asoc->stats.max_obs_rto = asoc->rto_min;
7327 struct sctp_association *asoc;
7339 asoc = sctp_id2assoc(sk, params.assoc_id);
7340 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7346 params.assoc_value = asoc ? asoc->peer.prsctp_capable
7366 struct sctp_association *asoc;
7378 asoc = sctp_id2assoc(sk, info.pr_assoc_id);
7379 if (!asoc && info.pr_assoc_id != SCTP_FUTURE_ASSOC &&
7385 if (asoc) {
7386 info.pr_policy = SCTP_PR_POLICY(asoc->default_flags);
7387 info.pr_value = asoc->default_timetolive;
7412 struct sctp_association *asoc;
7430 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7431 if (!asoc)
7439 asoc->abandoned_unsent[policy];
7441 asoc->abandoned_sent[policy];
7445 asoc->abandoned_unsent[__SCTP_PR_INDEX(policy)];
7447 asoc->abandoned_sent[__SCTP_PR_INDEX(policy)];
7471 struct sctp_association *asoc;
7490 asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
7491 if (!asoc || params.sprstat_sid >= asoc->stream.outcnt)
7494 streamoute = SCTP_SO(&asoc->stream, params.sprstat_sid)->ext;
7535 struct sctp_association *asoc;
7547 asoc = sctp_id2assoc(sk, params.assoc_id);
7548 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7554 params.assoc_value = asoc ? asoc->peer.reconf_capable
7574 struct sctp_association *asoc;
7586 asoc = sctp_id2assoc(sk, params.assoc_id);
7587 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7593 params.assoc_value = asoc ? asoc->strreset_enable
7613 struct sctp_association *asoc;
7625 asoc = sctp_id2assoc(sk, params.assoc_id);
7626 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7632 params.assoc_value = asoc ? sctp_sched_get_sched(asoc)
7652 struct sctp_association *asoc;
7664 asoc = sctp_id2assoc(sk, params.assoc_id);
7665 if (!asoc) {
7670 retval = sctp_sched_get_value(asoc, params.stream_id,
7694 struct sctp_association *asoc;
7706 asoc = sctp_id2assoc(sk, params.assoc_id);
7707 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7713 params.assoc_value = asoc ? asoc->peer.intl_capable
7751 struct sctp_association *asoc;
7766 asoc = sctp_id2assoc(sk, param.se_assoc_id);
7767 if (!asoc && param.se_assoc_id != SCTP_FUTURE_ASSOC &&
7771 subscribe = asoc ? asoc->subscribe : sctp_sk(sk)->subscribe;
7788 struct sctp_association *asoc;
7800 asoc = sctp_id2assoc(sk, params.assoc_id);
7801 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7807 params.assoc_value = asoc ? asoc->peer.asconf_capable
7827 struct sctp_association *asoc;
7839 asoc = sctp_id2assoc(sk, params.assoc_id);
7840 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7846 params.assoc_value = asoc ? asoc->peer.auth_capable
7866 struct sctp_association *asoc;
7878 asoc = sctp_id2assoc(sk, params.assoc_id);
7879 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7885 params.assoc_value = asoc ? asoc->peer.ecn_capable
7905 struct sctp_association *asoc;
7917 asoc = sctp_id2assoc(sk, params.assoc_id);
7918 if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
7924 params.assoc_value = asoc ? asoc->pf_expose
7942 struct sctp_association *asoc;
7973 asoc = sctp_id2assoc(sk, encap.sue_assoc_id);
7974 if (!asoc && encap.sue_assoc_id != SCTP_FUTURE_ASSOC &&
7980 if (asoc) {
7981 encap_port = asoc->encap_port;
8003 struct sctp_association *asoc;
8033 asoc = sctp_id2assoc(sk, params.spi_assoc_id);
8034 if (!asoc && params.spi_assoc_id != SCTP_FUTURE_ASSOC &&
8040 if (asoc) {
8041 probe_interval = jiffies_to_msecs(asoc->probe_interval);
9069 static void __sctp_write_space(struct sctp_association *asoc)
9071 struct sock *sk = asoc->base.sk;
9073 if (sctp_wspace(asoc) <= 0)
9076 if (waitqueue_active(&asoc->wait))
9077 wake_up_interruptible(&asoc->wait);
9100 struct sctp_association *asoc)
9102 struct sctp_association *tmp = asoc;
9107 if (asoc->ep->sndbuf_policy)
9108 return __sctp_write_space(asoc);
9113 if (asoc->base.dead)
9134 if (tmp == asoc)
9146 struct sctp_association *asoc = chunk->asoc;
9147 struct sock *sk = asoc->base.sk;
9151 asoc->sndbuf_used -= skb->truesize + sizeof(struct sctp_chunk);
9166 ev = sctp_ulpevent_make_authkey(asoc, shkey->key_id,
9170 asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
9176 sctp_wake_up_waiters(sk, asoc);
9178 sctp_association_put(asoc);
9201 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
9204 struct sock *sk = asoc->base.sk;
9209 pr_debug("%s: asoc:%p, timeo:%ld, msg_len:%zu\n", __func__, asoc,
9213 sctp_association_hold(asoc);
9217 prepare_to_wait_exclusive(&asoc->wait, &wait,
9219 if (asoc->base.dead)
9223 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING)
9227 if ((int)msg_len <= sctp_wspace(asoc) &&
9237 if (sk != asoc->base.sk)
9244 finish_wait(&asoc->wait, &wait);
9247 sctp_association_put(asoc);
9286 struct sctp_association *asoc;
9289 list_for_each_entry(asoc, &((sctp_sk(sk))->ep->asocs), asocs) {
9290 __sctp_write_space(asoc);
9313 static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)
9315 struct sock *sk = asoc->base.sk;
9320 pr_debug("%s: asoc:%p, timeo:%ld\n", __func__, asoc, *timeo_p);
9323 sctp_association_hold(asoc);
9326 prepare_to_wait_exclusive(&asoc->wait, &wait,
9332 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||
9333 asoc->base.dead)
9338 if (sctp_state(asoc, ESTABLISHED))
9352 finish_wait(&asoc->wait, &wait);
9355 sctp_association_put(asoc);
9360 if (asoc->init_err_counter + 1 > asoc->max_init_attempts)
9448 struct sctp_association *asoc)
9483 newinet->inet_dport = htons(asoc->peer.port);
9497 * security attribute from asoc.
9499 security_sctp_sk_clone(asoc, sk, newsk);
9577 if (event->asoc == assoc) {
9606 if (event->asoc == assoc) {