Lines Matching refs:asoc

43 static void sctp_select_active_and_retran_path(struct sctp_association *asoc);
45 static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc);
46 static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc);
52 struct sctp_association *asoc, in sctp_association_init() argument
65 asoc->ep = (struct sctp_endpoint *)ep; in sctp_association_init()
66 asoc->base.sk = (struct sock *)sk; in sctp_association_init()
67 asoc->base.net = sock_net(sk); in sctp_association_init()
69 sctp_endpoint_hold(asoc->ep); in sctp_association_init()
70 sock_hold(asoc->base.sk); in sctp_association_init()
73 asoc->base.type = SCTP_EP_TYPE_ASSOCIATION; in sctp_association_init()
76 refcount_set(&asoc->base.refcnt, 1); in sctp_association_init()
79 sctp_bind_addr_init(&asoc->base.bind_addr, ep->base.bind_addr.port); in sctp_association_init()
81 asoc->state = SCTP_STATE_CLOSED; in sctp_association_init()
82 asoc->cookie_life = ms_to_ktime(sp->assocparams.sasoc_cookie_life); in sctp_association_init()
83 asoc->user_frag = sp->user_frag; in sctp_association_init()
88 asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt; in sctp_association_init()
89 asoc->pf_retrans = sp->pf_retrans; in sctp_association_init()
90 asoc->ps_retrans = sp->ps_retrans; in sctp_association_init()
91 asoc->pf_expose = sp->pf_expose; in sctp_association_init()
93 asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial); in sctp_association_init()
94 asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max); in sctp_association_init()
95 asoc->rto_min = msecs_to_jiffies(sp->rtoinfo.srto_min); in sctp_association_init()
100 asoc->hbinterval = msecs_to_jiffies(sp->hbinterval); in sctp_association_init()
101 asoc->probe_interval = msecs_to_jiffies(sp->probe_interval); in sctp_association_init()
103 asoc->encap_port = sp->encap_port; in sctp_association_init()
106 asoc->pathmaxrxt = sp->pathmaxrxt; in sctp_association_init()
108 asoc->flowlabel = sp->flowlabel; in sctp_association_init()
109 asoc->dscp = sp->dscp; in sctp_association_init()
112 asoc->sackdelay = msecs_to_jiffies(sp->sackdelay); in sctp_association_init()
113 asoc->sackfreq = sp->sackfreq; in sctp_association_init()
118 asoc->param_flags = sp->param_flags; in sctp_association_init()
123 asoc->max_burst = sp->max_burst; in sctp_association_init()
125 asoc->subscribe = sp->subscribe; in sctp_association_init()
128 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] = asoc->rto_initial; in sctp_association_init()
129 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] = asoc->rto_initial; in sctp_association_init()
130 asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = asoc->rto_initial; in sctp_association_init()
136 asoc->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD] in sctp_association_init()
137 = 5 * asoc->rto_max; in sctp_association_init()
139 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; in sctp_association_init()
140 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = in sctp_association_init()
145 timer_setup(&asoc->timers[i], sctp_timer_events[i], 0); in sctp_association_init()
151 asoc->c.sinit_max_instreams = sp->initmsg.sinit_max_instreams; in sctp_association_init()
152 asoc->c.sinit_num_ostreams = sp->initmsg.sinit_num_ostreams; in sctp_association_init()
153 asoc->max_init_attempts = sp->initmsg.sinit_max_attempts; in sctp_association_init()
155 asoc->max_init_timeo = in sctp_association_init()
164 asoc->rwnd = SCTP_DEFAULT_MINWINDOW; in sctp_association_init()
166 asoc->rwnd = sk->sk_rcvbuf/2; in sctp_association_init()
168 asoc->a_rwnd = asoc->rwnd; in sctp_association_init()
171 asoc->peer.rwnd = SCTP_DEFAULT_MAXWINDOW; in sctp_association_init()
174 atomic_set(&asoc->rmem_alloc, 0); in sctp_association_init()
176 init_waitqueue_head(&asoc->wait); in sctp_association_init()
178 asoc->c.my_vtag = sctp_generate_tag(ep); in sctp_association_init()
179 asoc->c.my_port = ep->base.bind_addr.port; in sctp_association_init()
181 asoc->c.initial_tsn = sctp_generate_tsn(ep); in sctp_association_init()
183 asoc->next_tsn = asoc->c.initial_tsn; in sctp_association_init()
185 asoc->ctsn_ack_point = asoc->next_tsn - 1; in sctp_association_init()
186 asoc->adv_peer_ack_point = asoc->ctsn_ack_point; in sctp_association_init()
187 asoc->highest_sacked = asoc->ctsn_ack_point; in sctp_association_init()
188 asoc->last_cwr_tsn = asoc->ctsn_ack_point; in sctp_association_init()
200 asoc->addip_serial = asoc->c.initial_tsn; in sctp_association_init()
201 asoc->strreset_outseq = asoc->c.initial_tsn; in sctp_association_init()
203 INIT_LIST_HEAD(&asoc->addip_chunk_list); in sctp_association_init()
204 INIT_LIST_HEAD(&asoc->asconf_ack_list); in sctp_association_init()
207 INIT_LIST_HEAD(&asoc->peer.transport_addr_list); in sctp_association_init()
220 asoc->peer.sack_needed = 1; in sctp_association_init()
221 asoc->peer.sack_generation = 1; in sctp_association_init()
224 sctp_inq_init(&asoc->base.inqueue); in sctp_association_init()
225 sctp_inq_set_th_handler(&asoc->base.inqueue, sctp_assoc_bh_rcv); in sctp_association_init()
228 sctp_outq_init(asoc, &asoc->outqueue); in sctp_association_init()
230 sctp_ulpq_init(&asoc->ulpq, asoc); in sctp_association_init()
232 if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams, 0, gfp)) in sctp_association_init()
236 asoc->pathmtu = sp->pathmtu; in sctp_association_init()
237 sctp_assoc_update_frag_point(asoc); in sctp_association_init()
242 asoc->peer.ipv4_address = 1; in sctp_association_init()
243 if (asoc->base.sk->sk_family == PF_INET6) in sctp_association_init()
244 asoc->peer.ipv6_address = 1; in sctp_association_init()
245 INIT_LIST_HEAD(&asoc->asocs); in sctp_association_init()
247 asoc->default_stream = sp->default_stream; in sctp_association_init()
248 asoc->default_ppid = sp->default_ppid; in sctp_association_init()
249 asoc->default_flags = sp->default_flags; in sctp_association_init()
250 asoc->default_context = sp->default_context; in sctp_association_init()
251 asoc->default_timetolive = sp->default_timetolive; in sctp_association_init()
252 asoc->default_rcv_context = sp->default_rcv_context; in sctp_association_init()
255 INIT_LIST_HEAD(&asoc->endpoint_shared_keys); in sctp_association_init()
256 if (sctp_auth_asoc_copy_shkeys(ep, asoc, gfp)) in sctp_association_init()
259 asoc->active_key_id = ep->active_key_id; in sctp_association_init()
260 asoc->strreset_enable = ep->strreset_enable; in sctp_association_init()
264 memcpy(asoc->c.auth_hmacs, ep->auth_hmacs_list, in sctp_association_init()
267 memcpy(asoc->c.auth_chunks, ep->auth_chunk_list, in sctp_association_init()
271 p = (struct sctp_paramhdr *)asoc->c.auth_random; in sctp_association_init()
276 return asoc; in sctp_association_init()
279 sctp_stream_free(&asoc->stream); in sctp_association_init()
280 sock_put(asoc->base.sk); in sctp_association_init()
281 sctp_endpoint_put(asoc->ep); in sctp_association_init()
290 struct sctp_association *asoc; in sctp_association_new() local
292 asoc = kzalloc(sizeof(*asoc), gfp); in sctp_association_new()
293 if (!asoc) in sctp_association_new()
296 if (!sctp_association_init(asoc, ep, sk, scope, gfp)) in sctp_association_new()
301 pr_debug("Created asoc %p\n", asoc); in sctp_association_new()
303 return asoc; in sctp_association_new()
306 kfree(asoc); in sctp_association_new()
314 void sctp_association_free(struct sctp_association *asoc) in sctp_association_free() argument
316 struct sock *sk = asoc->base.sk; in sctp_association_free()
324 if (!list_empty(&asoc->asocs)) { in sctp_association_free()
325 list_del(&asoc->asocs); in sctp_association_free()
337 asoc->base.dead = true; in sctp_association_free()
340 sctp_outq_free(&asoc->outqueue); in sctp_association_free()
343 sctp_ulpq_free(&asoc->ulpq); in sctp_association_free()
346 sctp_inq_free(&asoc->base.inqueue); in sctp_association_free()
348 sctp_tsnmap_free(&asoc->peer.tsn_map); in sctp_association_free()
351 sctp_stream_free(&asoc->stream); in sctp_association_free()
353 if (asoc->strreset_chunk) in sctp_association_free()
354 sctp_chunk_free(asoc->strreset_chunk); in sctp_association_free()
357 sctp_bind_addr_free(&asoc->base.bind_addr); in sctp_association_free()
365 if (del_timer(&asoc->timers[i])) in sctp_association_free()
366 sctp_association_put(asoc); in sctp_association_free()
370 kfree(asoc->peer.cookie); in sctp_association_free()
371 kfree(asoc->peer.peer_random); in sctp_association_free()
372 kfree(asoc->peer.peer_chunks); in sctp_association_free()
373 kfree(asoc->peer.peer_hmacs); in sctp_association_free()
376 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { in sctp_association_free()
383 asoc->peer.transport_count = 0; in sctp_association_free()
385 sctp_asconf_queue_teardown(asoc); in sctp_association_free()
388 kfree(asoc->asconf_addr_del_pending); in sctp_association_free()
391 sctp_auth_destroy_keys(&asoc->endpoint_shared_keys); in sctp_association_free()
394 sctp_auth_key_put(asoc->asoc_shared_key); in sctp_association_free()
396 sctp_association_put(asoc); in sctp_association_free()
400 static void sctp_association_destroy(struct sctp_association *asoc) in sctp_association_destroy() argument
402 if (unlikely(!asoc->base.dead)) { in sctp_association_destroy()
403 WARN(1, "Attempt to destroy undead association %p!\n", asoc); in sctp_association_destroy()
407 sctp_endpoint_put(asoc->ep); in sctp_association_destroy()
408 sock_put(asoc->base.sk); in sctp_association_destroy()
410 if (asoc->assoc_id != 0) { in sctp_association_destroy()
412 idr_remove(&sctp_assocs_id, asoc->assoc_id); in sctp_association_destroy()
416 WARN_ON(atomic_read(&asoc->rmem_alloc)); in sctp_association_destroy()
418 kfree_rcu(asoc, rcu); in sctp_association_destroy()
423 void sctp_assoc_set_primary(struct sctp_association *asoc, in sctp_assoc_set_primary() argument
431 if (asoc->peer.primary_path != NULL && in sctp_assoc_set_primary()
432 asoc->peer.primary_path != transport) in sctp_assoc_set_primary()
435 asoc->peer.primary_path = transport; in sctp_assoc_set_primary()
440 memcpy(&asoc->peer.primary_addr, &transport->ipaddr, in sctp_assoc_set_primary()
448 asoc->peer.active_path = transport; in sctp_assoc_set_primary()
464 if (!asoc->outqueue.outstanding_bytes && !asoc->outqueue.out_qlen) in sctp_assoc_set_primary()
478 transport->cacc.next_tsn_at_change = asoc->next_tsn; in sctp_assoc_set_primary()
482 void sctp_assoc_rm_peer(struct sctp_association *asoc, in sctp_assoc_rm_peer() argument
490 __func__, asoc, &peer->ipaddr.sa); in sctp_assoc_rm_peer()
495 if (asoc->peer.retran_path == peer) in sctp_assoc_rm_peer()
496 sctp_assoc_update_retran_path(asoc); in sctp_assoc_rm_peer()
504 pos = asoc->peer.transport_addr_list.next; in sctp_assoc_rm_peer()
508 if (asoc->peer.primary_path == peer) in sctp_assoc_rm_peer()
509 sctp_assoc_set_primary(asoc, transport); in sctp_assoc_rm_peer()
510 if (asoc->peer.active_path == peer) in sctp_assoc_rm_peer()
511 asoc->peer.active_path = transport; in sctp_assoc_rm_peer()
512 if (asoc->peer.retran_path == peer) in sctp_assoc_rm_peer()
513 asoc->peer.retran_path = transport; in sctp_assoc_rm_peer()
514 if (asoc->peer.last_data_from == peer) in sctp_assoc_rm_peer()
515 asoc->peer.last_data_from = transport; in sctp_assoc_rm_peer()
517 if (asoc->strreset_chunk && in sctp_assoc_rm_peer()
518 asoc->strreset_chunk->transport == peer) { in sctp_assoc_rm_peer()
519 asoc->strreset_chunk->transport = transport; in sctp_assoc_rm_peer()
528 if (asoc->init_last_sent_to == peer) in sctp_assoc_rm_peer()
529 asoc->init_last_sent_to = NULL; in sctp_assoc_rm_peer()
536 if (asoc->shutdown_last_sent_to == peer) in sctp_assoc_rm_peer()
537 asoc->shutdown_last_sent_to = NULL; in sctp_assoc_rm_peer()
542 if (asoc->addip_last_asconf && in sctp_assoc_rm_peer()
543 asoc->addip_last_asconf->transport == peer) in sctp_assoc_rm_peer()
544 asoc->addip_last_asconf->transport = NULL; in sctp_assoc_rm_peer()
550 struct sctp_transport *active = asoc->peer.active_path; in sctp_assoc_rm_peer()
572 list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list) in sctp_assoc_rm_peer()
576 asoc->peer.transport_count--; in sctp_assoc_rm_peer()
583 struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, in sctp_assoc_add_peer() argument
592 sp = sctp_sk(asoc->base.sk); in sctp_assoc_add_peer()
598 asoc, &addr->sa, peer_state); in sctp_assoc_add_peer()
601 if (0 == asoc->peer.port) in sctp_assoc_add_peer()
602 asoc->peer.port = port; in sctp_assoc_add_peer()
605 peer = sctp_assoc_lookup_paddr(asoc, addr); in sctp_assoc_add_peer()
617 peer = sctp_transport_new(asoc->base.net, addr, gfp); in sctp_assoc_add_peer()
621 sctp_transport_set_owner(peer, asoc); in sctp_assoc_add_peer()
626 peer->hbinterval = asoc->hbinterval; in sctp_assoc_add_peer()
627 peer->probe_interval = asoc->probe_interval; in sctp_assoc_add_peer()
629 peer->encap_port = asoc->encap_port; in sctp_assoc_add_peer()
632 peer->pathmaxrxt = asoc->pathmaxrxt; in sctp_assoc_add_peer()
635 peer->pf_retrans = asoc->pf_retrans; in sctp_assoc_add_peer()
637 peer->ps_retrans = asoc->ps_retrans; in sctp_assoc_add_peer()
642 peer->sackdelay = asoc->sackdelay; in sctp_assoc_add_peer()
643 peer->sackfreq = asoc->sackfreq; in sctp_assoc_add_peer()
652 peer->flowlabel = asoc->flowlabel; in sctp_assoc_add_peer()
655 peer->dscp = asoc->dscp; in sctp_assoc_add_peer()
660 peer->param_flags = asoc->param_flags; in sctp_assoc_add_peer()
670 sctp_assoc_set_pmtu(asoc, asoc->pathmtu ? in sctp_assoc_add_peer()
671 min_t(int, peer->pathmtu, asoc->pathmtu) : in sctp_assoc_add_peer()
679 sctp_packet_init(&peer->packet, peer, asoc->base.bind_addr.port, in sctp_assoc_add_peer()
680 asoc->peer.port); in sctp_assoc_add_peer()
692 peer->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380)); in sctp_assoc_add_peer()
705 peer->rto = asoc->rto_initial; in sctp_assoc_add_peer()
706 sctp_max_rto(asoc, peer); in sctp_assoc_add_peer()
720 list_add_tail_rcu(&peer->transports, &asoc->peer.transport_addr_list); in sctp_assoc_add_peer()
721 asoc->peer.transport_count++; in sctp_assoc_add_peer()
726 if (!asoc->peer.primary_path) { in sctp_assoc_add_peer()
727 sctp_assoc_set_primary(asoc, peer); in sctp_assoc_add_peer()
728 asoc->peer.retran_path = peer; in sctp_assoc_add_peer()
731 if (asoc->peer.active_path == asoc->peer.retran_path && in sctp_assoc_add_peer()
733 asoc->peer.retran_path = peer; in sctp_assoc_add_peer()
740 void sctp_assoc_del_peer(struct sctp_association *asoc, in sctp_assoc_del_peer() argument
747 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { in sctp_assoc_del_peer()
751 sctp_assoc_rm_peer(asoc, transport); in sctp_assoc_del_peer()
759 const struct sctp_association *asoc, in sctp_assoc_lookup_paddr() argument
766 list_for_each_entry(t, &asoc->peer.transport_addr_list, in sctp_assoc_lookup_paddr()
776 void sctp_assoc_del_nonprimary_peers(struct sctp_association *asoc, in sctp_assoc_del_nonprimary_peers() argument
782 list_for_each_entry_safe(t, temp, &asoc->peer.transport_addr_list, in sctp_assoc_del_nonprimary_peers()
786 sctp_assoc_rm_peer(asoc, t); in sctp_assoc_del_nonprimary_peers()
794 void sctp_assoc_control_transport(struct sctp_association *asoc, in sctp_assoc_control_transport() argument
810 asoc->pf_expose != SCTP_PF_EXPOSE_ENABLE) in sctp_assoc_control_transport()
837 if (asoc->pf_expose != SCTP_PF_EXPOSE_ENABLE) in sctp_assoc_control_transport()
855 sctp_select_active_and_retran_path(asoc); in sctp_assoc_control_transport()
859 void sctp_association_hold(struct sctp_association *asoc) in sctp_association_hold() argument
861 refcount_inc(&asoc->base.refcnt); in sctp_association_hold()
867 void sctp_association_put(struct sctp_association *asoc) in sctp_association_put() argument
869 if (refcount_dec_and_test(&asoc->base.refcnt)) in sctp_association_put()
870 sctp_association_destroy(asoc); in sctp_association_put()
876 __u32 sctp_association_get_next_tsn(struct sctp_association *asoc) in sctp_association_get_next_tsn() argument
883 __u32 retval = asoc->next_tsn; in sctp_association_get_next_tsn()
884 asoc->next_tsn++; in sctp_association_get_next_tsn()
885 asoc->unack_data++; in sctp_association_get_next_tsn()
909 struct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc) in sctp_get_ecne_prepend() argument
911 if (!asoc->need_ecne) in sctp_get_ecne_prepend()
917 return sctp_make_ecne(asoc, asoc->last_ecne_tsn); in sctp_get_ecne_prepend()
923 struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *asoc, in sctp_assoc_lookup_tsn() argument
949 active = asoc->peer.active_path; in sctp_assoc_lookup_tsn()
961 list_for_each_entry(transport, &asoc->peer.transport_addr_list, in sctp_assoc_lookup_tsn()
981 struct sctp_association *asoc = in sctp_assoc_bh_rcv() local
984 struct net *net = asoc->base.net; in sctp_assoc_bh_rcv()
994 ep = asoc->ep; in sctp_assoc_bh_rcv()
996 inqueue = &asoc->base.inqueue; in sctp_assoc_bh_rcv()
997 sctp_association_hold(asoc); in sctp_assoc_bh_rcv()
999 state = asoc->state; in sctp_assoc_bh_rcv()
1033 if (sctp_auth_recv_cid(subtype.chunk, asoc) && !chunk->auth) in sctp_assoc_bh_rcv()
1040 asoc->peer.last_data_from = chunk->transport; in sctp_assoc_bh_rcv()
1043 asoc->stats.ictrlchunks++; in sctp_assoc_bh_rcv()
1045 asoc->stats.isacks++; in sctp_assoc_bh_rcv()
1053 state, ep, asoc, chunk, GFP_ATOMIC); in sctp_assoc_bh_rcv()
1058 if (asoc->base.dead) in sctp_assoc_bh_rcv()
1068 sctp_association_put(asoc); in sctp_assoc_bh_rcv()
1103 int sctp_assoc_update(struct sctp_association *asoc, in sctp_assoc_update() argument
1110 asoc->c = new->c; in sctp_assoc_update()
1111 asoc->peer.rwnd = new->peer.rwnd; in sctp_assoc_update()
1112 asoc->peer.sack_needed = new->peer.sack_needed; in sctp_assoc_update()
1113 asoc->peer.auth_capable = new->peer.auth_capable; in sctp_assoc_update()
1114 asoc->peer.i = new->peer.i; in sctp_assoc_update()
1116 if (!sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, in sctp_assoc_update()
1117 asoc->peer.i.initial_tsn, GFP_ATOMIC)) in sctp_assoc_update()
1121 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { in sctp_assoc_update()
1124 sctp_assoc_rm_peer(asoc, trans); in sctp_assoc_update()
1128 if (asoc->state >= SCTP_STATE_ESTABLISHED) in sctp_assoc_update()
1137 if (asoc->state >= SCTP_STATE_ESTABLISHED) { in sctp_assoc_update()
1138 asoc->next_tsn = new->next_tsn; in sctp_assoc_update()
1139 asoc->ctsn_ack_point = new->ctsn_ack_point; in sctp_assoc_update()
1140 asoc->adv_peer_ack_point = new->adv_peer_ack_point; in sctp_assoc_update()
1145 sctp_stream_clear(&asoc->stream); in sctp_assoc_update()
1151 sctp_ulpq_flush(&asoc->ulpq); in sctp_assoc_update()
1157 asoc->overall_error_count = 0; in sctp_assoc_update()
1163 if (!sctp_assoc_add_peer(asoc, &trans->ipaddr, in sctp_assoc_update()
1167 asoc->ctsn_ack_point = asoc->next_tsn - 1; in sctp_assoc_update()
1168 asoc->adv_peer_ack_point = asoc->ctsn_ack_point; in sctp_assoc_update()
1170 if (sctp_state(asoc, COOKIE_WAIT)) in sctp_assoc_update()
1171 sctp_stream_update(&asoc->stream, &new->stream); in sctp_assoc_update()
1174 if (sctp_assoc_set_id(asoc, GFP_ATOMIC)) in sctp_assoc_update()
1181 kfree(asoc->peer.peer_random); in sctp_assoc_update()
1182 asoc->peer.peer_random = new->peer.peer_random; in sctp_assoc_update()
1185 kfree(asoc->peer.peer_chunks); in sctp_assoc_update()
1186 asoc->peer.peer_chunks = new->peer.peer_chunks; in sctp_assoc_update()
1189 kfree(asoc->peer.peer_hmacs); in sctp_assoc_update()
1190 asoc->peer.peer_hmacs = new->peer.peer_hmacs; in sctp_assoc_update()
1193 return sctp_auth_asoc_init_active_key(asoc, GFP_ATOMIC); in sctp_assoc_update()
1275 void sctp_assoc_update_retran_path(struct sctp_association *asoc) in sctp_assoc_update_retran_path() argument
1277 struct sctp_transport *trans = asoc->peer.retran_path; in sctp_assoc_update_retran_path()
1281 if (asoc->peer.transport_count == 1) in sctp_assoc_update_retran_path()
1286 if (asoc->peer.active_path == asoc->peer.retran_path && in sctp_assoc_update_retran_path()
1287 asoc->peer.active_path->state == SCTP_ACTIVE) in sctp_assoc_update_retran_path()
1294 if (&trans->transports == &asoc->peer.transport_addr_list) in sctp_assoc_update_retran_path()
1303 if (trans == asoc->peer.retran_path) in sctp_assoc_update_retran_path()
1307 asoc->peer.retran_path = trans_next; in sctp_assoc_update_retran_path()
1310 __func__, asoc, &asoc->peer.retran_path->ipaddr.sa); in sctp_assoc_update_retran_path()
1313 static void sctp_select_active_and_retran_path(struct sctp_association *asoc) in sctp_select_active_and_retran_path() argument
1319 list_for_each_entry(trans, &asoc->peer.transport_addr_list, in sctp_select_active_and_retran_path()
1353 if ((asoc->peer.primary_path->state == SCTP_ACTIVE || in sctp_select_active_and_retran_path()
1354 asoc->peer.primary_path->state == SCTP_UNKNOWN) && in sctp_select_active_and_retran_path()
1355 asoc->peer.primary_path != trans_pri) { in sctp_select_active_and_retran_path()
1357 trans_pri = asoc->peer.primary_path; in sctp_select_active_and_retran_path()
1371 trans_pri = sctp_trans_elect_best(asoc->peer.active_path, trans_pf); in sctp_select_active_and_retran_path()
1376 asoc->peer.active_path = trans_pri; in sctp_select_active_and_retran_path()
1377 asoc->peer.retran_path = trans_sec; in sctp_select_active_and_retran_path()
1381 sctp_assoc_choose_alter_transport(struct sctp_association *asoc, in sctp_assoc_choose_alter_transport() argument
1389 return asoc->peer.active_path; in sctp_assoc_choose_alter_transport()
1391 if (last_sent_to == asoc->peer.retran_path) in sctp_assoc_choose_alter_transport()
1392 sctp_assoc_update_retran_path(asoc); in sctp_assoc_choose_alter_transport()
1394 return asoc->peer.retran_path; in sctp_assoc_choose_alter_transport()
1398 void sctp_assoc_update_frag_point(struct sctp_association *asoc) in sctp_assoc_update_frag_point() argument
1400 int frag = sctp_mtu_payload(sctp_sk(asoc->base.sk), asoc->pathmtu, in sctp_assoc_update_frag_point()
1401 sctp_datachk_len(&asoc->stream)); in sctp_assoc_update_frag_point()
1403 if (asoc->user_frag) in sctp_assoc_update_frag_point()
1404 frag = min_t(int, frag, asoc->user_frag); in sctp_assoc_update_frag_point()
1407 sctp_datachk_len(&asoc->stream)); in sctp_assoc_update_frag_point()
1409 asoc->frag_point = SCTP_TRUNC4(frag); in sctp_assoc_update_frag_point()
1412 void sctp_assoc_set_pmtu(struct sctp_association *asoc, __u32 pmtu) in sctp_assoc_set_pmtu() argument
1414 if (asoc->pathmtu != pmtu) { in sctp_assoc_set_pmtu()
1415 asoc->pathmtu = pmtu; in sctp_assoc_set_pmtu()
1416 sctp_assoc_update_frag_point(asoc); in sctp_assoc_set_pmtu()
1419 pr_debug("%s: asoc:%p, pmtu:%d, frag_point:%d\n", __func__, asoc, in sctp_assoc_set_pmtu()
1420 asoc->pathmtu, asoc->frag_point); in sctp_assoc_set_pmtu()
1426 void sctp_assoc_sync_pmtu(struct sctp_association *asoc) in sctp_assoc_sync_pmtu() argument
1431 if (!asoc) in sctp_assoc_sync_pmtu()
1435 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) { in sctp_assoc_sync_pmtu()
1445 sctp_assoc_set_pmtu(asoc, pmtu); in sctp_assoc_sync_pmtu()
1449 static inline bool sctp_peer_needs_update(struct sctp_association *asoc) in sctp_peer_needs_update() argument
1451 struct net *net = asoc->base.net; in sctp_peer_needs_update()
1453 switch (asoc->state) { in sctp_peer_needs_update()
1458 if ((asoc->rwnd > asoc->a_rwnd) && in sctp_peer_needs_update()
1459 ((asoc->rwnd - asoc->a_rwnd) >= max_t(__u32, in sctp_peer_needs_update()
1460 (asoc->base.sk->sk_rcvbuf >> net->sctp.rwnd_upd_shift), in sctp_peer_needs_update()
1461 asoc->pathmtu))) in sctp_peer_needs_update()
1471 void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned int len) in sctp_assoc_rwnd_increase() argument
1476 if (asoc->rwnd_over) { in sctp_assoc_rwnd_increase()
1477 if (asoc->rwnd_over >= len) { in sctp_assoc_rwnd_increase()
1478 asoc->rwnd_over -= len; in sctp_assoc_rwnd_increase()
1480 asoc->rwnd += (len - asoc->rwnd_over); in sctp_assoc_rwnd_increase()
1481 asoc->rwnd_over = 0; in sctp_assoc_rwnd_increase()
1484 asoc->rwnd += len; in sctp_assoc_rwnd_increase()
1492 if (asoc->rwnd_press) { in sctp_assoc_rwnd_increase()
1493 int change = min(asoc->pathmtu, asoc->rwnd_press); in sctp_assoc_rwnd_increase()
1494 asoc->rwnd += change; in sctp_assoc_rwnd_increase()
1495 asoc->rwnd_press -= change; in sctp_assoc_rwnd_increase()
1499 __func__, asoc, len, asoc->rwnd, asoc->rwnd_over, in sctp_assoc_rwnd_increase()
1500 asoc->a_rwnd); in sctp_assoc_rwnd_increase()
1507 if (sctp_peer_needs_update(asoc)) { in sctp_assoc_rwnd_increase()
1508 asoc->a_rwnd = asoc->rwnd; in sctp_assoc_rwnd_increase()
1511 "a_rwnd:%u\n", __func__, asoc, asoc->rwnd, in sctp_assoc_rwnd_increase()
1512 asoc->a_rwnd); in sctp_assoc_rwnd_increase()
1514 sack = sctp_make_sack(asoc); in sctp_assoc_rwnd_increase()
1518 asoc->peer.sack_needed = 0; in sctp_assoc_rwnd_increase()
1520 sctp_outq_tail(&asoc->outqueue, sack, GFP_ATOMIC); in sctp_assoc_rwnd_increase()
1523 timer = &asoc->timers[SCTP_EVENT_TIMEOUT_SACK]; in sctp_assoc_rwnd_increase()
1525 sctp_association_put(asoc); in sctp_assoc_rwnd_increase()
1530 void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len) in sctp_assoc_rwnd_decrease() argument
1535 if (unlikely(!asoc->rwnd || asoc->rwnd_over)) in sctp_assoc_rwnd_decrease()
1537 "asoc->rwnd_over:%u!\n", __func__, asoc, in sctp_assoc_rwnd_decrease()
1538 asoc->rwnd, asoc->rwnd_over); in sctp_assoc_rwnd_decrease()
1540 if (asoc->ep->rcvbuf_policy) in sctp_assoc_rwnd_decrease()
1541 rx_count = atomic_read(&asoc->rmem_alloc); in sctp_assoc_rwnd_decrease()
1543 rx_count = atomic_read(&asoc->base.sk->sk_rmem_alloc); in sctp_assoc_rwnd_decrease()
1550 if (rx_count >= asoc->base.sk->sk_rcvbuf) in sctp_assoc_rwnd_decrease()
1553 if (asoc->rwnd >= len) { in sctp_assoc_rwnd_decrease()
1554 asoc->rwnd -= len; in sctp_assoc_rwnd_decrease()
1556 asoc->rwnd_press += asoc->rwnd; in sctp_assoc_rwnd_decrease()
1557 asoc->rwnd = 0; in sctp_assoc_rwnd_decrease()
1560 asoc->rwnd_over += len - asoc->rwnd; in sctp_assoc_rwnd_decrease()
1561 asoc->rwnd = 0; in sctp_assoc_rwnd_decrease()
1565 __func__, asoc, len, asoc->rwnd, asoc->rwnd_over, in sctp_assoc_rwnd_decrease()
1566 asoc->rwnd_press); in sctp_assoc_rwnd_decrease()
1572 int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, in sctp_assoc_set_bind_addr_from_ep() argument
1575 struct sock *sk = asoc->base.sk; in sctp_assoc_set_bind_addr_from_ep()
1584 if (asoc->peer.ipv4_address) in sctp_assoc_set_bind_addr_from_ep()
1586 if (asoc->peer.ipv6_address) in sctp_assoc_set_bind_addr_from_ep()
1589 return sctp_bind_addr_copy(asoc->base.net, in sctp_assoc_set_bind_addr_from_ep()
1590 &asoc->base.bind_addr, in sctp_assoc_set_bind_addr_from_ep()
1591 &asoc->ep->base.bind_addr, in sctp_assoc_set_bind_addr_from_ep()
1596 int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc, in sctp_assoc_set_bind_addr_from_cookie() argument
1605 return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw, var_size3, in sctp_assoc_set_bind_addr_from_cookie()
1606 asoc->ep->base.bind_addr.port, gfp); in sctp_assoc_set_bind_addr_from_cookie()
1610 int sctp_assoc_lookup_laddr(struct sctp_association *asoc, in sctp_assoc_lookup_laddr() argument
1615 if ((asoc->base.bind_addr.port == ntohs(laddr->v4.sin_port)) && in sctp_assoc_lookup_laddr()
1616 sctp_bind_addr_match(&asoc->base.bind_addr, laddr, in sctp_assoc_lookup_laddr()
1617 sctp_sk(asoc->base.sk))) in sctp_assoc_lookup_laddr()
1624 int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp) in sctp_assoc_set_id() argument
1630 if (asoc->assoc_id) in sctp_assoc_set_id()
1639 ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, SCTP_ALL_ASSOC + 1, 0, in sctp_assoc_set_id()
1647 asoc->assoc_id = (sctp_assoc_t)ret; in sctp_assoc_set_id()
1652 static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc) in sctp_assoc_free_asconf_queue() argument
1657 list_for_each_entry_safe(asconf, tmp, &asoc->addip_chunk_list, list) { in sctp_assoc_free_asconf_queue()
1664 static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc) in sctp_assoc_free_asconf_acks() argument
1669 list_for_each_entry_safe(ack, tmp, &asoc->asconf_ack_list, in sctp_assoc_free_asconf_acks()
1677 void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc) in sctp_assoc_clean_asconf_ack_cache() argument
1685 list_for_each_entry_safe(ack, tmp, &asoc->asconf_ack_list, in sctp_assoc_clean_asconf_ack_cache()
1688 htonl(asoc->peer.addip_serial)) in sctp_assoc_clean_asconf_ack_cache()
1698 const struct sctp_association *asoc, in sctp_assoc_lookup_asconf_ack() argument
1706 list_for_each_entry(ack, &asoc->asconf_ack_list, transmitted_list) { in sctp_assoc_lookup_asconf_ack()
1718 void sctp_asconf_queue_teardown(struct sctp_association *asoc) in sctp_asconf_queue_teardown() argument
1721 sctp_assoc_free_asconf_acks(asoc); in sctp_asconf_queue_teardown()
1724 sctp_assoc_free_asconf_queue(asoc); in sctp_asconf_queue_teardown()
1727 if (asoc->addip_last_asconf) in sctp_asconf_queue_teardown()
1728 sctp_chunk_free(asoc->addip_last_asconf); in sctp_asconf_queue_teardown()