Lines Matching refs:asoc
85 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
98 static int sctp_send_asconf(struct sctp_association *asoc,
121 static inline int sctp_wspace(struct sctp_association *asoc) in sctp_wspace() argument
125 if (asoc->ep->sndbuf_policy) in sctp_wspace()
126 amt = asoc->sndbuf_used; in sctp_wspace()
128 amt = sk_wmem_alloc_get(asoc->base.sk); in sctp_wspace()
130 if (amt >= asoc->base.sk->sk_sndbuf) { in sctp_wspace()
131 if (asoc->base.sk->sk_userlocks & SOCK_SNDBUF_LOCK) in sctp_wspace()
134 amt = sk_stream_wspace(asoc->base.sk); in sctp_wspace()
139 amt = asoc->base.sk->sk_sndbuf - amt; in sctp_wspace()
155 struct sctp_association *asoc = chunk->asoc; in sctp_set_owner_w() local
156 struct sock *sk = asoc->base.sk; in sctp_set_owner_w()
159 sctp_association_hold(asoc); in sctp_set_owner_w()
167 asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk) + in sctp_set_owner_w()
181 static void sctp_for_each_tx_datachunk(struct sctp_association *asoc, in sctp_for_each_tx_datachunk() argument
185 struct sctp_outq *q = &asoc->outqueue; in sctp_for_each_tx_datachunk()
189 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) in sctp_for_each_tx_datachunk()
232 struct sctp_association *asoc = NULL; in sctp_id2assoc() local
245 asoc = list_entry(sctp_sk(sk)->ep->asocs.next, in sctp_id2assoc()
247 return asoc; in sctp_id2assoc()
255 asoc = (struct sctp_association *)idr_find(&sctp_assocs_id, (int)id); in sctp_id2assoc()
258 if (!asoc || (asoc->base.sk != sk) || asoc->base.dead) in sctp_id2assoc()
261 return asoc; in sctp_id2assoc()
443 static int sctp_send_asconf(struct sctp_association *asoc, in sctp_send_asconf() argument
446 struct net *net = sock_net(asoc->base.sk); in sctp_send_asconf()
452 if (asoc->addip_last_asconf) { in sctp_send_asconf()
453 list_add_tail(&chunk->list, &asoc->addip_chunk_list); in sctp_send_asconf()
459 retval = sctp_primitive_ASCONF(net, asoc, chunk); in sctp_send_asconf()
463 asoc->addip_last_asconf = chunk; in sctp_send_asconf()
538 struct sctp_association *asoc; in sctp_send_asconf_add_ip() local
559 list_for_each_entry(asoc, &ep->asocs, asocs) { in sctp_send_asconf_add_ip()
560 if (!asoc->peer.asconf_capable) in sctp_send_asconf_add_ip()
563 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_ADD_IP) in sctp_send_asconf_add_ip()
566 if (!sctp_state(asoc, ESTABLISHED)) in sctp_send_asconf_add_ip()
583 if (sctp_assoc_lookup_laddr(asoc, addr)) in sctp_send_asconf_add_ip()
594 bp = &asoc->base.bind_addr; in sctp_send_asconf_add_ip()
597 chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs, in sctp_send_asconf_add_ip()
616 if (asoc->src_out_of_asoc_ok) { in sctp_send_asconf_add_ip()
620 &asoc->peer.transport_addr_list, transports) { in sctp_send_asconf_add_ip()
623 trans->cwnd = min(4*asoc->pathmtu, max_t(__u32, in sctp_send_asconf_add_ip()
624 2*asoc->pathmtu, 4380)); in sctp_send_asconf_add_ip()
625 trans->ssthresh = asoc->peer.i.a_rwnd; in sctp_send_asconf_add_ip()
626 trans->rto = asoc->rto_initial; in sctp_send_asconf_add_ip()
627 sctp_max_rto(asoc, trans); in sctp_send_asconf_add_ip()
630 sctp_sk(asoc->base.sk)); in sctp_send_asconf_add_ip()
633 retval = sctp_send_asconf(asoc, chunk); in sctp_send_asconf_add_ip()
741 struct sctp_association *asoc; in sctp_send_asconf_del_ip() local
763 list_for_each_entry(asoc, &ep->asocs, asocs) { in sctp_send_asconf_del_ip()
765 if (!asoc->peer.asconf_capable) in sctp_send_asconf_del_ip()
768 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_DEL_IP) in sctp_send_asconf_del_ip()
771 if (!sctp_state(asoc, ESTABLISHED)) in sctp_send_asconf_del_ip()
788 if (!sctp_assoc_lookup_laddr(asoc, laddr)) in sctp_send_asconf_del_ip()
801 bp = &asoc->base.bind_addr; in sctp_send_asconf_del_ip()
805 if (asoc->asconf_addr_del_pending) in sctp_send_asconf_del_ip()
807 asoc->asconf_addr_del_pending = in sctp_send_asconf_del_ip()
809 if (asoc->asconf_addr_del_pending == NULL) { in sctp_send_asconf_del_ip()
813 asoc->asconf_addr_del_pending->sa.sa_family = in sctp_send_asconf_del_ip()
815 asoc->asconf_addr_del_pending->v4.sin_port = in sctp_send_asconf_del_ip()
821 asoc->asconf_addr_del_pending->v4.sin_addr.s_addr = sin->sin_addr.s_addr; in sctp_send_asconf_del_ip()
826 asoc->asconf_addr_del_pending->v6.sin6_addr = sin6->sin6_addr; in sctp_send_asconf_del_ip()
830 __func__, asoc, &asoc->asconf_addr_del_pending->sa, in sctp_send_asconf_del_ip()
831 asoc->asconf_addr_del_pending); in sctp_send_asconf_del_ip()
833 asoc->src_out_of_asoc_ok = 1; in sctp_send_asconf_del_ip()
845 chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt, in sctp_send_asconf_del_ip()
871 list_for_each_entry(transport, &asoc->peer.transport_addr_list, in sctp_send_asconf_del_ip()
875 sctp_sk(asoc->base.sk)); in sctp_send_asconf_del_ip()
881 retval = sctp_send_asconf(asoc, chunk); in sctp_send_asconf_del_ip()
1080 struct sctp_association *asoc = NULL; in __sctp_connect() local
1141 if (asoc && asoc->peer.port && asoc->peer.port != port) { in __sctp_connect()
1150 if (asoc2 && asoc2 != asoc) { in __sctp_connect()
1167 if (!asoc) { in __sctp_connect()
1194 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL); in __sctp_connect()
1195 if (!asoc) { in __sctp_connect()
1200 err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, in __sctp_connect()
1209 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, in __sctp_connect()
1225 err = sctp_assoc_set_id(asoc, GFP_KERNEL); in __sctp_connect()
1230 err = sctp_primitive_ASSOCIATE(net, asoc, NULL); in __sctp_connect()
1236 inet_sk(sk)->inet_dport = htons(asoc->peer.port); in __sctp_connect()
1248 err = sctp_wait_for_connect(asoc, &timeo); in __sctp_connect()
1250 *assoc_id = asoc->assoc_id; in __sctp_connect()
1253 asoc = NULL; in __sctp_connect()
1257 __func__, asoc, kaddrs, err); in __sctp_connect()
1259 if (asoc) { in __sctp_connect()
1264 sctp_unhash_established(asoc); in __sctp_connect()
1265 sctp_association_free(asoc); in __sctp_connect()
1510 struct sctp_association *asoc; in sctp_close() local
1528 asoc = list_entry(pos, struct sctp_association, asocs); in sctp_close()
1536 if (sctp_state(asoc, CLOSED)) { in sctp_close()
1537 sctp_unhash_established(asoc); in sctp_close()
1538 sctp_association_free(asoc); in sctp_close()
1543 if (data_was_unread || !skb_queue_empty(&asoc->ulpq.lobby) || in sctp_close()
1544 !skb_queue_empty(&asoc->ulpq.reasm) || in sctp_close()
1548 chunk = sctp_make_abort_user(asoc, NULL, 0); in sctp_close()
1549 sctp_primitive_ABORT(net, asoc, chunk); in sctp_close()
1551 sctp_primitive_SHUTDOWN(net, asoc, NULL); in sctp_close()
1624 struct sctp_association *new_asoc = NULL, *asoc = NULL; in sctp_sendmsg() local
1738 asoc = sctp_endpoint_lookup_assoc(ep, &to, &transport); in sctp_sendmsg()
1739 if (!asoc) { in sctp_sendmsg()
1753 asoc = sctp_id2assoc(sk, associd); in sctp_sendmsg()
1754 if (!asoc) { in sctp_sendmsg()
1760 if (asoc) { in sctp_sendmsg()
1761 pr_debug("%s: just looked up association:%p\n", __func__, asoc); in sctp_sendmsg()
1768 if (sctp_state(asoc, CLOSED) && sctp_style(sk, TCP)) { in sctp_sendmsg()
1775 __func__, asoc); in sctp_sendmsg()
1777 sctp_primitive_SHUTDOWN(net, asoc, NULL); in sctp_sendmsg()
1783 chunk = sctp_make_abort_user(asoc, msg, msg_len); in sctp_sendmsg()
1790 __func__, asoc); in sctp_sendmsg()
1792 sctp_primitive_ABORT(net, asoc, chunk); in sctp_sendmsg()
1799 if (!asoc) { in sctp_sendmsg()
1861 asoc = new_asoc; in sctp_sendmsg()
1862 err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, GFP_KERNEL); in sctp_sendmsg()
1873 asoc->c.sinit_num_ostreams = in sctp_sendmsg()
1877 asoc->c.sinit_max_instreams = in sctp_sendmsg()
1881 asoc->max_init_attempts in sctp_sendmsg()
1885 asoc->max_init_timeo = in sctp_sendmsg()
1891 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, SCTP_UNKNOWN); in sctp_sendmsg()
1906 default_sinfo.sinfo_stream = asoc->default_stream; in sctp_sendmsg()
1907 default_sinfo.sinfo_flags = asoc->default_flags; in sctp_sendmsg()
1908 default_sinfo.sinfo_ppid = asoc->default_ppid; in sctp_sendmsg()
1909 default_sinfo.sinfo_context = asoc->default_context; in sctp_sendmsg()
1910 default_sinfo.sinfo_timetolive = asoc->default_timetolive; in sctp_sendmsg()
1911 default_sinfo.sinfo_assoc_id = sctp_assoc2id(asoc); in sctp_sendmsg()
1918 sinfo->sinfo_timetolive = asoc->default_timetolive; in sctp_sendmsg()
1929 if (asoc->pmtu_pending) in sctp_sendmsg()
1930 sctp_assoc_pending_pmtu(sk, asoc); in sctp_sendmsg()
1937 if (sctp_sk(sk)->disable_fragments && (msg_len > asoc->frag_point)) { in sctp_sendmsg()
1943 if (sinfo->sinfo_stream >= asoc->c.sinit_num_ostreams) { in sctp_sendmsg()
1949 if (!sctp_wspace(asoc)) { in sctp_sendmsg()
1951 err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len); in sctp_sendmsg()
1968 chunk_tp = sctp_assoc_lookup_paddr(asoc, &to); in sctp_sendmsg()
1977 if (sctp_state(asoc, CLOSED)) { in sctp_sendmsg()
1978 err = sctp_primitive_ASSOCIATE(net, asoc, NULL); in sctp_sendmsg()
1987 datamsg = sctp_datamsg_from_user(asoc, sinfo, msg, msg_len); in sctp_sendmsg()
2008 err = sctp_primitive_SEND(net, asoc, datamsg); in sctp_sendmsg()
2022 sctp_wait_for_connect(asoc, &timeo); in sctp_sendmsg()
2032 sctp_unhash_established(asoc); in sctp_sendmsg()
2033 sctp_association_free(asoc); in sctp_sendmsg()
2189 sctp_assoc_rwnd_increase(event->asoc, copied); in sctp_recvmsg()
2242 struct sctp_association *asoc; in sctp_setsockopt_events() local
2262 asoc = sctp_id2assoc(sk, 0); in sctp_setsockopt_events()
2264 if (asoc && sctp_outq_is_empty(&asoc->outqueue)) { in sctp_setsockopt_events()
2265 event = sctp_ulpevent_make_sender_dry_event(asoc, in sctp_setsockopt_events()
2270 sctp_ulpq_tail_event(&asoc->ulpq, event); in sctp_setsockopt_events()
2407 struct sctp_association *asoc, in sctp_apply_peer_addr_params() argument
2416 struct net *net = sock_net(trans->asoc->base.sk); in sctp_apply_peer_addr_params()
2418 error = sctp_primitive_REQUESTHEARTBEAT(net, trans->asoc, trans); in sctp_apply_peer_addr_params()
2441 } else if (asoc) { in sctp_apply_peer_addr_params()
2442 asoc->hbinterval = in sctp_apply_peer_addr_params()
2454 } else if (asoc) { in sctp_apply_peer_addr_params()
2455 asoc->param_flags = in sctp_apply_peer_addr_params()
2456 (asoc->param_flags & ~SPP_HB) | hb_change; in sctp_apply_peer_addr_params()
2471 sctp_assoc_sync_pmtu(sctp_opt2sk(sp), asoc); in sctp_apply_peer_addr_params()
2472 } else if (asoc) { in sctp_apply_peer_addr_params()
2473 asoc->pathmtu = params->spp_pathmtu; in sctp_apply_peer_addr_params()
2474 sctp_frag_point(asoc, params->spp_pathmtu); in sctp_apply_peer_addr_params()
2488 sctp_assoc_sync_pmtu(sctp_opt2sk(sp), asoc); in sctp_apply_peer_addr_params()
2490 } else if (asoc) { in sctp_apply_peer_addr_params()
2491 asoc->param_flags = in sctp_apply_peer_addr_params()
2492 (asoc->param_flags & ~SPP_PMTUD) | pmtud_change; in sctp_apply_peer_addr_params()
2507 } else if (asoc) { in sctp_apply_peer_addr_params()
2508 asoc->sackdelay = in sctp_apply_peer_addr_params()
2520 } else if (asoc) { in sctp_apply_peer_addr_params()
2521 asoc->param_flags = in sctp_apply_peer_addr_params()
2522 (asoc->param_flags & ~SPP_SACKDELAY) | in sctp_apply_peer_addr_params()
2537 } else if (asoc) { in sctp_apply_peer_addr_params()
2538 asoc->pathmaxrxt = params->spp_pathmaxrxt; in sctp_apply_peer_addr_params()
2553 struct sctp_association *asoc = NULL; in sctp_setsockopt_peer_addr_params() local
2591 asoc = sctp_id2assoc(sk, params.spp_assoc_id); in sctp_setsockopt_peer_addr_params()
2592 if (!asoc && params.spp_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_peer_addr_params()
2598 if (params.spp_flags & SPP_HB_DEMAND && !trans && !asoc) in sctp_setsockopt_peer_addr_params()
2602 error = sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, in sctp_setsockopt_peer_addr_params()
2612 if (!trans && asoc) { in sctp_setsockopt_peer_addr_params()
2613 list_for_each_entry(trans, &asoc->peer.transport_addr_list, in sctp_setsockopt_peer_addr_params()
2615 sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, in sctp_setsockopt_peer_addr_params()
2675 struct sctp_association *asoc = NULL; in sctp_setsockopt_delayed_ack() local
2708 asoc = sctp_id2assoc(sk, params.sack_assoc_id); in sctp_setsockopt_delayed_ack()
2709 if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_delayed_ack()
2713 if (asoc) { in sctp_setsockopt_delayed_ack()
2714 asoc->sackdelay = in sctp_setsockopt_delayed_ack()
2716 asoc->param_flags = in sctp_setsockopt_delayed_ack()
2717 sctp_spp_sackdelay_enable(asoc->param_flags); in sctp_setsockopt_delayed_ack()
2726 if (asoc) { in sctp_setsockopt_delayed_ack()
2727 asoc->param_flags = in sctp_setsockopt_delayed_ack()
2728 sctp_spp_sackdelay_disable(asoc->param_flags); in sctp_setsockopt_delayed_ack()
2734 if (asoc) { in sctp_setsockopt_delayed_ack()
2735 asoc->sackfreq = params.sack_freq; in sctp_setsockopt_delayed_ack()
2736 asoc->param_flags = in sctp_setsockopt_delayed_ack()
2737 sctp_spp_sackdelay_enable(asoc->param_flags); in sctp_setsockopt_delayed_ack()
2746 if (asoc) { in sctp_setsockopt_delayed_ack()
2747 list_for_each_entry(trans, &asoc->peer.transport_addr_list, in sctp_setsockopt_delayed_ack()
2821 struct sctp_association *asoc; in sctp_setsockopt_default_send_param() local
2833 asoc = sctp_id2assoc(sk, info.sinfo_assoc_id); in sctp_setsockopt_default_send_param()
2834 if (!asoc && info.sinfo_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_default_send_param()
2836 if (asoc) { in sctp_setsockopt_default_send_param()
2837 asoc->default_stream = info.sinfo_stream; in sctp_setsockopt_default_send_param()
2838 asoc->default_flags = info.sinfo_flags; in sctp_setsockopt_default_send_param()
2839 asoc->default_ppid = info.sinfo_ppid; in sctp_setsockopt_default_send_param()
2840 asoc->default_context = info.sinfo_context; in sctp_setsockopt_default_send_param()
2841 asoc->default_timetolive = info.sinfo_timetolive; in sctp_setsockopt_default_send_param()
2861 struct sctp_association *asoc; in sctp_setsockopt_default_sndinfo() local
2873 asoc = sctp_id2assoc(sk, info.snd_assoc_id); in sctp_setsockopt_default_sndinfo()
2874 if (!asoc && info.snd_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_default_sndinfo()
2876 if (asoc) { in sctp_setsockopt_default_sndinfo()
2877 asoc->default_stream = info.snd_sid; in sctp_setsockopt_default_sndinfo()
2878 asoc->default_flags = info.snd_flags; in sctp_setsockopt_default_sndinfo()
2879 asoc->default_ppid = info.snd_ppid; in sctp_setsockopt_default_sndinfo()
2880 asoc->default_context = info.snd_context; in sctp_setsockopt_default_sndinfo()
2913 sctp_assoc_set_primary(trans->asoc, trans); in sctp_setsockopt_primary_addr()
2955 struct sctp_association *asoc; in sctp_setsockopt_rtoinfo() local
2965 asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id); in sctp_setsockopt_rtoinfo()
2968 if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_rtoinfo()
2975 rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max; in sctp_setsockopt_rtoinfo()
2977 rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max; in sctp_setsockopt_rtoinfo()
2980 rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min; in sctp_setsockopt_rtoinfo()
2982 rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min; in sctp_setsockopt_rtoinfo()
2987 if (asoc) { in sctp_setsockopt_rtoinfo()
2989 asoc->rto_initial = in sctp_setsockopt_rtoinfo()
2991 asoc->rto_max = rto_max; in sctp_setsockopt_rtoinfo()
2992 asoc->rto_min = rto_min; in sctp_setsockopt_rtoinfo()
3021 struct sctp_association *asoc; in sctp_setsockopt_associnfo() local
3028 asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id); in sctp_setsockopt_associnfo()
3030 if (!asoc && assocparams.sasoc_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_associnfo()
3034 if (asoc) { in sctp_setsockopt_associnfo()
3040 list_for_each_entry(peer_addr, &asoc->peer.transport_addr_list, in sctp_setsockopt_associnfo()
3055 asoc->max_retrans = assocparams.sasoc_asocmaxrxt; in sctp_setsockopt_associnfo()
3059 asoc->cookie_life = ms_to_ktime(assocparams.sasoc_cookie_life); in sctp_setsockopt_associnfo()
3131 struct sctp_association *asoc; in sctp_setsockopt_maxseg() local
3154 asoc = sctp_id2assoc(sk, params.assoc_id); in sctp_setsockopt_maxseg()
3155 if (!asoc && params.assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_maxseg()
3158 if (asoc) { in sctp_setsockopt_maxseg()
3160 val = asoc->pathmtu; in sctp_setsockopt_maxseg()
3165 asoc->user_frag = val; in sctp_setsockopt_maxseg()
3166 asoc->frag_point = sctp_frag_point(asoc, asoc->pathmtu); in sctp_setsockopt_maxseg()
3188 struct sctp_association *asoc = NULL; in sctp_setsockopt_peer_primary_addr() local
3205 asoc = sctp_id2assoc(sk, prim.sspp_assoc_id); in sctp_setsockopt_peer_primary_addr()
3206 if (!asoc) in sctp_setsockopt_peer_primary_addr()
3209 if (!asoc->peer.asconf_capable) in sctp_setsockopt_peer_primary_addr()
3212 if (asoc->peer.addip_disabled_mask & SCTP_PARAM_SET_PRIMARY) in sctp_setsockopt_peer_primary_addr()
3215 if (!sctp_state(asoc, ESTABLISHED)) in sctp_setsockopt_peer_primary_addr()
3225 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) in sctp_setsockopt_peer_primary_addr()
3229 chunk = sctp_make_asconf_set_prim(asoc, in sctp_setsockopt_peer_primary_addr()
3234 err = sctp_send_asconf(asoc, chunk); in sctp_setsockopt_peer_primary_addr()
3275 struct sctp_association *asoc; in sctp_setsockopt_context() local
3285 asoc = sctp_id2assoc(sk, params.assoc_id); in sctp_setsockopt_context()
3286 if (!asoc) in sctp_setsockopt_context()
3288 asoc->default_rcv_context = params.assoc_value; in sctp_setsockopt_context()
3392 struct sctp_association *asoc; in sctp_setsockopt_maxburst() local
3415 asoc = sctp_id2assoc(sk, assoc_id); in sctp_setsockopt_maxburst()
3416 if (!asoc) in sctp_setsockopt_maxburst()
3418 asoc->max_burst = val; in sctp_setsockopt_maxburst()
3509 struct sctp_association *asoc; in sctp_setsockopt_auth_key() local
3527 asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); in sctp_setsockopt_auth_key()
3528 if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { in sctp_setsockopt_auth_key()
3533 ret = sctp_auth_set_key(ep, asoc, authkey); in sctp_setsockopt_auth_key()
3551 struct sctp_association *asoc; in sctp_setsockopt_active_key() local
3561 asoc = sctp_id2assoc(sk, val.scact_assoc_id); in sctp_setsockopt_active_key()
3562 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_active_key()
3565 return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); in sctp_setsockopt_active_key()
3579 struct sctp_association *asoc; in sctp_setsockopt_del_key() local
3589 asoc = sctp_id2assoc(sk, val.scact_assoc_id); in sctp_setsockopt_del_key()
3590 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) in sctp_setsockopt_del_key()
3593 return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); in sctp_setsockopt_del_key()
3652 struct sctp_association *asoc; in sctp_setsockopt_paddr_thresholds() local
3662 asoc = sctp_id2assoc(sk, val.spt_assoc_id); in sctp_setsockopt_paddr_thresholds()
3663 if (!asoc) in sctp_setsockopt_paddr_thresholds()
3665 list_for_each_entry(trans, &asoc->peer.transport_addr_list, in sctp_setsockopt_paddr_thresholds()
3673 asoc->pathmaxrxt = val.spt_pathmaxrxt; in sctp_setsockopt_paddr_thresholds()
3674 asoc->pf_retrans = val.spt_pathpfthld; in sctp_setsockopt_paddr_thresholds()
3952 struct sctp_association *asoc; in sctp_accept() local
3980 asoc = list_entry(ep->asocs.next, struct sctp_association, asocs); in sctp_accept()
3982 newsk = sp->pf->create_accept_sk(sk, asoc); in sctp_accept()
3991 sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP); in sctp_accept()
4247 struct sctp_association *asoc; in sctp_shutdown() local
4255 asoc = list_entry(ep->asocs.next, in sctp_shutdown()
4257 sctp_primitive_SHUTDOWN(net, asoc, NULL); in sctp_shutdown()
4274 struct sctp_association *asoc = NULL; in sctp_getsockopt_sctp_status() local
4291 asoc = sctp_id2assoc(sk, associd); in sctp_getsockopt_sctp_status()
4292 if (!asoc) { in sctp_getsockopt_sctp_status()
4297 transport = asoc->peer.primary_path; in sctp_getsockopt_sctp_status()
4299 status.sstat_assoc_id = sctp_assoc2id(asoc); in sctp_getsockopt_sctp_status()
4300 status.sstat_state = sctp_assoc_to_state(asoc); in sctp_getsockopt_sctp_status()
4301 status.sstat_rwnd = asoc->peer.rwnd; in sctp_getsockopt_sctp_status()
4302 status.sstat_unackdata = asoc->unack_data; in sctp_getsockopt_sctp_status()
4304 status.sstat_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map); in sctp_getsockopt_sctp_status()
4305 status.sstat_instrms = asoc->c.sinit_max_instreams; in sctp_getsockopt_sctp_status()
4306 status.sstat_outstrms = asoc->c.sinit_num_ostreams; in sctp_getsockopt_sctp_status()
4307 status.sstat_fragmentation_point = asoc->frag_point; in sctp_getsockopt_sctp_status()
4308 status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc); in sctp_getsockopt_sctp_status()
4373 pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc); in sctp_getsockopt_peer_addr_info()
4469 struct sctp_association *asoc = sctp_id2assoc(sk, id); in sctp_do_peeloff() local
4478 if (!asoc) in sctp_do_peeloff()
4492 sctp_copy_sock(sock->sk, sk, asoc); in sctp_do_peeloff()
4497 sp->pf->to_sk_daddr(&asoc->peer.primary_addr, sk); in sctp_do_peeloff()
4502 sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH); in sctp_do_peeloff()
4659 struct sctp_association *asoc = NULL; in sctp_getsockopt_peer_addr_params() local
4684 asoc = sctp_id2assoc(sk, params.spp_assoc_id); in sctp_getsockopt_peer_addr_params()
4685 if (!asoc && params.spp_assoc_id && sctp_style(sk, UDP)) { in sctp_getsockopt_peer_addr_params()
4699 } else if (asoc) { in sctp_getsockopt_peer_addr_params()
4701 params.spp_hbinterval = jiffies_to_msecs(asoc->hbinterval); in sctp_getsockopt_peer_addr_params()
4702 params.spp_pathmtu = asoc->pathmtu; in sctp_getsockopt_peer_addr_params()
4703 params.spp_pathmaxrxt = asoc->pathmaxrxt; in sctp_getsockopt_peer_addr_params()
4704 params.spp_sackdelay = jiffies_to_msecs(asoc->sackdelay); in sctp_getsockopt_peer_addr_params()
4707 params.spp_flags = asoc->param_flags; in sctp_getsockopt_peer_addr_params()
4768 struct sctp_association *asoc = NULL; in sctp_getsockopt_delayed_ack() local
4791 asoc = sctp_id2assoc(sk, params.sack_assoc_id); in sctp_getsockopt_delayed_ack()
4792 if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_delayed_ack()
4795 if (asoc) { in sctp_getsockopt_delayed_ack()
4797 if (asoc->param_flags & SPP_SACKDELAY_ENABLE) { in sctp_getsockopt_delayed_ack()
4799 asoc->sackdelay); in sctp_getsockopt_delayed_ack()
4800 params.sack_freq = asoc->sackfreq; in sctp_getsockopt_delayed_ack()
4853 struct sctp_association *asoc; in sctp_getsockopt_peer_addrs() local
4871 asoc = sctp_id2assoc(sk, getaddrs.assoc_id); in sctp_getsockopt_peer_addrs()
4872 if (!asoc) in sctp_getsockopt_peer_addrs()
4878 list_for_each_entry(from, &asoc->peer.transport_addr_list, in sctp_getsockopt_peer_addrs()
4950 struct sctp_association *asoc; in sctp_getsockopt_local_addrs() local
4979 asoc = sctp_id2assoc(sk, getaddrs.assoc_id); in sctp_getsockopt_local_addrs()
4980 if (!asoc) in sctp_getsockopt_local_addrs()
4982 bp = &asoc->base.bind_addr; in sctp_getsockopt_local_addrs()
5055 struct sctp_association *asoc; in sctp_getsockopt_primary_addr() local
5066 asoc = sctp_id2assoc(sk, prim.ssp_assoc_id); in sctp_getsockopt_primary_addr()
5067 if (!asoc) in sctp_getsockopt_primary_addr()
5070 if (!asoc->peer.primary_path) in sctp_getsockopt_primary_addr()
5073 memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr, in sctp_getsockopt_primary_addr()
5074 asoc->peer.primary_path->af_specific->sockaddr_len); in sctp_getsockopt_primary_addr()
5137 struct sctp_association *asoc; in sctp_getsockopt_default_send_param() local
5148 asoc = sctp_id2assoc(sk, info.sinfo_assoc_id); in sctp_getsockopt_default_send_param()
5149 if (!asoc && info.sinfo_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_default_send_param()
5151 if (asoc) { in sctp_getsockopt_default_send_param()
5152 info.sinfo_stream = asoc->default_stream; in sctp_getsockopt_default_send_param()
5153 info.sinfo_flags = asoc->default_flags; in sctp_getsockopt_default_send_param()
5154 info.sinfo_ppid = asoc->default_ppid; in sctp_getsockopt_default_send_param()
5155 info.sinfo_context = asoc->default_context; in sctp_getsockopt_default_send_param()
5156 info.sinfo_timetolive = asoc->default_timetolive; in sctp_getsockopt_default_send_param()
5181 struct sctp_association *asoc; in sctp_getsockopt_default_sndinfo() local
5192 asoc = sctp_id2assoc(sk, info.snd_assoc_id); in sctp_getsockopt_default_sndinfo()
5193 if (!asoc && info.snd_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_default_sndinfo()
5195 if (asoc) { in sctp_getsockopt_default_sndinfo()
5196 info.snd_sid = asoc->default_stream; in sctp_getsockopt_default_sndinfo()
5197 info.snd_flags = asoc->default_flags; in sctp_getsockopt_default_sndinfo()
5198 info.snd_ppid = asoc->default_ppid; in sctp_getsockopt_default_sndinfo()
5199 info.snd_context = asoc->default_context; in sctp_getsockopt_default_sndinfo()
5258 struct sctp_association *asoc; in sctp_getsockopt_rtoinfo() local
5268 asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id); in sctp_getsockopt_rtoinfo()
5270 if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_rtoinfo()
5274 if (asoc) { in sctp_getsockopt_rtoinfo()
5275 rtoinfo.srto_initial = jiffies_to_msecs(asoc->rto_initial); in sctp_getsockopt_rtoinfo()
5276 rtoinfo.srto_max = jiffies_to_msecs(asoc->rto_max); in sctp_getsockopt_rtoinfo()
5277 rtoinfo.srto_min = jiffies_to_msecs(asoc->rto_min); in sctp_getsockopt_rtoinfo()
5313 struct sctp_association *asoc; in sctp_getsockopt_associnfo() local
5325 asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id); in sctp_getsockopt_associnfo()
5327 if (!asoc && assocparams.sasoc_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_associnfo()
5331 if (asoc) { in sctp_getsockopt_associnfo()
5332 assocparams.sasoc_asocmaxrxt = asoc->max_retrans; in sctp_getsockopt_associnfo()
5333 assocparams.sasoc_peer_rwnd = asoc->peer.rwnd; in sctp_getsockopt_associnfo()
5334 assocparams.sasoc_local_rwnd = asoc->a_rwnd; in sctp_getsockopt_associnfo()
5335 assocparams.sasoc_cookie_life = ktime_to_ms(asoc->cookie_life); in sctp_getsockopt_associnfo()
5337 list_for_each(pos, &asoc->peer.transport_addr_list) { in sctp_getsockopt_associnfo()
5403 struct sctp_association *asoc; in sctp_getsockopt_context() local
5416 asoc = sctp_id2assoc(sk, params.assoc_id); in sctp_getsockopt_context()
5417 if (!asoc) in sctp_getsockopt_context()
5419 params.assoc_value = asoc->default_rcv_context; in sctp_getsockopt_context()
5463 struct sctp_association *asoc; in sctp_getsockopt_maxseg() local
5479 asoc = sctp_id2assoc(sk, params.assoc_id); in sctp_getsockopt_maxseg()
5480 if (!asoc && params.assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_maxseg()
5483 if (asoc) in sctp_getsockopt_maxseg()
5484 params.assoc_value = asoc->frag_point; in sctp_getsockopt_maxseg()
5558 struct sctp_association *asoc; in sctp_getsockopt_maxburst() local
5577 asoc = sctp_id2assoc(sk, params.assoc_id); in sctp_getsockopt_maxburst()
5578 if (!asoc) in sctp_getsockopt_maxburst()
5580 params.assoc_value = asoc->max_burst; in sctp_getsockopt_maxburst()
5631 struct sctp_association *asoc; in sctp_getsockopt_active_key() local
5641 asoc = sctp_id2assoc(sk, val.scact_assoc_id); in sctp_getsockopt_active_key()
5642 if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_active_key()
5645 if (asoc) in sctp_getsockopt_active_key()
5646 val.scact_keynumber = asoc->active_key_id; in sctp_getsockopt_active_key()
5665 struct sctp_association *asoc; in sctp_getsockopt_peer_auth_chunks() local
5680 asoc = sctp_id2assoc(sk, val.gauth_assoc_id); in sctp_getsockopt_peer_auth_chunks()
5681 if (!asoc) in sctp_getsockopt_peer_auth_chunks()
5684 ch = asoc->peer.peer_chunks; in sctp_getsockopt_peer_auth_chunks()
5710 struct sctp_association *asoc; in sctp_getsockopt_local_auth_chunks() local
5725 asoc = sctp_id2assoc(sk, val.gauth_assoc_id); in sctp_getsockopt_local_auth_chunks()
5726 if (!asoc && val.gauth_assoc_id && sctp_style(sk, UDP)) in sctp_getsockopt_local_auth_chunks()
5729 if (asoc) in sctp_getsockopt_local_auth_chunks()
5730 ch = (struct sctp_chunks_param *)asoc->c.auth_chunks; in sctp_getsockopt_local_auth_chunks()
5762 struct sctp_association *asoc; in sctp_getsockopt_assoc_number() local
5773 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) { in sctp_getsockopt_assoc_number()
5818 struct sctp_association *asoc; in sctp_getsockopt_assoc_ids() local
5828 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) { in sctp_getsockopt_assoc_ids()
5843 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) { in sctp_getsockopt_assoc_ids()
5844 ids->gaids_assoc_id[num++] = asoc->assoc_id; in sctp_getsockopt_assoc_ids()
5870 struct sctp_association *asoc; in sctp_getsockopt_paddr_thresholds() local
5879 asoc = sctp_id2assoc(sk, val.spt_assoc_id); in sctp_getsockopt_paddr_thresholds()
5880 if (!asoc) in sctp_getsockopt_paddr_thresholds()
5883 val.spt_pathpfthld = asoc->pf_retrans; in sctp_getsockopt_paddr_thresholds()
5884 val.spt_pathmaxrxt = asoc->pathmaxrxt; in sctp_getsockopt_paddr_thresholds()
5912 struct sctp_association *asoc = NULL; in sctp_getsockopt_assoc_stats() local
5924 asoc = sctp_id2assoc(sk, sas.sas_assoc_id); in sctp_getsockopt_assoc_stats()
5925 if (!asoc) in sctp_getsockopt_assoc_stats()
5928 sas.sas_rtxchunks = asoc->stats.rtxchunks; in sctp_getsockopt_assoc_stats()
5929 sas.sas_gapcnt = asoc->stats.gapcnt; in sctp_getsockopt_assoc_stats()
5930 sas.sas_outofseqtsns = asoc->stats.outofseqtsns; in sctp_getsockopt_assoc_stats()
5931 sas.sas_osacks = asoc->stats.osacks; in sctp_getsockopt_assoc_stats()
5932 sas.sas_isacks = asoc->stats.isacks; in sctp_getsockopt_assoc_stats()
5933 sas.sas_octrlchunks = asoc->stats.octrlchunks; in sctp_getsockopt_assoc_stats()
5934 sas.sas_ictrlchunks = asoc->stats.ictrlchunks; in sctp_getsockopt_assoc_stats()
5935 sas.sas_oodchunks = asoc->stats.oodchunks; in sctp_getsockopt_assoc_stats()
5936 sas.sas_iodchunks = asoc->stats.iodchunks; in sctp_getsockopt_assoc_stats()
5937 sas.sas_ouodchunks = asoc->stats.ouodchunks; in sctp_getsockopt_assoc_stats()
5938 sas.sas_iuodchunks = asoc->stats.iuodchunks; in sctp_getsockopt_assoc_stats()
5939 sas.sas_idupchunks = asoc->stats.idupchunks; in sctp_getsockopt_assoc_stats()
5940 sas.sas_opackets = asoc->stats.opackets; in sctp_getsockopt_assoc_stats()
5941 sas.sas_ipackets = asoc->stats.ipackets; in sctp_getsockopt_assoc_stats()
5947 sas.sas_maxrto = asoc->stats.max_obs_rto; in sctp_getsockopt_assoc_stats()
5948 memcpy(&sas.sas_obs_rto_ipaddr, &asoc->stats.obs_rto_ipaddr, in sctp_getsockopt_assoc_stats()
5952 asoc->stats.max_obs_rto = asoc->rto_min; in sctp_getsockopt_assoc_stats()
6865 static void __sctp_write_space(struct sctp_association *asoc) in __sctp_write_space() argument
6867 struct sock *sk = asoc->base.sk; in __sctp_write_space()
6870 if ((sctp_wspace(asoc) > 0) && sock) { in __sctp_write_space()
6871 if (waitqueue_active(&asoc->wait)) in __sctp_write_space()
6872 wake_up_interruptible(&asoc->wait); in __sctp_write_space()
6892 struct sctp_association *asoc) in sctp_wake_up_waiters() argument
6894 struct sctp_association *tmp = asoc; in sctp_wake_up_waiters()
6899 if (asoc->ep->sndbuf_policy) in sctp_wake_up_waiters()
6900 return __sctp_write_space(asoc); in sctp_wake_up_waiters()
6905 if (asoc->base.dead) in sctp_wake_up_waiters()
6926 if (tmp == asoc) in sctp_wake_up_waiters()
6937 struct sctp_association *asoc; in sctp_wfree() local
6943 asoc = chunk->asoc; in sctp_wfree()
6944 sk = asoc->base.sk; in sctp_wfree()
6945 asoc->sndbuf_used -= SCTP_DATA_SNDSIZE(chunk) + in sctp_wfree()
6958 sctp_wake_up_waiters(sk, asoc); in sctp_wfree()
6960 sctp_association_put(asoc); in sctp_wfree()
6983 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, in sctp_wait_for_sndbuf() argument
6986 struct sock *sk = asoc->base.sk; in sctp_wait_for_sndbuf()
6991 pr_debug("%s: asoc:%p, timeo:%ld, msg_len:%zu\n", __func__, asoc, in sctp_wait_for_sndbuf()
6995 sctp_association_hold(asoc); in sctp_wait_for_sndbuf()
6999 prepare_to_wait_exclusive(&asoc->wait, &wait, in sctp_wait_for_sndbuf()
7001 if (asoc->base.dead) in sctp_wait_for_sndbuf()
7005 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING) in sctp_wait_for_sndbuf()
7009 if (msg_len <= sctp_wspace(asoc)) in sctp_wait_for_sndbuf()
7018 if (sk != asoc->base.sk) in sctp_wait_for_sndbuf()
7025 finish_wait(&asoc->wait, &wait); in sctp_wait_for_sndbuf()
7028 sctp_association_put(asoc); in sctp_wait_for_sndbuf()
7065 struct sctp_association *asoc; in sctp_write_space() local
7068 list_for_each_entry(asoc, &((sctp_sk(sk))->ep->asocs), asocs) { in sctp_write_space()
7069 __sctp_write_space(asoc); in sctp_write_space()
7097 static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p) in sctp_wait_for_connect() argument
7099 struct sock *sk = asoc->base.sk; in sctp_wait_for_connect()
7104 pr_debug("%s: asoc:%p, timeo:%ld\n", __func__, asoc, *timeo_p); in sctp_wait_for_connect()
7107 sctp_association_hold(asoc); in sctp_wait_for_connect()
7110 prepare_to_wait_exclusive(&asoc->wait, &wait, in sctp_wait_for_connect()
7116 if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || in sctp_wait_for_connect()
7117 asoc->base.dead) in sctp_wait_for_connect()
7122 if (sctp_state(asoc, ESTABLISHED)) in sctp_wait_for_connect()
7136 finish_wait(&asoc->wait, &wait); in sctp_wait_for_connect()
7139 sctp_association_put(asoc); in sctp_wait_for_connect()
7144 if (asoc->init_err_counter + 1 > asoc->max_init_attempts) in sctp_wait_for_connect()
7232 struct sctp_association *asoc) in sctp_copy_sock() argument
7264 newinet->inet_dport = htons(asoc->peer.port); in sctp_copy_sock()
7266 newinet->inet_id = asoc->next_tsn ^ jiffies; in sctp_copy_sock()
7343 if (event->asoc == assoc) { in sctp_sock_migrate()
7373 if (event->asoc == assoc) { in sctp_sock_migrate()