Lines Matching +full:touch +full:- +full:hold +full:- +full:ms

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
78 sctp_clog.x.sb.stcb_sbcc = stcb->asoc.sb_cc; in sctp_sblog()
82 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_sblog()
99 sctp_clog.x.close.sctp_flags = inp->sctp_flags; in sctp_log_closing()
102 sctp_clog.x.close.state = (uint16_t)stcb->asoc.state; in sctp_log_closing()
108 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_closing()
126 sctp_clog.x.rto.rtt = net->rtt / 1000; in rto_logging()
127 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in rto_logging()
149 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_strm_del_alt()
166 sctp_clog.x.nagle.total_flight = stcb->asoc.total_flight; in sctp_log_nagle_event()
167 sctp_clog.x.nagle.total_in_queue = stcb->asoc.total_output_queue_size; in sctp_log_nagle_event()
168 sctp_clog.x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue; in sctp_log_nagle_event()
169 sctp_clog.x.nagle.count_in_flight = stcb->asoc.total_flight_count; in sctp_log_nagle_event()
170 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_nagle_event()
191 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_sack()
211 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_map()
231 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_fr()
259 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_mb()
290 sctp_clog.x.strlog.stcb = control->stcb; in sctp_log_strm_del()
291 sctp_clog.x.strlog.n_tsn = control->sinfo_tsn; in sctp_log_strm_del()
292 sctp_clog.x.strlog.n_sseq = (uint16_t)control->mid; in sctp_log_strm_del()
293 sctp_clog.x.strlog.strm = control->sinfo_stream; in sctp_log_strm_del()
295 sctp_clog.x.strlog.e_tsn = poschk->sinfo_tsn; in sctp_log_strm_del()
296 sctp_clog.x.strlog.e_sseq = (uint16_t)poschk->mid; in sctp_log_strm_del()
301 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_strm_del()
318 if (stcb->asoc.send_queue_cnt > 255) in sctp_log_cwnd()
321 sctp_clog.x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt; in sctp_log_cwnd()
322 if (stcb->asoc.stream_queue_cnt > 255) in sctp_log_cwnd()
325 sctp_clog.x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt; in sctp_log_cwnd()
328 sctp_clog.x.cwnd.cwnd_new_value = net->cwnd; in sctp_log_cwnd()
329 sctp_clog.x.cwnd.inflight = net->flight_size; in sctp_log_cwnd()
330 sctp_clog.x.cwnd.pseudo_cumack = net->pseudo_cumack; in sctp_log_cwnd()
331 sctp_clog.x.cwnd.meets_pseudo_cumack = net->new_pseudo_cumack; in sctp_log_cwnd()
332 sctp_clog.x.cwnd.need_new_pseudo_cumack = net->find_pseudo_cumack; in sctp_log_cwnd()
335 sctp_clog.x.cwnd.meets_pseudo_cumack = stcb->asoc.peers_rwnd; in sctp_log_cwnd()
338 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_cwnd()
356 sctp_clog.x.lock.sock = (void *)inp->sctp_socket; in sctp_log_lock()
363 sctp_clog.x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx); in sctp_log_lock()
368 sctp_clog.x.lock.inp_lock = mtx_owned(&inp->inp_mtx); in sctp_log_lock()
369 sctp_clog.x.lock.create_lock = mtx_owned(&inp->inp_create_mtx); in sctp_log_lock()
375 if (inp && (inp->sctp_socket)) { in sctp_log_lock()
376 sctp_clog.x.lock.sock_lock = mtx_owned(SOCK_MTX(inp->sctp_socket)); in sctp_log_lock()
377 sctp_clog.x.lock.sockrcvbuf_lock = mtx_owned(SOCKBUF_MTX(&inp->sctp_socket->so_rcv)); in sctp_log_lock()
378 sctp_clog.x.lock.socksndbuf_lock = mtx_owned(SOCKBUF_MTX(&inp->sctp_socket->so_snd)); in sctp_log_lock()
384 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_lock()
403 sctp_clog.x.cwnd.inflight = net->flight_size; in sctp_log_maxburst()
405 if (stcb->asoc.send_queue_cnt > 255) in sctp_log_maxburst()
408 sctp_clog.x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt; in sctp_log_maxburst()
409 if (stcb->asoc.stream_queue_cnt > 255) in sctp_log_maxburst()
412 sctp_clog.x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt; in sctp_log_maxburst()
413 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_maxburst()
433 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_rwnd()
453 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_rwnd_set()
474 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_mbcnt()
489 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_misc_ints()
504 sctp_clog.x.wake.flight = stcb->asoc.total_flight_count; in sctp_wakeup_log()
505 sctp_clog.x.wake.send_q = stcb->asoc.send_queue_cnt; in sctp_wakeup_log()
506 sctp_clog.x.wake.sent_q = stcb->asoc.sent_queue_cnt; in sctp_wakeup_log()
508 if (stcb->asoc.stream_queue_cnt < 0xff) in sctp_wakeup_log()
509 sctp_clog.x.wake.stream_qcnt = (uint8_t)stcb->asoc.stream_queue_cnt; in sctp_wakeup_log()
513 if (stcb->asoc.chunks_on_out_queue < 0xff) in sctp_wakeup_log()
514 sctp_clog.x.wake.chunks_on_oque = (uint8_t)stcb->asoc.chunks_on_out_queue; in sctp_wakeup_log()
520 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) in sctp_wakeup_log()
522 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_WAKEOUTPUT) in sctp_wakeup_log()
524 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_WAKEINPUT) in sctp_wakeup_log()
527 if (stcb->sctp_socket) { in sctp_wakeup_log()
528 struct socket *so = stcb->sctp_socket; in sctp_wakeup_log()
530 sctp_clog.x.wake.sbflags = (uint8_t)((so->so_snd.sb_flags & 0x00ff)); in sctp_wakeup_log()
534 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_wakeup_log()
550 sctp_clog.x.blk.onsb = asoc->total_output_queue_size; in sctp_log_block()
551 sctp_clog.x.blk.send_sent_qcnt = (uint16_t)(asoc->send_queue_cnt + asoc->sent_queue_cnt); in sctp_log_block()
552 sctp_clog.x.blk.peer_rwnd = asoc->peers_rwnd; in sctp_log_block()
553 sctp_clog.x.blk.stream_qcnt = (uint16_t)asoc->stream_queue_cnt; in sctp_log_block()
554 sctp_clog.x.blk.chunks_on_oque = (uint16_t)asoc->chunks_on_out_queue; in sctp_log_block()
555 sctp_clog.x.blk.flight_size = (uint16_t)(asoc->total_flight / 1024); in sctp_log_block()
557 SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x", in sctp_log_block()
661 (0x000000ff & stcb->asoc.sent_queue_retran_cnt); in sctp_auditing()
669 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { in sctp_auditing()
670 if (chk->sent == SCTP_DATAGRAM_RESEND) { in sctp_auditing()
672 } else if (chk->sent < SCTP_DATAGRAM_RESEND) { in sctp_auditing()
673 tot_out += chk->book_size; in sctp_auditing()
677 if (resend_cnt != stcb->asoc.sent_queue_retran_cnt) { in sctp_auditing()
684 SCTP_PRINTF("resend_cnt:%d asoc-tot:%d\n", in sctp_auditing()
685 resend_cnt, stcb->asoc.sent_queue_retran_cnt); in sctp_auditing()
687 stcb->asoc.sent_queue_retran_cnt = resend_cnt; in sctp_auditing()
690 (0x000000ff & stcb->asoc.sent_queue_retran_cnt); in sctp_auditing()
696 if (tot_out != stcb->asoc.total_flight) { in sctp_auditing()
705 (int)stcb->asoc.total_flight); in sctp_auditing()
706 stcb->asoc.total_flight = tot_out; in sctp_auditing()
708 if (tot_book_cnt != stcb->asoc.total_flight_count) { in sctp_auditing()
718 stcb->asoc.total_flight_count = tot_book_cnt; in sctp_auditing()
721 TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) { in sctp_auditing()
722 tot_out += lnet->flight_size; in sctp_auditing()
724 if (tot_out != stcb->asoc.total_flight) { in sctp_auditing()
733 stcb->asoc.total_flight, tot_out); in sctp_auditing()
735 TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) { in sctp_auditing()
737 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { in sctp_auditing()
738 if ((chk->whoTo == lnet) && in sctp_auditing()
739 (chk->sent < SCTP_DATAGRAM_RESEND)) { in sctp_auditing()
740 tot_out += chk->book_size; in sctp_auditing()
743 if (lnet->flight_size != tot_out) { in sctp_auditing()
745 (void *)lnet, lnet->flight_size, in sctp_auditing()
747 lnet->flight_size = tot_out; in sctp_auditing()
804 temp = (((uint64_t)ticks * 1000) + (hz - 1)) / hz; in sctp_ticks_to_msecs()
835 temp = ((uint64_t)ticks + (hz - 1)) / hz; in sctp_ticks_to_secs()
855 inp = stcb->sctp_ep; in sctp_stop_timers_for_shutdown()
865 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { in sctp_stop_timers_for_shutdown()
879 inp = stcb->sctp_ep; in sctp_stop_association_timers()
897 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { in sctp_stop_association_timers()
960 KASSERT((sctp_mtu_sizes[i - 1] & 0x00000003) == 0, in sctp_get_prev_mtu()
961 ("sctp_mtu_sizes[%u] not a multiple of 4", i - 1)); in sctp_get_prev_mtu()
962 return (sctp_mtu_sizes[i - 1]); in sctp_get_prev_mtu()
992 * Here we use the MD5/SHA-1 to hash with our good randomNumbers and in sctp_fill_random_store()
998 * numbers, but thats ok too since that is random as well :-> in sctp_fill_random_store()
1000 m->store_at = 0; in sctp_fill_random_store()
1001 (void)sctp_hmac(SCTP_HMAC, (uint8_t *)m->random_numbers, in sctp_fill_random_store()
1002 sizeof(m->random_numbers), (uint8_t *)&m->random_counter, in sctp_fill_random_store()
1003 sizeof(m->random_counter), (uint8_t *)m->random_store); in sctp_fill_random_store()
1004 m->random_counter++; in sctp_fill_random_store()
1019 if (inp->initial_sequence_debug != 0) { in sctp_select_initial_TSN()
1022 ret = inp->initial_sequence_debug; in sctp_select_initial_TSN()
1023 inp->initial_sequence_debug++; in sctp_select_initial_TSN()
1027 store_at = inp->store_at; in sctp_select_initial_TSN()
1029 if (new_store >= (SCTP_SIGNATURE_SIZE - 3)) { in sctp_select_initial_TSN()
1032 if (!atomic_cmpset_int(&inp->store_at, store_at, new_store)) { in sctp_select_initial_TSN()
1039 p = &inp->random_store[store_at]; in sctp_select_initial_TSN()
1055 x = sctp_select_initial_TSN(&inp->sctp_ep); in sctp_select_a_tag()
1133 asoc = &stcb->asoc; in sctp_init_asoc()
1136 asoc->max_burst = inp->sctp_ep.max_burst; in sctp_init_asoc()
1137 asoc->fr_max_burst = inp->sctp_ep.fr_max_burst; in sctp_init_asoc()
1138 asoc->heart_beat_delay = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]); in sctp_init_asoc()
1139 asoc->cookie_life = inp->sctp_ep.def_cookie_life; in sctp_init_asoc()
1140 asoc->sctp_cmt_on_off = inp->sctp_cmt_on_off; in sctp_init_asoc()
1141 asoc->ecn_supported = inp->ecn_supported; in sctp_init_asoc()
1142 asoc->prsctp_supported = inp->prsctp_supported; in sctp_init_asoc()
1143 asoc->auth_supported = inp->auth_supported; in sctp_init_asoc()
1144 asoc->asconf_supported = inp->asconf_supported; in sctp_init_asoc()
1145 asoc->reconfig_supported = inp->reconfig_supported; in sctp_init_asoc()
1146 asoc->nrsack_supported = inp->nrsack_supported; in sctp_init_asoc()
1147 asoc->pktdrop_supported = inp->pktdrop_supported; in sctp_init_asoc()
1148 asoc->idata_supported = inp->idata_supported; in sctp_init_asoc()
1149 asoc->rcv_edmid = inp->rcv_edmid; in sctp_init_asoc()
1150 asoc->snd_edmid = SCTP_EDMID_NONE; in sctp_init_asoc()
1151 asoc->sctp_cmt_pf = (uint8_t)0; in sctp_init_asoc()
1152 asoc->sctp_frag_point = inp->sctp_frag_point; in sctp_init_asoc()
1153 asoc->sctp_features = inp->sctp_features; in sctp_init_asoc()
1154 asoc->default_dscp = inp->sctp_ep.default_dscp; in sctp_init_asoc()
1155 asoc->max_cwnd = inp->max_cwnd; in sctp_init_asoc()
1157 if (inp->sctp_ep.default_flowlabel) { in sctp_init_asoc()
1158 asoc->default_flowlabel = inp->sctp_ep.default_flowlabel; in sctp_init_asoc()
1160 if (inp->ip_inp.inp.inp_flags & IN6P_AUTOFLOWLABEL) { in sctp_init_asoc()
1161 asoc->default_flowlabel = sctp_select_initial_TSN(&inp->sctp_ep); in sctp_init_asoc()
1162 asoc->default_flowlabel &= 0x000fffff; in sctp_init_asoc()
1163 asoc->default_flowlabel |= 0x80000000; in sctp_init_asoc()
1165 asoc->default_flowlabel = 0; in sctp_init_asoc()
1169 asoc->sb_send_resv = 0; in sctp_init_asoc()
1171 asoc->my_vtag = override_tag; in sctp_init_asoc()
1173 asoc->my_vtag = sctp_select_a_tag(inp, stcb->sctp_ep->sctp_lport, stcb->rport, 1); in sctp_init_asoc()
1176 asoc->my_vtag_nonce = sctp_select_a_tag(inp, stcb->sctp_ep->sctp_lport, stcb->rport, 0); in sctp_init_asoc()
1177 asoc->peer_vtag_nonce = sctp_select_a_tag(inp, stcb->sctp_ep->sctp_lport, stcb->rport, 0); in sctp_init_asoc()
1178 asoc->vrf_id = vrf_id; in sctp_init_asoc()
1181 asoc->tsn_in_at = 0; in sctp_init_asoc()
1182 asoc->tsn_out_at = 0; in sctp_init_asoc()
1183 asoc->tsn_in_wrapped = 0; in sctp_init_asoc()
1184 asoc->tsn_out_wrapped = 0; in sctp_init_asoc()
1185 asoc->cumack_log_at = 0; in sctp_init_asoc()
1186 asoc->cumack_log_atsnt = 0; in sctp_init_asoc()
1189 asoc->fs_index = 0; in sctp_init_asoc()
1191 asoc->refcnt = 0; in sctp_init_asoc()
1192 asoc->assoc_up_sent = 0; in sctp_init_asoc()
1194 asoc->init_seq_number = initial_tsn; in sctp_init_asoc()
1196 asoc->init_seq_number = sctp_select_initial_TSN(&inp->sctp_ep); in sctp_init_asoc()
1198 asoc->asconf_seq_out = asoc->init_seq_number; in sctp_init_asoc()
1199 asoc->str_reset_seq_out = asoc->init_seq_number; in sctp_init_asoc()
1200 asoc->sending_seq = asoc->init_seq_number; in sctp_init_asoc()
1201 asoc->asconf_seq_out_acked = asoc->init_seq_number - 1; in sctp_init_asoc()
1203 asoc->peer_supports_nat = 0; in sctp_init_asoc()
1204 asoc->sent_queue_retran_cnt = 0; in sctp_init_asoc()
1207 asoc->last_net_cmt_send_started = NULL; in sctp_init_asoc()
1209 asoc->last_acked_seq = asoc->init_seq_number - 1; in sctp_init_asoc()
1210 asoc->advanced_peer_ack_point = asoc->init_seq_number - 1; in sctp_init_asoc()
1211 asoc->asconf_seq_in = asoc->init_seq_number - 1; in sctp_init_asoc()
1213 /* here we are different, we hold the next one we expect */ in sctp_init_asoc()
1214 asoc->str_reset_seq_in = asoc->init_seq_number; in sctp_init_asoc()
1216 asoc->initial_init_rto_max = inp->sctp_ep.initial_init_rto_max; in sctp_init_asoc()
1217 asoc->initial_rto = inp->sctp_ep.initial_rto; in sctp_init_asoc()
1219 asoc->default_mtu = inp->sctp_ep.default_mtu; in sctp_init_asoc()
1220 asoc->max_init_times = inp->sctp_ep.max_init_times; in sctp_init_asoc()
1221 asoc->max_send_times = inp->sctp_ep.max_send_times; in sctp_init_asoc()
1222 asoc->def_net_failure = inp->sctp_ep.def_net_failure; in sctp_init_asoc()
1223 asoc->def_net_pf_threshold = inp->sctp_ep.def_net_pf_threshold; in sctp_init_asoc()
1224 asoc->free_chunk_cnt = 0; in sctp_init_asoc()
1226 asoc->iam_blocking = 0; in sctp_init_asoc()
1227 asoc->context = inp->sctp_context; in sctp_init_asoc()
1228 asoc->local_strreset_support = inp->local_strreset_support; in sctp_init_asoc()
1229 asoc->def_send = inp->def_send; in sctp_init_asoc()
1230 asoc->delayed_ack = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]); in sctp_init_asoc()
1231 asoc->sack_freq = inp->sctp_ep.sctp_sack_freq; in sctp_init_asoc()
1232 asoc->pr_sctp_cnt = 0; in sctp_init_asoc()
1233 asoc->total_output_queue_size = 0; in sctp_init_asoc()
1235 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { in sctp_init_asoc()
1236 asoc->scope.ipv6_addr_legal = 1; in sctp_init_asoc()
1238 asoc->scope.ipv4_addr_legal = 1; in sctp_init_asoc()
1240 asoc->scope.ipv4_addr_legal = 0; in sctp_init_asoc()
1243 asoc->scope.ipv6_addr_legal = 0; in sctp_init_asoc()
1244 asoc->scope.ipv4_addr_legal = 1; in sctp_init_asoc()
1247 asoc->my_rwnd = max(SCTP_SB_LIMIT_RCV(inp->sctp_socket), SCTP_MINIMAL_RWND); in sctp_init_asoc()
1248 asoc->peers_rwnd = SCTP_SB_LIMIT_RCV(inp->sctp_socket); in sctp_init_asoc()
1250 asoc->smallest_mtu = 0; in sctp_init_asoc()
1251 asoc->minrto = inp->sctp_ep.sctp_minrto; in sctp_init_asoc()
1252 asoc->maxrto = inp->sctp_ep.sctp_maxrto; in sctp_init_asoc()
1254 asoc->stream_locked_on = 0; in sctp_init_asoc()
1255 asoc->ecn_echo_cnt_onq = 0; in sctp_init_asoc()
1256 asoc->stream_locked = 0; in sctp_init_asoc()
1258 asoc->send_sack = 1; in sctp_init_asoc()
1260 LIST_INIT(&asoc->sctp_restricted_addrs); in sctp_init_asoc()
1262 TAILQ_INIT(&asoc->nets); in sctp_init_asoc()
1263 TAILQ_INIT(&asoc->pending_reply_queue); in sctp_init_asoc()
1264 TAILQ_INIT(&asoc->asconf_ack_sent); in sctp_init_asoc()
1266 asoc->hb_random_idx = 4; in sctp_init_asoc()
1268 asoc->sctp_autoclose_ticks = inp->sctp_ep.auto_close_time; in sctp_init_asoc()
1270 stcb->asoc.congestion_control_module = inp->sctp_ep.sctp_default_cc_module; in sctp_init_asoc()
1271 stcb->asoc.cc_functions = sctp_cc_functions[inp->sctp_ep.sctp_default_cc_module]; in sctp_init_asoc()
1273 stcb->asoc.stream_scheduling_module = inp->sctp_ep.sctp_default_ss_module; in sctp_init_asoc()
1274 stcb->asoc.ss_functions = sctp_ss_functions[inp->sctp_ep.sctp_default_ss_module]; in sctp_init_asoc()
1280 asoc->strm_realoutsize = asoc->streamoutcnt = asoc->pre_open_streams = in sctp_init_asoc()
1282 SCTP_MALLOC(asoc->strmout, struct sctp_stream_out *, in sctp_init_asoc()
1283 asoc->streamoutcnt * sizeof(struct sctp_stream_out), in sctp_init_asoc()
1285 if (asoc->strmout == NULL) { in sctp_init_asoc()
1291 for (i = 0; i < asoc->streamoutcnt; i++) { in sctp_init_asoc()
1294 * the INIT-ACK back (for INIT sender) we MUST reduce the in sctp_init_asoc()
1300 TAILQ_INIT(&asoc->strmout[i].outqueue); in sctp_init_asoc()
1301 asoc->ss_functions.sctp_ss_init_stream(stcb, &asoc->strmout[i], NULL); in sctp_init_asoc()
1302 asoc->strmout[i].chunks_on_queues = 0; in sctp_init_asoc()
1305 asoc->strmout[i].abandoned_sent[j] = 0; in sctp_init_asoc()
1306 asoc->strmout[i].abandoned_unsent[j] = 0; in sctp_init_asoc()
1309 asoc->strmout[i].abandoned_sent[0] = 0; in sctp_init_asoc()
1310 asoc->strmout[i].abandoned_unsent[0] = 0; in sctp_init_asoc()
1312 asoc->strmout[i].next_mid_ordered = 0; in sctp_init_asoc()
1313 asoc->strmout[i].next_mid_unordered = 0; in sctp_init_asoc()
1314 asoc->strmout[i].sid = i; in sctp_init_asoc()
1315 asoc->strmout[i].last_msg_incomplete = 0; in sctp_init_asoc()
1316 asoc->strmout[i].state = SCTP_STREAM_OPENING; in sctp_init_asoc()
1318 asoc->ss_functions.sctp_ss_init(stcb, asoc); in sctp_init_asoc()
1322 asoc->mapping_array_size = SCTP_INITIAL_MAPPING_ARRAY; in sctp_init_asoc()
1323 SCTP_MALLOC(asoc->mapping_array, uint8_t *, asoc->mapping_array_size, in sctp_init_asoc()
1325 if (asoc->mapping_array == NULL) { in sctp_init_asoc()
1326 SCTP_FREE(asoc->strmout, SCTP_M_STRMO); in sctp_init_asoc()
1330 memset(asoc->mapping_array, 0, asoc->mapping_array_size); in sctp_init_asoc()
1331 SCTP_MALLOC(asoc->nr_mapping_array, uint8_t *, asoc->mapping_array_size, in sctp_init_asoc()
1333 if (asoc->nr_mapping_array == NULL) { in sctp_init_asoc()
1334 SCTP_FREE(asoc->strmout, SCTP_M_STRMO); in sctp_init_asoc()
1335 SCTP_FREE(asoc->mapping_array, SCTP_M_MAP); in sctp_init_asoc()
1339 memset(asoc->nr_mapping_array, 0, asoc->mapping_array_size); in sctp_init_asoc()
1342 TAILQ_INIT(&asoc->free_chunks); in sctp_init_asoc()
1343 TAILQ_INIT(&asoc->control_send_queue); in sctp_init_asoc()
1344 TAILQ_INIT(&asoc->asconf_send_queue); in sctp_init_asoc()
1345 TAILQ_INIT(&asoc->send_queue); in sctp_init_asoc()
1346 TAILQ_INIT(&asoc->sent_queue); in sctp_init_asoc()
1347 TAILQ_INIT(&asoc->resetHead); in sctp_init_asoc()
1348 asoc->max_inbound_streams = inp->sctp_ep.max_open_streams_intome; in sctp_init_asoc()
1349 TAILQ_INIT(&asoc->asconf_queue); in sctp_init_asoc()
1351 asoc->authinfo.random = NULL; in sctp_init_asoc()
1352 asoc->authinfo.active_keyid = 0; in sctp_init_asoc()
1353 asoc->authinfo.assoc_key = NULL; in sctp_init_asoc()
1354 asoc->authinfo.assoc_keyid = 0; in sctp_init_asoc()
1355 asoc->authinfo.recv_key = NULL; in sctp_init_asoc()
1356 asoc->authinfo.recv_keyid = 0; in sctp_init_asoc()
1357 LIST_INIT(&asoc->shared_keys); in sctp_init_asoc()
1358 asoc->marked_retrans = 0; in sctp_init_asoc()
1359 asoc->port = inp->sctp_ep.port; in sctp_init_asoc()
1360 asoc->timoinit = 0; in sctp_init_asoc()
1361 asoc->timodata = 0; in sctp_init_asoc()
1362 asoc->timosack = 0; in sctp_init_asoc()
1363 asoc->timoshutdown = 0; in sctp_init_asoc()
1364 asoc->timoheartbeat = 0; in sctp_init_asoc()
1365 asoc->timocookie = 0; in sctp_init_asoc()
1366 asoc->timoshutdownack = 0; in sctp_init_asoc()
1367 (void)SCTP_GETTIME_TIMEVAL(&asoc->start_time); in sctp_init_asoc()
1368 asoc->discontinuity_time = asoc->start_time; in sctp_init_asoc()
1370 asoc->abandoned_unsent[i] = 0; in sctp_init_asoc()
1371 asoc->abandoned_sent[i] = 0; in sctp_init_asoc()
1386 asoc->mapping_array_size, in sctp_print_mapping_array()
1387 asoc->mapping_array_base_tsn, in sctp_print_mapping_array()
1388 asoc->cumulative_tsn, in sctp_print_mapping_array()
1389 asoc->highest_tsn_inside_map, in sctp_print_mapping_array()
1390 asoc->highest_tsn_inside_nr_map); in sctp_print_mapping_array()
1391 for (limit = asoc->mapping_array_size; limit > 1; limit--) { in sctp_print_mapping_array()
1392 if (asoc->mapping_array[limit - 1] != 0) { in sctp_print_mapping_array()
1396 …SCTP_PRINTF("Renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - li… in sctp_print_mapping_array()
1398 SCTP_PRINTF("%2.2x%c", asoc->mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); in sctp_print_mapping_array()
1402 for (limit = asoc->mapping_array_size; limit > 1; limit--) { in sctp_print_mapping_array()
1403 if (asoc->nr_mapping_array[limit - 1]) { in sctp_print_mapping_array()
1407 …NTF("Non renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); in sctp_print_mapping_array()
1409 SCTP_PRINTF("%2.2x%c", asoc->nr_mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); in sctp_print_mapping_array()
1422 new_size = asoc->mapping_array_size + ((needed + 7) / 8 + SCTP_MAPPING_ARRAY_INCR); in sctp_expand_mapping_array()
1434 return (-1); in sctp_expand_mapping_array()
1438 memcpy(new_array1, asoc->mapping_array, asoc->mapping_array_size); in sctp_expand_mapping_array()
1439 memcpy(new_array2, asoc->nr_mapping_array, asoc->mapping_array_size); in sctp_expand_mapping_array()
1440 SCTP_FREE(asoc->mapping_array, SCTP_M_MAP); in sctp_expand_mapping_array()
1441 SCTP_FREE(asoc->nr_mapping_array, SCTP_M_MAP); in sctp_expand_mapping_array()
1442 asoc->mapping_array = new_array1; in sctp_expand_mapping_array()
1443 asoc->nr_mapping_array = new_array2; in sctp_expand_mapping_array()
1444 asoc->mapping_array_size = new_size; in sctp_expand_mapping_array()
1461 if (it->inp) { in sctp_iterator_work()
1462 SCTP_INP_RLOCK(it->inp); in sctp_iterator_work()
1463 SCTP_INP_DECR_REF(it->inp); in sctp_iterator_work()
1465 if (it->inp == NULL) { in sctp_iterator_work()
1471 if (it->function_atend != NULL) { in sctp_iterator_work()
1472 (*it->function_atend) (it->pointer, it->val); in sctp_iterator_work()
1482 SCTP_INP_RLOCK(it->inp); in sctp_iterator_work()
1484 while (((it->pcb_flags) && in sctp_iterator_work()
1485 ((it->inp->sctp_flags & it->pcb_flags) != it->pcb_flags)) || in sctp_iterator_work()
1486 ((it->pcb_features) && in sctp_iterator_work()
1487 ((it->inp->sctp_features & it->pcb_features) != it->pcb_features))) { in sctp_iterator_work()
1489 if (it->iterator_flags & SCTP_ITERATOR_DO_SINGLE_INP) { in sctp_iterator_work()
1490 SCTP_INP_RUNLOCK(it->inp); in sctp_iterator_work()
1493 tinp = it->inp; in sctp_iterator_work()
1494 it->inp = LIST_NEXT(it->inp, sctp_list); in sctp_iterator_work()
1495 it->stcb = NULL; in sctp_iterator_work()
1497 if (it->inp == NULL) { in sctp_iterator_work()
1500 SCTP_INP_RLOCK(it->inp); in sctp_iterator_work()
1503 if (it->done_current_ep == 0) { in sctp_iterator_work()
1504 if (it->function_inp != NULL) in sctp_iterator_work()
1505 inp_skip = (*it->function_inp) (it->inp, it->pointer, it->val); in sctp_iterator_work()
1506 it->done_current_ep = 1; in sctp_iterator_work()
1508 if (it->stcb == NULL) { in sctp_iterator_work()
1510 it->stcb = LIST_FIRST(&it->inp->sctp_asoc_list); in sctp_iterator_work()
1512 if ((inp_skip) || it->stcb == NULL) { in sctp_iterator_work()
1513 if (it->function_inp_end != NULL) { in sctp_iterator_work()
1514 inp_skip = (*it->function_inp_end) (it->inp, in sctp_iterator_work()
1515 it->pointer, in sctp_iterator_work()
1516 it->val); in sctp_iterator_work()
1518 SCTP_INP_RUNLOCK(it->inp); in sctp_iterator_work()
1521 while (it->stcb != NULL) { in sctp_iterator_work()
1522 SCTP_TCB_LOCK(it->stcb); in sctp_iterator_work()
1523 if (it->asoc_state && ((it->stcb->asoc.state & it->asoc_state) != it->asoc_state)) { in sctp_iterator_work()
1525 SCTP_TCB_UNLOCK(it->stcb); in sctp_iterator_work()
1532 atomic_add_int(&it->stcb->asoc.refcnt, 1); in sctp_iterator_work()
1533 SCTP_TCB_UNLOCK(it->stcb); in sctp_iterator_work()
1534 SCTP_INP_INCR_REF(it->inp); in sctp_iterator_work()
1535 SCTP_INP_RUNLOCK(it->inp); in sctp_iterator_work()
1542 SCTP_INP_DECR_REF(it->inp); in sctp_iterator_work()
1543 atomic_subtract_int(&it->stcb->asoc.refcnt, 1); in sctp_iterator_work()
1559 SCTP_INP_RLOCK(it->inp); in sctp_iterator_work()
1560 SCTP_INP_DECR_REF(it->inp); in sctp_iterator_work()
1561 SCTP_TCB_LOCK(it->stcb); in sctp_iterator_work()
1562 atomic_subtract_int(&it->stcb->asoc.refcnt, 1); in sctp_iterator_work()
1565 KASSERT(it->inp == it->stcb->sctp_ep, in sctp_iterator_work()
1567 __func__, it->stcb, it->inp, it->stcb->sctp_ep)); in sctp_iterator_work()
1568 SCTP_INP_RLOCK_ASSERT(it->inp); in sctp_iterator_work()
1569 SCTP_TCB_LOCK_ASSERT(it->stcb); in sctp_iterator_work()
1572 (*it->function_assoc) (it->inp, it->stcb, it->pointer, it->val); in sctp_iterator_work()
1573 SCTP_INP_RLOCK_ASSERT(it->inp); in sctp_iterator_work()
1574 SCTP_TCB_LOCK_ASSERT(it->stcb); in sctp_iterator_work()
1578 * first I must verify that this won't effect things :-0 in sctp_iterator_work()
1580 if (it->no_chunk_output == 0) { in sctp_iterator_work()
1581 sctp_chunk_output(it->inp, it->stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED); in sctp_iterator_work()
1582 SCTP_INP_RLOCK_ASSERT(it->inp); in sctp_iterator_work()
1583 SCTP_TCB_LOCK_ASSERT(it->stcb); in sctp_iterator_work()
1586 SCTP_TCB_UNLOCK(it->stcb); in sctp_iterator_work()
1588 it->stcb = LIST_NEXT(it->stcb, sctp_tcblist); in sctp_iterator_work()
1589 if (it->stcb == NULL) { in sctp_iterator_work()
1591 if (it->function_inp_end != NULL) { in sctp_iterator_work()
1592 inp_skip = (*it->function_inp_end) (it->inp, in sctp_iterator_work()
1593 it->pointer, in sctp_iterator_work()
1594 it->val); in sctp_iterator_work()
1598 SCTP_INP_RUNLOCK(it->inp); in sctp_iterator_work()
1601 it->done_current_ep = 0; in sctp_iterator_work()
1602 if (it->iterator_flags & SCTP_ITERATOR_DO_SINGLE_INP) { in sctp_iterator_work()
1603 it->inp = NULL; in sctp_iterator_work()
1605 it->inp = LIST_NEXT(it->inp, sctp_list); in sctp_iterator_work()
1607 it->stcb = NULL; in sctp_iterator_work()
1608 if (it->inp == NULL) { in sctp_iterator_work()
1625 CURVNET_SET(it->vn); in sctp_iterator_worker()
1652 LIST_INIT(&asc->list_of_work); in sctp_handle_addr_wq()
1653 asc->cnt = 0; in sctp_handle_addr_wq()
1657 LIST_INSERT_HEAD(&asc->list_of_work, wi, sctp_nxt_addr); in sctp_handle_addr_wq()
1658 asc->cnt++; in sctp_handle_addr_wq()
1661 if (asc->cnt == 0) { in sctp_handle_addr_wq()
1683 LIST_FOREACH(wi, &asc->list_of_work, sctp_nxt_addr) { in sctp_handle_addr_wq()
1692 /*-
1697 *|-----------------------------|-----------------------------|----|----|----|
1698 *|SCTP_TIMER_TYPE_SEND |net->rxt_timer |Yes |Yes |Yes |
1699 *|SCTP_TIMER_TYPE_INIT |net->rxt_timer |Yes |Yes |Yes |
1700 *|SCTP_TIMER_TYPE_RECV |stcb->asoc.dack_timer |Yes |Yes |No |
1701 *|SCTP_TIMER_TYPE_SHUTDOWN |net->rxt_timer |Yes |Yes |Yes |
1702 *|SCTP_TIMER_TYPE_HEARTBEAT |net->hb_timer |Yes |Yes |Yes |
1703 *|SCTP_TIMER_TYPE_COOKIE |net->rxt_timer |Yes |Yes |Yes |
1704 *|SCTP_TIMER_TYPE_NEWCOOKIE |inp->sctp_ep.signature_change|Yes |No |No |
1705 *|SCTP_TIMER_TYPE_PATHMTURAISE |net->pmtu_timer |Yes |Yes |Yes |
1706 *|SCTP_TIMER_TYPE_SHUTDOWNACK |net->rxt_timer |Yes |Yes |Yes |
1707 *|SCTP_TIMER_TYPE_ASCONF |stcb->asoc.asconf_timer |Yes |Yes |Yes |
1708 *|SCTP_TIMER_TYPE_SHUTDOWNGUARD|stcb->asoc.shut_guard_timer |Yes |Yes |No |
1709 *|SCTP_TIMER_TYPE_AUTOCLOSE |stcb->asoc.autoclose_timer |Yes |Yes |No |
1710 *|SCTP_TIMER_TYPE_STRRESET |stcb->asoc.strreset_timer |Yes |Yes |No |
1711 *|SCTP_TIMER_TYPE_INPKILL |inp->sctp_ep.signature_change|Yes |No |No |
1712 *|SCTP_TIMER_TYPE_ASOCKILL |stcb->asoc.strreset_timer |Yes |Yes |No |
1714 *|SCTP_TIMER_TYPE_PRIM_DELETED |stcb->asoc.delete_prim_timer |Yes |Yes |No |
1737 inp = (struct sctp_inpcb *)tmr->ep; in sctp_timeout_handler()
1738 stcb = (struct sctp_tcb *)tmr->tcb; in sctp_timeout_handler()
1739 net = (struct sctp_nets *)tmr->net; in sctp_timeout_handler()
1740 CURVNET_SET((struct vnet *)tmr->vnet); in sctp_timeout_handler()
1745 sctp_audit_log(0xF0, (uint8_t)tmr->type); in sctp_timeout_handler()
1750 KASSERT(tmr->self == NULL || tmr->self == tmr, in sctp_timeout_handler()
1751 ("sctp_timeout_handler: tmr->self corrupted")); in sctp_timeout_handler()
1752 KASSERT(SCTP_IS_TIMER_TYPE_VALID(tmr->type), in sctp_timeout_handler()
1753 ("sctp_timeout_handler: invalid timer type %d", tmr->type)); in sctp_timeout_handler()
1754 type = tmr->type; in sctp_timeout_handler()
1755 KASSERT(stcb == NULL || stcb->sctp_ep == inp, in sctp_timeout_handler()
1756 ("sctp_timeout_handler of type %d: inp = %p, stcb->sctp_ep %p", in sctp_timeout_handler()
1757 type, stcb, stcb->sctp_ep)); in sctp_timeout_handler()
1758 tmr->stopped_from = 0xa001; in sctp_timeout_handler()
1759 if ((stcb != NULL) && (stcb->asoc.state == SCTP_STATE_EMPTY)) { in sctp_timeout_handler()
1765 tmr->stopped_from = 0xa002; in sctp_timeout_handler()
1767 if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) { in sctp_timeout_handler()
1774 tmr->stopped_from = 0xa003; in sctp_timeout_handler()
1782 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_timeout_handler()
1785 ((stcb->asoc.state == SCTP_STATE_EMPTY) || in sctp_timeout_handler()
1786 (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED))) { in sctp_timeout_handler()
1799 tmr->stopped_from = type; in sctp_timeout_handler()
1801 if (SCTP_OS_TIMER_PENDING(&tmr->timer)) { in sctp_timeout_handler()
1807 if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) { in sctp_timeout_handler()
1813 SCTP_OS_TIMER_DEACTIVATE(&tmr->timer); in sctp_timeout_handler()
1822 stcb->asoc.timodata++; in sctp_timeout_handler()
1823 stcb->asoc.num_send_timers_up--; in sctp_timeout_handler()
1824 if (stcb->asoc.num_send_timers_up < 0) { in sctp_timeout_handler()
1825 stcb->asoc.num_send_timers_up = 0; in sctp_timeout_handler()
1839 if ((stcb->asoc.num_send_timers_up == 0) && in sctp_timeout_handler()
1840 (stcb->asoc.sent_queue_cnt > 0)) { in sctp_timeout_handler()
1849 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { in sctp_timeout_handler()
1850 if (chk->whoTo != NULL) { in sctp_timeout_handler()
1855 sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, chk->whoTo); in sctp_timeout_handler()
1864 stcb->asoc.timoinit++; in sctp_timeout_handler()
1876 stcb->asoc.timosack++; in sctp_timeout_handler()
1889 stcb->asoc.timoshutdown++; in sctp_timeout_handler()
1905 stcb->asoc.timoheartbeat++; in sctp_timeout_handler()
1913 if ((net->dest_state & SCTP_ADDR_NOHB) == 0) { in sctp_timeout_handler()
1926 stcb->asoc.timocookie++; in sctp_timeout_handler()
1947 inp->sctp_ep.time_of_secret_change = tv.tv_sec; in sctp_timeout_handler()
1948 inp->sctp_ep.last_secret_number = in sctp_timeout_handler()
1949 inp->sctp_ep.current_secret_number; in sctp_timeout_handler()
1950 inp->sctp_ep.current_secret_number++; in sctp_timeout_handler()
1951 if (inp->sctp_ep.current_secret_number >= in sctp_timeout_handler()
1953 inp->sctp_ep.current_secret_number = 0; in sctp_timeout_handler()
1955 secret = (int)inp->sctp_ep.current_secret_number; in sctp_timeout_handler()
1957 inp->sctp_ep.secret_key[secret][i] = in sctp_timeout_handler()
1958 sctp_select_initial_TSN(&inp->sctp_ep); in sctp_timeout_handler()
1980 stcb->asoc.timoshutdownack++; in sctp_timeout_handler()
2062 * duplicate unlock or unlock of a free mtx :-0 in sctp_timeout_handler()
2101 sctp_fix_ecn_echo(&stcb->asoc); in sctp_timeout_handler()
2118 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_timeout_handler()
2128 /*-
2134 * |-----------------------------|----|----|----|
2163 KASSERT(stcb == NULL || stcb->sctp_ep == inp, in sctp_timer_start()
2164 ("sctp_timer_start of type %d: inp = %p, stcb->sctp_ep %p", in sctp_timer_start()
2165 t_type, stcb, stcb->sctp_ep)); in sctp_timer_start()
2179 if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) && in sctp_timer_start()
2187 if (net != NULL && (net->dest_state & SCTP_ADDR_BEING_DELETED)) { in sctp_timer_start()
2205 tmr = &net->rxt_timer; in sctp_timer_start()
2206 if (net->RTO == 0) { in sctp_timer_start()
2207 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2209 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2225 tmr = &net->rxt_timer; in sctp_timer_start()
2226 if (net->RTO == 0) { in sctp_timer_start()
2227 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2229 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2234 * Here we use the Delayed-Ack timer value from the inp, in sctp_timer_start()
2235 * usually about 200ms. in sctp_timer_start()
2245 tmr = &stcb->asoc.dack_timer; in sctp_timer_start()
2246 to_ticks = sctp_msecs_to_ticks(stcb->asoc.delayed_ack); in sctp_timer_start()
2258 tmr = &net->rxt_timer; in sctp_timer_start()
2259 if (net->RTO == 0) { in sctp_timer_start()
2260 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2262 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2279 if ((net->dest_state & SCTP_ADDR_NOHB) && in sctp_timer_start()
2280 ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0)) { in sctp_timer_start()
2286 tmr = &net->hb_timer; in sctp_timer_start()
2287 if (net->RTO == 0) { in sctp_timer_start()
2288 to_ticks = stcb->asoc.initial_rto; in sctp_timer_start()
2290 to_ticks = net->RTO; in sctp_timer_start()
2292 if (!((net->dest_state & SCTP_ADDR_UNCONFIRMED) && in sctp_timer_start()
2293 (net->dest_state & SCTP_ADDR_REACHABLE)) && in sctp_timer_start()
2294 ((net->dest_state & SCTP_ADDR_PF) == 0)) { in sctp_timer_start()
2296 rndval = sctp_select_initial_TSN(&inp->sctp_ep); in sctp_timer_start()
2299 if (jitter < (UINT32_MAX - to_ticks)) { in sctp_timer_start()
2305 if (net->heart_beat_delay < (UINT32_MAX - to_ticks)) { in sctp_timer_start()
2306 to_ticks += net->heart_beat_delay; in sctp_timer_start()
2312 * Now we must convert the to_ticks that are now in ms to in sctp_timer_start()
2331 tmr = &net->rxt_timer; in sctp_timer_start()
2332 if (net->RTO == 0) { in sctp_timer_start()
2333 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2335 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2351 tmr = &inp->sctp_ep.signature_change; in sctp_timer_start()
2352 to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_SIGNATURE]; in sctp_timer_start()
2367 if (net->dest_state & SCTP_ADDR_NO_PMTUD) { in sctp_timer_start()
2373 tmr = &net->pmtu_timer; in sctp_timer_start()
2374 to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_PMTU]; in sctp_timer_start()
2386 tmr = &net->rxt_timer; in sctp_timer_start()
2387 if (net->RTO == 0) { in sctp_timer_start()
2388 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2390 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2406 tmr = &stcb->asoc.asconf_timer; in sctp_timer_start()
2407 if (net->RTO == 0) { in sctp_timer_start()
2408 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2410 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2426 tmr = &stcb->asoc.shut_guard_timer; in sctp_timer_start()
2427 if (inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] == 0) { in sctp_timer_start()
2428 if (stcb->asoc.maxrto < UINT32_MAX / 5) { in sctp_timer_start()
2429 to_ticks = sctp_msecs_to_ticks(5 * stcb->asoc.maxrto); in sctp_timer_start()
2434 to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN]; in sctp_timer_start()
2446 tmr = &stcb->asoc.autoclose_timer; in sctp_timer_start()
2447 to_ticks = stcb->asoc.sctp_autoclose_ticks; in sctp_timer_start()
2462 tmr = &stcb->asoc.strreset_timer; in sctp_timer_start()
2463 if (net->RTO == 0) { in sctp_timer_start()
2464 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2466 to_ticks = sctp_msecs_to_ticks(net->RTO); in sctp_timer_start()
2471 * The inp is setup to die. We re-use the signature_change in sctp_timer_start()
2483 tmr = &inp->sctp_ep.signature_change; in sctp_timer_start()
2495 tmr = &stcb->asoc.strreset_timer; in sctp_timer_start()
2507 /* Only 1 tick away :-) */ in sctp_timer_start()
2520 tmr = &stcb->asoc.delete_prim_timer; in sctp_timer_start()
2521 to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto); in sctp_timer_start()
2532 if (SCTP_OS_TIMER_PENDING(&tmr->timer)) { in sctp_timer_start()
2544 stcb->asoc.num_send_timers_up++; in sctp_timer_start()
2546 tmr->stopped_from = 0; in sctp_timer_start()
2547 tmr->type = t_type; in sctp_timer_start()
2548 tmr->ep = (void *)inp; in sctp_timer_start()
2549 tmr->tcb = (void *)stcb; in sctp_timer_start()
2551 tmr->net = NULL; in sctp_timer_start()
2553 tmr->net = (void *)net; in sctp_timer_start()
2555 tmr->self = (void *)tmr; in sctp_timer_start()
2556 tmr->vnet = (void *)curvnet; in sctp_timer_start()
2557 tmr->ticks = sctp_get_tick_count(); in sctp_timer_start()
2558 if (SCTP_OS_TIMER_START(&tmr->timer, to_ticks, sctp_timeout_handler, tmr) == 0) { in sctp_timer_start()
2566 if (tmr->ep != NULL) { in sctp_timer_start()
2569 if (tmr->tcb != NULL) { in sctp_timer_start()
2570 atomic_add_int(&stcb->asoc.refcnt, 1); in sctp_timer_start()
2572 if (tmr->net != NULL) { in sctp_timer_start()
2573 atomic_add_int(&net->ref_count, 1); in sctp_timer_start()
2587 /*-
2593 * |-----------------------------|----|----|----|
2620 KASSERT(stcb == NULL || stcb->sctp_ep == inp, in sctp_timer_stop()
2621 ("sctp_timer_stop of type %d: inp = %p, stcb->sctp_ep %p", in sctp_timer_stop()
2622 t_type, stcb, stcb->sctp_ep)); in sctp_timer_stop()
2641 tmr = &net->rxt_timer; in sctp_timer_stop()
2652 tmr = &net->rxt_timer; in sctp_timer_stop()
2663 tmr = &stcb->asoc.dack_timer; in sctp_timer_stop()
2674 tmr = &net->rxt_timer; in sctp_timer_stop()
2685 tmr = &net->hb_timer; in sctp_timer_stop()
2696 tmr = &net->rxt_timer; in sctp_timer_stop()
2707 tmr = &inp->sctp_ep.signature_change; in sctp_timer_stop()
2718 tmr = &net->pmtu_timer; in sctp_timer_stop()
2729 tmr = &net->rxt_timer; in sctp_timer_stop()
2740 tmr = &stcb->asoc.asconf_timer; in sctp_timer_stop()
2751 tmr = &stcb->asoc.shut_guard_timer; in sctp_timer_stop()
2762 tmr = &stcb->asoc.autoclose_timer; in sctp_timer_stop()
2773 tmr = &stcb->asoc.strreset_timer; in sctp_timer_stop()
2777 * The inp is setup to die. We re-use the signature_change in sctp_timer_stop()
2789 tmr = &inp->sctp_ep.signature_change; in sctp_timer_stop()
2800 tmr = &stcb->asoc.strreset_timer; in sctp_timer_stop()
2822 tmr = &stcb->asoc.delete_prim_timer; in sctp_timer_stop()
2832 if ((tmr->type != SCTP_TIMER_TYPE_NONE) && in sctp_timer_stop()
2833 (tmr->type != t_type)) { in sctp_timer_stop()
2846 stcb->asoc.num_send_timers_up--; in sctp_timer_stop()
2847 if (stcb->asoc.num_send_timers_up < 0) { in sctp_timer_stop()
2848 stcb->asoc.num_send_timers_up = 0; in sctp_timer_stop()
2851 tmr->self = NULL; in sctp_timer_stop()
2852 tmr->stopped_from = from; in sctp_timer_stop()
2853 if (SCTP_OS_TIMER_STOP(&tmr->timer) == 1) { in sctp_timer_stop()
2854 KASSERT(tmr->ep == inp, in sctp_timer_stop()
2855 ("sctp_timer_stop of type %d: inp = %p, tmr->inp = %p", in sctp_timer_stop()
2856 t_type, inp, tmr->ep)); in sctp_timer_stop()
2857 KASSERT(tmr->tcb == stcb, in sctp_timer_stop()
2858 ("sctp_timer_stop of type %d: stcb = %p, tmr->stcb = %p", in sctp_timer_stop()
2859 t_type, stcb, tmr->tcb)); in sctp_timer_stop()
2860 KASSERT(((t_type == SCTP_TIMER_TYPE_ASCONF) && (tmr->net != NULL)) || in sctp_timer_stop()
2861 ((t_type != SCTP_TIMER_TYPE_ASCONF) && (tmr->net == net)), in sctp_timer_stop()
2862 ("sctp_timer_stop of type %d: net = %p, tmr->net = %p", in sctp_timer_stop()
2863 t_type, net, tmr->net)); in sctp_timer_stop()
2871 if (tmr->ep != NULL) { in sctp_timer_stop()
2872 tmr->ep = NULL; in sctp_timer_stop()
2875 if (tmr->tcb != NULL) { in sctp_timer_stop()
2876 tmr->tcb = NULL; in sctp_timer_stop()
2877 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_timer_stop()
2879 if (tmr->net != NULL) { in sctp_timer_stop()
2886 tmr_net = tmr->net; in sctp_timer_stop()
2887 tmr->net = NULL; in sctp_timer_stop()
2927 int32_t rtt; /* RTT in ms */ in sctp_calculate_rto()
2935 if (stcb->asoc.use_precise_time) { in sctp_calculate_rto()
2940 if ((old->tv_sec > now.tv_sec) || in sctp_calculate_rto()
2941 ((old->tv_sec == now.tv_sec) && (old->tv_usec > now.tv_usec))) { in sctp_calculate_rto()
2952 net->rtt = rtt_us; in sctp_calculate_rto()
2953 /* compute rtt in ms */ in sctp_calculate_rto()
2954 rtt = (int32_t)(net->rtt / 1000); in sctp_calculate_rto()
2955 if ((asoc->cc_functions.sctp_rtt_calculated) && (rtt_from_sack == SCTP_RTT_FROM_DATA)) { in sctp_calculate_rto()
2960 (*asoc->cc_functions.sctp_rtt_calculated) (stcb, net, &now); in sctp_calculate_rto()
2964 * RTT being determined from data not non-data (HB/INIT->INITACK). in sctp_calculate_rto()
2967 (net->lan_type == SCTP_LAN_UNKNOWN)) { in sctp_calculate_rto()
2968 if (net->rtt > SCTP_LOCAL_LAN_RTT) { in sctp_calculate_rto()
2969 net->lan_type = SCTP_LAN_INTERNET; in sctp_calculate_rto()
2971 net->lan_type = SCTP_LAN_LOCAL; in sctp_calculate_rto()
2978 /*- in sctp_calculate_rto()
2983 * (net->lastsa >> SCTP_RTT_SHIFT) is the srtt in sctp_calculate_rto()
2984 * (net->lastsv >> SCTP_RTT_VAR_SHIFT) is the rttvar in sctp_calculate_rto()
2986 if (net->RTO_measured) { in sctp_calculate_rto()
2987 rtt -= (net->lastsa >> SCTP_RTT_SHIFT); in sctp_calculate_rto()
2988 net->lastsa += rtt; in sctp_calculate_rto()
2990 rtt = -rtt; in sctp_calculate_rto()
2992 rtt -= (net->lastsv >> SCTP_RTT_VAR_SHIFT); in sctp_calculate_rto()
2993 net->lastsv += rtt; in sctp_calculate_rto()
2999 net->RTO_measured = 1; in sctp_calculate_rto()
3001 net->lastsa = rtt << SCTP_RTT_SHIFT; in sctp_calculate_rto()
3002 net->lastsv = (rtt / 2) << SCTP_RTT_VAR_SHIFT; in sctp_calculate_rto()
3007 if (net->lastsv == 0) { in sctp_calculate_rto()
3008 net->lastsv = SCTP_CLOCK_GRANULARITY; in sctp_calculate_rto()
3010 new_rto = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv; in sctp_calculate_rto()
3012 (stcb->asoc.sat_network_lockout == 0)) { in sctp_calculate_rto()
3013 stcb->asoc.sat_network = 1; in sctp_calculate_rto()
3014 } else if ((!first_measure) && stcb->asoc.sat_network) { in sctp_calculate_rto()
3015 stcb->asoc.sat_network = 0; in sctp_calculate_rto()
3016 stcb->asoc.sat_network_lockout = 1; in sctp_calculate_rto()
3019 if (new_rto < stcb->asoc.minrto) { in sctp_calculate_rto()
3020 new_rto = stcb->asoc.minrto; in sctp_calculate_rto()
3022 if (new_rto > stcb->asoc.maxrto) { in sctp_calculate_rto()
3023 new_rto = stcb->asoc.maxrto; in sctp_calculate_rto()
3025 net->RTO = new_rto; in sctp_calculate_rto()
3049 off -= SCTP_BUF_LEN(m); in sctp_m_getptr()
3056 if ((SCTP_BUF_LEN(m) - off) >= len) { in sctp_m_getptr()
3061 count = min(SCTP_BUF_LEN(m) - off, len); in sctp_m_getptr()
3063 len -= count; in sctp_m_getptr()
3154 inp = stcb->sctp_ep; in sctp_notify_assoc_change()
3160 abort_len = ntohs(abort->ch.chunk_length); in sctp_notify_assoc_change()
3188 sac->sac_type = SCTP_ASSOC_CHANGE; in sctp_notify_assoc_change()
3189 sac->sac_flags = 0; in sctp_notify_assoc_change()
3190 sac->sac_length = sizeof(struct sctp_assoc_change); in sctp_notify_assoc_change()
3191 sac->sac_state = state; in sctp_notify_assoc_change()
3192 sac->sac_error = error; in sctp_notify_assoc_change()
3194 sac->sac_outbound_streams = 0; in sctp_notify_assoc_change()
3195 sac->sac_inbound_streams = 0; in sctp_notify_assoc_change()
3197 sac->sac_outbound_streams = stcb->asoc.streamoutcnt; in sctp_notify_assoc_change()
3198 sac->sac_inbound_streams = stcb->asoc.streamincnt; in sctp_notify_assoc_change()
3200 sac->sac_assoc_id = sctp_get_associd(stcb); in sctp_notify_assoc_change()
3204 if (stcb->asoc.prsctp_supported == 1) { in sctp_notify_assoc_change()
3205 sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_PR; in sctp_notify_assoc_change()
3207 if (stcb->asoc.auth_supported == 1) { in sctp_notify_assoc_change()
3208 sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_AUTH; in sctp_notify_assoc_change()
3210 if (stcb->asoc.asconf_supported == 1) { in sctp_notify_assoc_change()
3211 sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_ASCONF; in sctp_notify_assoc_change()
3213 if (stcb->asoc.idata_supported == 1) { in sctp_notify_assoc_change()
3214 sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_INTERLEAVING; in sctp_notify_assoc_change()
3216 sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_MULTIBUF; in sctp_notify_assoc_change()
3217 if (stcb->asoc.reconfig_supported == 1) { in sctp_notify_assoc_change()
3218 sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_RE_CONFIG; in sctp_notify_assoc_change()
3220 sac->sac_length += i; in sctp_notify_assoc_change()
3222 memcpy(sac->sac_info, abort, abort_len); in sctp_notify_assoc_change()
3223 sac->sac_length += abort_len; in sctp_notify_assoc_change()
3226 SCTP_BUF_LEN(m_notify) = sac->sac_length; in sctp_notify_assoc_change()
3227 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_assoc_change()
3228 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_assoc_change()
3231 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_assoc_change()
3232 control->spec_flags = M_NOTIFICATION; in sctp_notify_assoc_change()
3234 control->tail_mbuf = m_notify; in sctp_notify_assoc_change()
3236 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_assoc_change()
3243 * For 1-to-1 style sockets, we send up and error when an ABORT in sctp_notify_assoc_change()
3247 if (((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || in sctp_notify_assoc_change()
3248 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && in sctp_notify_assoc_change()
3250 SOCK_LOCK(stcb->sctp_socket); in sctp_notify_assoc_change()
3254 stcb->sctp_socket->so_error = ECONNREFUSED; in sctp_notify_assoc_change()
3257 stcb->sctp_socket->so_error = ECONNRESET; in sctp_notify_assoc_change()
3262 stcb->sctp_socket->so_error = ETIMEDOUT; in sctp_notify_assoc_change()
3265 stcb->sctp_socket->so_error = ECONNABORTED; in sctp_notify_assoc_change()
3268 SOCK_UNLOCK(stcb->sctp_socket); in sctp_notify_assoc_change()
3271 if (((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || in sctp_notify_assoc_change()
3272 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && in sctp_notify_assoc_change()
3274 socantrcvmore(stcb->sctp_socket); in sctp_notify_assoc_change()
3276 sorwakeup(stcb->sctp_socket); in sctp_notify_assoc_change()
3277 sowwakeup(stcb->sctp_socket); in sctp_notify_assoc_change()
3290 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_peer_addr_change()
3292 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVPADDREVNT)) { in sctp_notify_peer_addr_change()
3303 spc->spc_type = SCTP_PEER_ADDR_CHANGE; in sctp_notify_peer_addr_change()
3304 spc->spc_flags = 0; in sctp_notify_peer_addr_change()
3305 spc->spc_length = sizeof(struct sctp_paddr_change); in sctp_notify_peer_addr_change()
3306 switch (sa->sa_family) { in sctp_notify_peer_addr_change()
3310 if (sctp_is_feature_on(stcb->sctp_ep, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) { in sctp_notify_peer_addr_change()
3312 (struct sockaddr_in6 *)&spc->spc_aaddr); in sctp_notify_peer_addr_change()
3314 memcpy(&spc->spc_aaddr, sa, sizeof(struct sockaddr_in)); in sctp_notify_peer_addr_change()
3317 memcpy(&spc->spc_aaddr, sa, sizeof(struct sockaddr_in)); in sctp_notify_peer_addr_change()
3326 memcpy(&spc->spc_aaddr, sa, sizeof(struct sockaddr_in6)); in sctp_notify_peer_addr_change()
3328 sin6 = (struct sockaddr_in6 *)&spc->spc_aaddr; in sctp_notify_peer_addr_change()
3329 if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr)) { in sctp_notify_peer_addr_change()
3330 if (sin6->sin6_scope_id == 0) { in sctp_notify_peer_addr_change()
3335 in6_clearscope(&sin6->sin6_addr); in sctp_notify_peer_addr_change()
3345 spc->spc_state = state; in sctp_notify_peer_addr_change()
3346 spc->spc_error = error; in sctp_notify_peer_addr_change()
3347 spc->spc_assoc_id = sctp_get_associd(stcb); in sctp_notify_peer_addr_change()
3353 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_peer_addr_change()
3354 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_peer_addr_change()
3361 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_peer_addr_change()
3362 control->spec_flags = M_NOTIFICATION; in sctp_notify_peer_addr_change()
3364 control->tail_mbuf = m_notify; in sctp_notify_peer_addr_change()
3365 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_peer_addr_change()
3366 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_peer_addr_change()
3383 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_send_failed()
3385 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) && in sctp_notify_send_failed()
3386 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { in sctp_notify_send_failed()
3391 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { in sctp_notify_send_failed()
3401 if (stcb->asoc.idata_supported) { in sctp_notify_send_failed()
3407 if (chk->send_size >= chkhdr_len) { in sctp_notify_send_failed()
3408 payload_len = chk->send_size - chkhdr_len; in sctp_notify_send_failed()
3413 if (chk->data != NULL) { in sctp_notify_send_failed()
3414 chkhdr = mtod(chk->data, struct sctp_chunkhdr *); in sctp_notify_send_failed()
3416 chk_len = ntohs(chkhdr->chunk_length); in sctp_notify_send_failed()
3418 (chk->send_size >= chk_len) && in sctp_notify_send_failed()
3419 (chk->send_size - chk_len < 4)) { in sctp_notify_send_failed()
3420 padding_len = chk->send_size - chk_len; in sctp_notify_send_failed()
3421 payload_len = chk->send_size - chkhdr_len - padding_len; in sctp_notify_send_failed()
3425 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { in sctp_notify_send_failed()
3428 ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT; in sctp_notify_send_failed()
3430 ssfe->ssfe_flags = SCTP_DATA_SENT; in sctp_notify_send_failed()
3432 ssfe->ssfe_flags = SCTP_DATA_UNSENT; in sctp_notify_send_failed()
3434 ssfe->ssfe_length = (uint32_t)(notifhdr_len + payload_len); in sctp_notify_send_failed()
3435 ssfe->ssfe_error = error; in sctp_notify_send_failed()
3437 ssfe->ssfe_info.snd_sid = chk->rec.data.sid; in sctp_notify_send_failed()
3438 ssfe->ssfe_info.snd_flags = chk->rec.data.rcv_flags; in sctp_notify_send_failed()
3439 ssfe->ssfe_info.snd_ppid = chk->rec.data.ppid; in sctp_notify_send_failed()
3440 ssfe->ssfe_info.snd_context = chk->rec.data.context; in sctp_notify_send_failed()
3441 ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed()
3442 ssfe->ssfe_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed()
3446 ssf->ssf_type = SCTP_SEND_FAILED; in sctp_notify_send_failed()
3448 ssf->ssf_flags = SCTP_DATA_SENT; in sctp_notify_send_failed()
3450 ssf->ssf_flags = SCTP_DATA_UNSENT; in sctp_notify_send_failed()
3452 ssf->ssf_length = (uint32_t)(notifhdr_len + payload_len); in sctp_notify_send_failed()
3453 ssf->ssf_error = error; in sctp_notify_send_failed()
3455 ssf->ssf_info.sinfo_stream = chk->rec.data.sid; in sctp_notify_send_failed()
3456 ssf->ssf_info.sinfo_ssn = (uint16_t)chk->rec.data.mid; in sctp_notify_send_failed()
3457 ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags; in sctp_notify_send_failed()
3458 ssf->ssf_info.sinfo_ppid = chk->rec.data.ppid; in sctp_notify_send_failed()
3459 ssf->ssf_info.sinfo_context = chk->rec.data.context; in sctp_notify_send_failed()
3460 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed()
3461 ssf->ssf_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed()
3463 if (chk->data != NULL) { in sctp_notify_send_failed()
3465 if (chk->send_size == chkhdr_len + payload_len + padding_len) { in sctp_notify_send_failed()
3466 m_adj(chk->data, chkhdr_len); in sctp_notify_send_failed()
3467 m_adj(chk->data, -padding_len); in sctp_notify_send_failed()
3468 sctp_mbuf_crush(chk->data); in sctp_notify_send_failed()
3469 chk->send_size -= (chkhdr_len + padding_len); in sctp_notify_send_failed()
3472 SCTP_BUF_NEXT(m_notify) = chk->data; in sctp_notify_send_failed()
3474 chk->data = NULL; in sctp_notify_send_failed()
3478 * non-reader in sctp_notify_send_failed()
3480 if (sctp_sbspace_failedmsgs(&stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { in sctp_notify_send_failed()
3485 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_send_failed()
3486 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_send_failed()
3493 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_send_failed()
3494 control->spec_flags = M_NOTIFICATION; in sctp_notify_send_failed()
3496 control->tail_mbuf = m_notify; in sctp_notify_send_failed()
3497 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_send_failed()
3498 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_send_failed()
3514 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_send_failed2()
3516 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) && in sctp_notify_send_failed2()
3517 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { in sctp_notify_send_failed2()
3522 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { in sctp_notify_send_failed2()
3533 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) { in sctp_notify_send_failed2()
3536 ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT; in sctp_notify_send_failed2()
3537 ssfe->ssfe_flags = SCTP_DATA_UNSENT; in sctp_notify_send_failed2()
3538 ssfe->ssfe_length = (uint32_t)(notifhdr_len + sp->length); in sctp_notify_send_failed2()
3539 ssfe->ssfe_error = error; in sctp_notify_send_failed2()
3541 ssfe->ssfe_info.snd_sid = sp->sid; in sctp_notify_send_failed2()
3542 if (sp->some_taken) { in sctp_notify_send_failed2()
3543 ssfe->ssfe_info.snd_flags = SCTP_DATA_LAST_FRAG; in sctp_notify_send_failed2()
3545 ssfe->ssfe_info.snd_flags = SCTP_DATA_NOT_FRAG; in sctp_notify_send_failed2()
3547 ssfe->ssfe_info.snd_ppid = sp->ppid; in sctp_notify_send_failed2()
3548 ssfe->ssfe_info.snd_context = sp->context; in sctp_notify_send_failed2()
3549 ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed2()
3550 ssfe->ssfe_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed2()
3554 ssf->ssf_type = SCTP_SEND_FAILED; in sctp_notify_send_failed2()
3555 ssf->ssf_flags = SCTP_DATA_UNSENT; in sctp_notify_send_failed2()
3556 ssf->ssf_length = (uint32_t)(notifhdr_len + sp->length); in sctp_notify_send_failed2()
3557 ssf->ssf_error = error; in sctp_notify_send_failed2()
3559 ssf->ssf_info.sinfo_stream = sp->sid; in sctp_notify_send_failed2()
3560 ssf->ssf_info.sinfo_ssn = 0; in sctp_notify_send_failed2()
3561 if (sp->some_taken) { in sctp_notify_send_failed2()
3562 ssf->ssf_info.sinfo_flags = SCTP_DATA_LAST_FRAG; in sctp_notify_send_failed2()
3564 ssf->ssf_info.sinfo_flags = SCTP_DATA_NOT_FRAG; in sctp_notify_send_failed2()
3566 ssf->ssf_info.sinfo_ppid = sp->ppid; in sctp_notify_send_failed2()
3567 ssf->ssf_info.sinfo_context = sp->context; in sctp_notify_send_failed2()
3568 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed2()
3569 ssf->ssf_assoc_id = sctp_get_associd(stcb); in sctp_notify_send_failed2()
3571 SCTP_BUF_NEXT(m_notify) = sp->data; in sctp_notify_send_failed2()
3574 sp->data = NULL; in sctp_notify_send_failed2()
3578 * non-reader in sctp_notify_send_failed2()
3580 if (sctp_sbspace_failedmsgs(&stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { in sctp_notify_send_failed2()
3585 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_send_failed2()
3586 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_send_failed2()
3593 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_send_failed2()
3594 control->spec_flags = M_NOTIFICATION; in sctp_notify_send_failed2()
3596 control->tail_mbuf = m_notify; in sctp_notify_send_failed2()
3597 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_send_failed2()
3598 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_send_failed2()
3611 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_adaptation_layer()
3613 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_ADAPTATIONEVNT)) { in sctp_notify_adaptation_layer()
3625 sai->sai_type = SCTP_ADAPTATION_INDICATION; in sctp_notify_adaptation_layer()
3626 sai->sai_flags = 0; in sctp_notify_adaptation_layer()
3627 sai->sai_length = sizeof(struct sctp_adaptation_event); in sctp_notify_adaptation_layer()
3628 sai->sai_adaptation_ind = stcb->asoc.peers_adaptation; in sctp_notify_adaptation_layer()
3629 sai->sai_assoc_id = sctp_get_associd(stcb); in sctp_notify_adaptation_layer()
3635 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_adaptation_layer()
3636 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_adaptation_layer()
3643 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_adaptation_layer()
3644 control->spec_flags = M_NOTIFICATION; in sctp_notify_adaptation_layer()
3646 control->tail_mbuf = m_notify; in sctp_notify_adaptation_layer()
3647 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_adaptation_layer()
3648 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_adaptation_layer()
3665 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_partial_delivery_indication()
3667 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_PDAPIEVNT)) { in sctp_notify_partial_delivery_indication()
3679 pdapi->pdapi_type = SCTP_PARTIAL_DELIVERY_EVENT; in sctp_notify_partial_delivery_indication()
3680 pdapi->pdapi_flags = 0; in sctp_notify_partial_delivery_indication()
3681 pdapi->pdapi_length = sizeof(struct sctp_pdapi_event); in sctp_notify_partial_delivery_indication()
3682 pdapi->pdapi_indication = error; in sctp_notify_partial_delivery_indication()
3683 pdapi->pdapi_stream = aborted_control->sinfo_stream; in sctp_notify_partial_delivery_indication()
3684 pdapi->pdapi_seq = (uint16_t)aborted_control->mid; in sctp_notify_partial_delivery_indication()
3685 pdapi->pdapi_assoc_id = sctp_get_associd(stcb); in sctp_notify_partial_delivery_indication()
3689 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_partial_delivery_indication()
3690 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_partial_delivery_indication()
3697 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_partial_delivery_indication()
3698 control->spec_flags = M_NOTIFICATION; in sctp_notify_partial_delivery_indication()
3700 control->tail_mbuf = m_notify; in sctp_notify_partial_delivery_indication()
3701 sb = &stcb->sctp_socket->so_rcv; in sctp_notify_partial_delivery_indication()
3703 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m_notify)); in sctp_notify_partial_delivery_indication()
3707 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0); in sctp_notify_partial_delivery_indication()
3709 control->end_added = 1; in sctp_notify_partial_delivery_indication()
3710 TAILQ_INSERT_AFTER(&stcb->sctp_ep->read_queue, aborted_control, control, next); in sctp_notify_partial_delivery_indication()
3711 if (stcb->sctp_ep && stcb->sctp_socket) { in sctp_notify_partial_delivery_indication()
3713 sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); in sctp_notify_partial_delivery_indication()
3726 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_shutdown_event()
3732 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || in sctp_notify_shutdown_event()
3733 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { in sctp_notify_shutdown_event()
3735 socantsendmore(stcb->sctp_socket); in sctp_notify_shutdown_event()
3738 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT)) { in sctp_notify_shutdown_event()
3749 sse->sse_type = SCTP_SHUTDOWN_EVENT; in sctp_notify_shutdown_event()
3750 sse->sse_flags = 0; in sctp_notify_shutdown_event()
3751 sse->sse_length = sizeof(struct sctp_shutdown_event); in sctp_notify_shutdown_event()
3752 sse->sse_assoc_id = sctp_get_associd(stcb); in sctp_notify_shutdown_event()
3758 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_shutdown_event()
3759 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_shutdown_event()
3766 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_shutdown_event()
3767 control->spec_flags = M_NOTIFICATION; in sctp_notify_shutdown_event()
3769 control->tail_mbuf = m_notify; in sctp_notify_shutdown_event()
3770 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_shutdown_event()
3771 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_shutdown_event()
3784 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_sender_dry_event()
3786 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_DRYEVNT)) { in sctp_notify_sender_dry_event()
3799 event->sender_dry_type = SCTP_SENDER_DRY_EVENT; in sctp_notify_sender_dry_event()
3800 event->sender_dry_flags = 0; in sctp_notify_sender_dry_event()
3801 event->sender_dry_length = sizeof(struct sctp_sender_dry_event); in sctp_notify_sender_dry_event()
3802 event->sender_dry_assoc_id = sctp_get_associd(stcb); in sctp_notify_sender_dry_event()
3808 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_sender_dry_event()
3809 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_sender_dry_event()
3816 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_sender_dry_event()
3817 control->spec_flags = M_NOTIFICATION; in sctp_notify_sender_dry_event()
3819 control->tail_mbuf = m_notify; in sctp_notify_sender_dry_event()
3820 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_sender_dry_event()
3821 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_sender_dry_event()
3834 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_stream_reset_add()
3836 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_CHANGEEVNT)) { in sctp_notify_stream_reset_add()
3841 if ((stcb->asoc.peer_req_out) && flag) { in sctp_notify_stream_reset_add()
3843 stcb->asoc.peer_req_out = 0; in sctp_notify_stream_reset_add()
3846 stcb->asoc.peer_req_out = 0; in sctp_notify_stream_reset_add()
3854 stradd->strchange_type = SCTP_STREAM_CHANGE_EVENT; in sctp_notify_stream_reset_add()
3855 stradd->strchange_flags = flag; in sctp_notify_stream_reset_add()
3856 stradd->strchange_length = sizeof(struct sctp_stream_change_event); in sctp_notify_stream_reset_add()
3857 stradd->strchange_assoc_id = sctp_get_associd(stcb); in sctp_notify_stream_reset_add()
3858 stradd->strchange_instrms = stcb->asoc.streamincnt; in sctp_notify_stream_reset_add()
3859 stradd->strchange_outstrms = stcb->asoc.streamoutcnt; in sctp_notify_stream_reset_add()
3862 if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { in sctp_notify_stream_reset_add()
3868 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_stream_reset_add()
3869 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_stream_reset_add()
3876 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_stream_reset_add()
3877 control->spec_flags = M_NOTIFICATION; in sctp_notify_stream_reset_add()
3879 control->tail_mbuf = m_notify; in sctp_notify_stream_reset_add()
3880 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_stream_reset_add()
3881 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_stream_reset_add()
3894 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_stream_reset_tsn()
3896 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_ASSOC_RESETEVNT)) { in sctp_notify_stream_reset_tsn()
3908 strasoc->assocreset_type = SCTP_ASSOC_RESET_EVENT; in sctp_notify_stream_reset_tsn()
3909 strasoc->assocreset_flags = flag; in sctp_notify_stream_reset_tsn()
3910 strasoc->assocreset_length = sizeof(struct sctp_assoc_reset_event); in sctp_notify_stream_reset_tsn()
3911 strasoc->assocreset_assoc_id = sctp_get_associd(stcb); in sctp_notify_stream_reset_tsn()
3912 strasoc->assocreset_local_tsn = stcb->asoc.sending_seq; in sctp_notify_stream_reset_tsn()
3913 strasoc->assocreset_remote_tsn = stcb->asoc.mapping_array_base_tsn + 1; in sctp_notify_stream_reset_tsn()
3916 if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { in sctp_notify_stream_reset_tsn()
3922 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_stream_reset_tsn()
3923 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_stream_reset_tsn()
3930 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_stream_reset_tsn()
3931 control->spec_flags = M_NOTIFICATION; in sctp_notify_stream_reset_tsn()
3933 control->tail_mbuf = m_notify; in sctp_notify_stream_reset_tsn()
3934 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_stream_reset_tsn()
3935 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_stream_reset_tsn()
3950 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_stream_reset()
3952 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { in sctp_notify_stream_reset()
3970 strreset->strreset_type = SCTP_STREAM_RESET_EVENT; in sctp_notify_stream_reset()
3971 strreset->strreset_flags = flag; in sctp_notify_stream_reset()
3972 strreset->strreset_length = len; in sctp_notify_stream_reset()
3973 strreset->strreset_assoc_id = sctp_get_associd(stcb); in sctp_notify_stream_reset()
3978 strreset->strreset_stream_list[i] = ntohs(list[i]); in sctp_notify_stream_reset()
3983 if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { in sctp_notify_stream_reset()
3989 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_stream_reset()
3990 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_stream_reset()
3997 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_stream_reset()
3998 control->spec_flags = M_NOTIFICATION; in sctp_notify_stream_reset()
4000 control->tail_mbuf = m_notify; in sctp_notify_stream_reset()
4001 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_stream_reset()
4002 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_stream_reset()
4018 SCTP_INP_READ_LOCK_ASSERT(stcb->sctp_ep); in sctp_notify_remote_error()
4020 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVPEERERR)) { in sctp_notify_remote_error()
4025 chunk_len = ntohs(chunk->ch.chunk_length); in sctp_notify_remote_error()
4049 sre->sre_type = SCTP_REMOTE_ERROR; in sctp_notify_remote_error()
4050 sre->sre_flags = 0; in sctp_notify_remote_error()
4051 sre->sre_length = sizeof(struct sctp_remote_error); in sctp_notify_remote_error()
4052 sre->sre_error = error; in sctp_notify_remote_error()
4053 sre->sre_assoc_id = sctp_get_associd(stcb); in sctp_notify_remote_error()
4055 memcpy(sre->sre_data, chunk, chunk_len); in sctp_notify_remote_error()
4056 sre->sre_length += chunk_len; in sctp_notify_remote_error()
4058 SCTP_BUF_LEN(m_notify) = sre->sre_length; in sctp_notify_remote_error()
4059 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination, in sctp_notify_remote_error()
4060 0, 0, stcb->asoc.context, 0, 0, 0, in sctp_notify_remote_error()
4063 control->length = SCTP_BUF_LEN(m_notify); in sctp_notify_remote_error()
4064 control->spec_flags = M_NOTIFICATION; in sctp_notify_remote_error()
4066 control->tail_mbuf = m_notify; in sctp_notify_remote_error()
4067 sctp_add_to_readq(stcb->sctp_ep, stcb, control, in sctp_notify_remote_error()
4068 &stcb->sctp_socket->so_rcv, 1, in sctp_notify_remote_error()
4085 inp = stcb->sctp_ep; in sctp_ulp_notify()
4086 if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) { in sctp_ulp_notify()
4103 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || in sctp_ulp_notify()
4104 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || in sctp_ulp_notify()
4105 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ)) { in sctp_ulp_notify()
4112 if (stcb->asoc.assoc_up_sent == 0) { in sctp_ulp_notify()
4114 stcb->asoc.assoc_up_sent = 1; in sctp_ulp_notify()
4116 if (stcb->asoc.adaptation_needed && (stcb->asoc.adaptation_sent == 0)) { in sctp_ulp_notify()
4119 if (stcb->asoc.auth_supported == 0) { in sctp_ulp_notify()
4129 &net->ro._l_addr.sa, error, so_locked); in sctp_ulp_notify()
4134 &net->ro._l_addr.sa, error, so_locked); in sctp_ulp_notify()
4139 &net->ro._l_addr.sa, error, so_locked); in sctp_ulp_notify()
4184 if (stcb->asoc.auth_supported == 0) { in sctp_ulp_notify()
4271 asoc = &stcb->asoc; in sctp_report_all_outbound()
4272 if (asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) { in sctp_report_all_outbound()
4276 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || in sctp_report_all_outbound()
4277 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || in sctp_report_all_outbound()
4278 (asoc->state & SCTP_STATE_CLOSED_SOCKET)) { in sctp_report_all_outbound()
4283 TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) { in sctp_report_all_outbound()
4284 TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); in sctp_report_all_outbound()
4285 asoc->sent_queue_cnt--; in sctp_report_all_outbound()
4286 if (chk->sent != SCTP_DATAGRAM_NR_ACKED) { in sctp_report_all_outbound()
4287 if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) { in sctp_report_all_outbound()
4288 asoc->strmout[chk->rec.data.sid].chunks_on_queues--; in sctp_report_all_outbound()
4291 panic("No chunks on the queues for sid %u.", chk->rec.data.sid); in sctp_report_all_outbound()
4295 if (chk->data != NULL) { in sctp_report_all_outbound()
4299 if (chk->data) { in sctp_report_all_outbound()
4300 sctp_m_freem(chk->data); in sctp_report_all_outbound()
4301 chk->data = NULL; in sctp_report_all_outbound()
4308 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) { in sctp_report_all_outbound()
4309 TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next); in sctp_report_all_outbound()
4310 asoc->send_queue_cnt--; in sctp_report_all_outbound()
4311 if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) { in sctp_report_all_outbound()
4312 asoc->strmout[chk->rec.data.sid].chunks_on_queues--; in sctp_report_all_outbound()
4315 panic("No chunks on the queues for sid %u.", chk->rec.data.sid); in sctp_report_all_outbound()
4318 if (chk->data != NULL) { in sctp_report_all_outbound()
4322 if (chk->data) { in sctp_report_all_outbound()
4323 sctp_m_freem(chk->data); in sctp_report_all_outbound()
4324 chk->data = NULL; in sctp_report_all_outbound()
4330 for (i = 0; i < asoc->streamoutcnt; i++) { in sctp_report_all_outbound()
4332 outs = &asoc->strmout[i]; in sctp_report_all_outbound()
4334 TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) { in sctp_report_all_outbound()
4335 atomic_subtract_int(&asoc->stream_queue_cnt, 1); in sctp_report_all_outbound()
4336 TAILQ_REMOVE(&outs->outqueue, sp, next); in sctp_report_all_outbound()
4337 stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp); in sctp_report_all_outbound()
4339 if (sp->data) { in sctp_report_all_outbound()
4342 if (sp->data) { in sctp_report_all_outbound()
4343 sctp_m_freem(sp->data); in sctp_report_all_outbound()
4344 sp->data = NULL; in sctp_report_all_outbound()
4345 sp->tail_mbuf = NULL; in sctp_report_all_outbound()
4346 sp->length = 0; in sctp_report_all_outbound()
4349 if (sp->net) { in sctp_report_all_outbound()
4350 sctp_free_remote_addr(sp->net); in sctp_report_all_outbound()
4351 sp->net = NULL; in sctp_report_all_outbound()
4370 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || in sctp_abort_notification()
4371 ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && in sctp_abort_notification()
4372 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) { in sctp_abort_notification()
4373 sctp_pcb_add_flags(stcb->sctp_ep, SCTP_PCB_FLAGS_WAS_ABORTED); in sctp_abort_notification()
4375 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || in sctp_abort_notification()
4376 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || in sctp_abort_notification()
4377 (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { in sctp_abort_notification()
4407 vtag = stcb->asoc.peer_vtag; in sctp_abort_association()
4408 vrf_id = stcb->asoc.vrf_id; in sctp_abort_association()
4412 cause_code = ntohs(cause->code); in sctp_abort_association()
4420 mflowtype, mflowid, inp->fibnum, in sctp_abort_association()
4442 SCTP_PRINTF("Last ep reason:%x\n", stcb->sctp_ep->last_abort_code); in sctp_print_out_track_log()
4443 SCTP_PRINTF("IN bound TSN log-aaa\n"); in sctp_print_out_track_log()
4444 if ((stcb->asoc.tsn_in_at == 0) && (stcb->asoc.tsn_in_wrapped == 0)) { in sctp_print_out_track_log()
4448 if (stcb->asoc.tsn_in_wrapped) { in sctp_print_out_track_log()
4449 for (i = stcb->asoc.tsn_in_at; i < SCTP_TSN_LOG_SIZE; i++) { in sctp_print_out_track_log()
4451 stcb->asoc.in_tsnlog[i].tsn, in sctp_print_out_track_log()
4452 stcb->asoc.in_tsnlog[i].strm, in sctp_print_out_track_log()
4453 stcb->asoc.in_tsnlog[i].seq, in sctp_print_out_track_log()
4454 stcb->asoc.in_tsnlog[i].flgs, in sctp_print_out_track_log()
4455 stcb->asoc.in_tsnlog[i].sz); in sctp_print_out_track_log()
4458 if (stcb->asoc.tsn_in_at) { in sctp_print_out_track_log()
4459 for (i = 0; i < stcb->asoc.tsn_in_at; i++) { in sctp_print_out_track_log()
4461 stcb->asoc.in_tsnlog[i].tsn, in sctp_print_out_track_log()
4462 stcb->asoc.in_tsnlog[i].strm, in sctp_print_out_track_log()
4463 stcb->asoc.in_tsnlog[i].seq, in sctp_print_out_track_log()
4464 stcb->asoc.in_tsnlog[i].flgs, in sctp_print_out_track_log()
4465 stcb->asoc.in_tsnlog[i].sz); in sctp_print_out_track_log()
4469 SCTP_PRINTF("OUT bound TSN log-aaa\n"); in sctp_print_out_track_log()
4470 if ((stcb->asoc.tsn_out_at == 0) && in sctp_print_out_track_log()
4471 (stcb->asoc.tsn_out_wrapped == 0)) { in sctp_print_out_track_log()
4474 if (stcb->asoc.tsn_out_wrapped) { in sctp_print_out_track_log()
4475 for (i = stcb->asoc.tsn_out_at; i < SCTP_TSN_LOG_SIZE; i++) { in sctp_print_out_track_log()
4477 stcb->asoc.out_tsnlog[i].tsn, in sctp_print_out_track_log()
4478 stcb->asoc.out_tsnlog[i].strm, in sctp_print_out_track_log()
4479 stcb->asoc.out_tsnlog[i].seq, in sctp_print_out_track_log()
4480 stcb->asoc.out_tsnlog[i].flgs, in sctp_print_out_track_log()
4481 stcb->asoc.out_tsnlog[i].sz); in sctp_print_out_track_log()
4484 if (stcb->asoc.tsn_out_at) { in sctp_print_out_track_log()
4485 for (i = 0; i < stcb->asoc.tsn_out_at; i++) { in sctp_print_out_track_log()
4487 stcb->asoc.out_tsnlog[i].tsn, in sctp_print_out_track_log()
4488 stcb->asoc.out_tsnlog[i].strm, in sctp_print_out_track_log()
4489 stcb->asoc.out_tsnlog[i].seq, in sctp_print_out_track_log()
4490 stcb->asoc.out_tsnlog[i].flgs, in sctp_print_out_track_log()
4491 stcb->asoc.out_tsnlog[i].sz); in sctp_print_out_track_log()
4507 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { in sctp_abort_an_association()
4508 if (LIST_EMPTY(&inp->sctp_asoc_list)) { in sctp_abort_an_association()
4518 cause_code = ntohs(cause->code); in sctp_abort_an_association()
4530 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { in sctp_abort_an_association()
4555 if (inp && (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { in sctp_handle_ootb()
4556 if (LIST_EMPTY(&inp->sctp_asoc_list)) { in sctp_handle_ootb()
4565 chk_length = ntohs(ch->chunk_length); in sctp_handle_ootb()
4570 switch (ch->chunk_type) { in sctp_handle_ootb()
4575 /* we don't respond to pkt-dropped */ in sctp_handle_ootb()
4623 chk_length = ntohs(ch->chunk_length); in sctp_is_there_an_abort_here()
4629 if (ch->chunk_type == SCTP_ABORT_ASSOCIATION) { in sctp_is_there_an_abort_here()
4633 if ((ch->chunk_type == SCTP_INITIATION) || in sctp_is_there_an_abort_here()
4634 (ch->chunk_type == SCTP_INITIATION_ACK)) { in sctp_is_there_an_abort_here()
4639 *vtag = ntohl(init_chk->init.initiate_tag); in sctp_is_there_an_abort_here()
4687 if (addr->sin6_family == AF_INET6) { in sctp_recover_scope()
4688 if (IN6_IS_SCOPE_LINKLOCAL(&addr->sin6_addr)) { in sctp_recover_scope()
4689 if (addr->sin6_scope_id == 0) { in sctp_recover_scope()
4697 in6_clearscope(&addr->sin6_addr); in sctp_recover_scope()
4718 if (sa1->sa_family != sa2->sa_family) in sctp_cmpaddr()
4721 switch (sa1->sa_family) { in sctp_cmpaddr()
4742 return (sin_1->sin_addr.s_addr == sin_2->sin_addr.s_addr); in sctp_cmpaddr()
4758 switch (sa->sa_family) { in sctp_print_address()
4766 ip6_sprintf(ip6buf, &sin6->sin6_addr), in sctp_print_address()
4767 ntohs(sin6->sin6_port), in sctp_print_address()
4768 sin6->sin6_scope_id); in sctp_print_address()
4779 p = (unsigned char *)&sin->sin_addr; in sctp_print_address()
4781 p[0], p[1], p[2], p[3], ntohs(sin->sin_port)); in sctp_print_address()
4807 old_so = old_inp->sctp_socket; in sctp_pull_off_control_to_new_inp()
4808 new_so = new_inp->sctp_socket; in sctp_pull_off_control_to_new_inp()
4825 TAILQ_FOREACH_SAFE(control, &old_inp->read_queue, next, nctl) { in sctp_pull_off_control_to_new_inp()
4827 if (control->stcb == stcb) { in sctp_pull_off_control_to_new_inp()
4829 TAILQ_REMOVE(&old_inp->read_queue, control, next); in sctp_pull_off_control_to_new_inp()
4831 m = control->data; in sctp_pull_off_control_to_new_inp()
4834 …sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(… in sctp_pull_off_control_to_new_inp()
4836 sctp_sbfree(control, stcb, &old_so->so_rcv, m); in sctp_pull_off_control_to_new_inp()
4838 sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0); in sctp_pull_off_control_to_new_inp()
4845 /* Remove the recv-lock on the old socket */ in sctp_pull_off_control_to_new_inp()
4850 TAILQ_INSERT_TAIL(&new_inp->read_queue, control, next); in sctp_pull_off_control_to_new_inp()
4851 m = control->data; in sctp_pull_off_control_to_new_inp()
4854 …sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN… in sctp_pull_off_control_to_new_inp()
4856 sctp_sballoc(stcb, &new_so->so_rcv, m); in sctp_pull_off_control_to_new_inp()
4858 sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0); in sctp_pull_off_control_to_new_inp()
4874 (inp->sctp_socket != NULL) && in sctp_wakeup_the_read_socket()
4875 (((inp->sctp_flags & (SCTP_PCB_FLAGS_TCPTYPE | SCTP_PCB_FLAGS_IN_TCPPOOL)) == 0) || in sctp_wakeup_the_read_socket()
4877 sctp_sorwakeup(inp, inp->sctp_socket); in sctp_wakeup_the_read_socket()
4907 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ) { in sctp_add_to_readq()
4908 if (!control->on_strm_q) { in sctp_add_to_readq()
4909 sctp_free_remote_addr(control->whoFrom); in sctp_add_to_readq()
4910 if (control->data) { in sctp_add_to_readq()
4911 sctp_m_freem(control->data); in sctp_add_to_readq()
4912 control->data = NULL; in sctp_add_to_readq()
4921 if ((control->spec_flags & M_NOTIFICATION) == 0) { in sctp_add_to_readq()
4922 atomic_add_int(&inp->total_recvs, 1); in sctp_add_to_readq()
4923 if (!control->do_not_ref_stcb) { in sctp_add_to_readq()
4924 atomic_add_int(&stcb->total_recvs, 1); in sctp_add_to_readq()
4927 m = control->data; in sctp_add_to_readq()
4928 control->held_length = 0; in sctp_add_to_readq()
4929 control->length = 0; in sctp_add_to_readq()
4935 control->data = sctp_m_free(m); in sctp_add_to_readq()
4936 m = control->data; in sctp_add_to_readq()
4942 control->tail_mbuf = prev; in sctp_add_to_readq()
4948 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m)); in sctp_add_to_readq()
4952 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0); in sctp_add_to_readq()
4954 atomic_add_int(&control->length, SCTP_BUF_LEN(m)); in sctp_add_to_readq()
4958 control->tail_mbuf = prev; in sctp_add_to_readq()
4961 if (!control->on_strm_q) { in sctp_add_to_readq()
4962 sctp_free_remote_addr(control->whoFrom); in sctp_add_to_readq()
4970 control->end_added = 1; in sctp_add_to_readq()
4972 TAILQ_INSERT_TAIL(&inp->read_queue, control, next); in sctp_add_to_readq()
4973 control->on_read_q = 1; in sctp_add_to_readq()
4974 if ((inp != NULL) && (inp->sctp_socket != NULL)) { in sctp_add_to_readq()
4982 /*************HOLD THIS COMMENT FOR PATCH FILE OF
4986 /*************HOLD THIS COMMENT FOR END OF PATCH FILE OF
5002 if (info_len > (SCTP_MAX_CAUSE_LENGTH - sizeof(struct sctp_paramhdr))) { in sctp_generate_cause()
5010 cause->code = htons(code); in sctp_generate_cause()
5011 cause->length = htons(len); in sctp_generate_cause()
5012 memcpy(cause->info, info, info_len); in sctp_generate_cause()
5029 no_user_data_cause->cause.code = htons(SCTP_CAUSE_NO_USER_DATA); in sctp_generate_no_user_data_cause()
5030 no_user_data_cause->cause.length = htons(len); in sctp_generate_no_user_data_cause()
5031 no_user_data_cause->tsn = htonl(tsn); in sctp_generate_no_user_data_cause()
5040 if (tp1->data == NULL) { in sctp_free_bufspace()
5043 atomic_subtract_int(&asoc->chunks_on_out_queue, chk_cnt); in sctp_free_bufspace()
5047 asoc->total_output_queue_size, in sctp_free_bufspace()
5048 tp1->book_size, in sctp_free_bufspace()
5050 tp1->mbcnt); in sctp_free_bufspace()
5053 if (asoc->total_output_queue_size >= tp1->book_size) { in sctp_free_bufspace()
5054 atomic_subtract_int(&asoc->total_output_queue_size, tp1->book_size); in sctp_free_bufspace()
5056 asoc->total_output_queue_size = 0; in sctp_free_bufspace()
5058 if ((stcb->sctp_socket != NULL) && in sctp_free_bufspace()
5059 (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) || in sctp_free_bufspace()
5060 ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)))) { in sctp_free_bufspace()
5061 SCTP_SB_DECR(&stcb->sctp_socket->so_snd, tp1->book_size); in sctp_free_bufspace()
5081 sid = tp1->rec.data.sid; in sctp_release_pr_sctp_chunk()
5082 mid = tp1->rec.data.mid; in sctp_release_pr_sctp_chunk()
5083 if (sent || ((tp1->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) == 0)) { in sctp_release_pr_sctp_chunk()
5084 stcb->asoc.abandoned_sent[0]++; in sctp_release_pr_sctp_chunk()
5085 stcb->asoc.abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++; in sctp_release_pr_sctp_chunk()
5086 stcb->asoc.strmout[sid].abandoned_sent[0]++; in sctp_release_pr_sctp_chunk()
5088 stcb->asoc.strmout[sid].abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++; in sctp_release_pr_sctp_chunk()
5091 stcb->asoc.abandoned_unsent[0]++; in sctp_release_pr_sctp_chunk()
5092 stcb->asoc.abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++; in sctp_release_pr_sctp_chunk()
5093 stcb->asoc.strmout[sid].abandoned_unsent[0]++; in sctp_release_pr_sctp_chunk()
5095 stcb->asoc.strmout[sid].abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++; in sctp_release_pr_sctp_chunk()
5099 ret_sz += tp1->book_size; in sctp_release_pr_sctp_chunk()
5100 if (tp1->data != NULL) { in sctp_release_pr_sctp_chunk()
5101 if (tp1->sent < SCTP_DATAGRAM_RESEND) { in sctp_release_pr_sctp_chunk()
5105 sctp_free_bufspace(stcb, &stcb->asoc, tp1, 1); in sctp_release_pr_sctp_chunk()
5106 stcb->asoc.peers_rwnd += tp1->send_size; in sctp_release_pr_sctp_chunk()
5107 stcb->asoc.peers_rwnd += SCTP_BASE_SYSCTL(sctp_peer_chunk_oh); in sctp_release_pr_sctp_chunk()
5113 if (tp1->data) { in sctp_release_pr_sctp_chunk()
5114 sctp_m_freem(tp1->data); in sctp_release_pr_sctp_chunk()
5115 tp1->data = NULL; in sctp_release_pr_sctp_chunk()
5118 if (PR_SCTP_BUF_ENABLED(tp1->flags)) { in sctp_release_pr_sctp_chunk()
5119 stcb->asoc.sent_queue_cnt_removeable--; in sctp_release_pr_sctp_chunk()
5122 tp1->sent = SCTP_FORWARD_TSN_SKIP; in sctp_release_pr_sctp_chunk()
5123 if ((tp1->rec.data.rcv_flags & SCTP_DATA_NOT_FRAG) == in sctp_release_pr_sctp_chunk()
5128 } else if (tp1->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) { in sctp_release_pr_sctp_chunk()
5143 * The multi-part message was scattered across the send and in sctp_release_pr_sctp_chunk()
5146 TAILQ_FOREACH_SAFE(tp1, &stcb->asoc.send_queue, sctp_next, tp2) { in sctp_release_pr_sctp_chunk()
5147 if ((tp1->rec.data.sid != sid) || in sctp_release_pr_sctp_chunk()
5148 (!SCTP_MID_EQ(stcb->asoc.idata_supported, tp1->rec.data.mid, mid))) { in sctp_release_pr_sctp_chunk()
5153 * queue. If so and we have an un-transmitted one we in sctp_release_pr_sctp_chunk()
5157 ret_sz += tp1->book_size; in sctp_release_pr_sctp_chunk()
5158 sctp_free_bufspace(stcb, &stcb->asoc, tp1, 1); in sctp_release_pr_sctp_chunk()
5164 if (tp1->data) { in sctp_release_pr_sctp_chunk()
5165 sctp_m_freem(tp1->data); in sctp_release_pr_sctp_chunk()
5166 tp1->data = NULL; in sctp_release_pr_sctp_chunk()
5169 tp1->book_size = 0; in sctp_release_pr_sctp_chunk()
5170 if (tp1->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) { in sctp_release_pr_sctp_chunk()
5174 tp1->sent = SCTP_FORWARD_TSN_SKIP; in sctp_release_pr_sctp_chunk()
5175 TAILQ_REMOVE(&stcb->asoc.send_queue, tp1, sctp_next); in sctp_release_pr_sctp_chunk()
5180 TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, tp1, in sctp_release_pr_sctp_chunk()
5182 stcb->asoc.send_queue_cnt--; in sctp_release_pr_sctp_chunk()
5183 stcb->asoc.sent_queue_cnt++; in sctp_release_pr_sctp_chunk()
5191 strq = &stcb->asoc.strmout[sid]; in sctp_release_pr_sctp_chunk()
5192 sp = TAILQ_FIRST(&strq->outqueue); in sctp_release_pr_sctp_chunk()
5194 sp->discard_rest = 1; in sctp_release_pr_sctp_chunk()
5213 chk->rec.data.rcv_flags = 0; in sctp_release_pr_sctp_chunk()
5214 chk->sent = SCTP_FORWARD_TSN_SKIP; in sctp_release_pr_sctp_chunk()
5215 chk->asoc = &stcb->asoc; in sctp_release_pr_sctp_chunk()
5216 if (stcb->asoc.idata_supported == 0) { in sctp_release_pr_sctp_chunk()
5217 if (sp->sinfo_flags & SCTP_UNORDERED) { in sctp_release_pr_sctp_chunk()
5218 chk->rec.data.mid = 0; in sctp_release_pr_sctp_chunk()
5220 chk->rec.data.mid = strq->next_mid_ordered; in sctp_release_pr_sctp_chunk()
5223 if (sp->sinfo_flags & SCTP_UNORDERED) { in sctp_release_pr_sctp_chunk()
5224 chk->rec.data.mid = strq->next_mid_unordered; in sctp_release_pr_sctp_chunk()
5226 chk->rec.data.mid = strq->next_mid_ordered; in sctp_release_pr_sctp_chunk()
5229 chk->rec.data.sid = sp->sid; in sctp_release_pr_sctp_chunk()
5230 chk->rec.data.ppid = sp->ppid; in sctp_release_pr_sctp_chunk()
5231 chk->rec.data.context = sp->context; in sctp_release_pr_sctp_chunk()
5232 chk->flags = sp->act_flags; in sctp_release_pr_sctp_chunk()
5233 chk->whoTo = NULL; in sctp_release_pr_sctp_chunk()
5234 chk->rec.data.tsn = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1); in sctp_release_pr_sctp_chunk()
5235 strq->chunks_on_queues++; in sctp_release_pr_sctp_chunk()
5236 TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, chk, sctp_next); in sctp_release_pr_sctp_chunk()
5237 stcb->asoc.sent_queue_cnt++; in sctp_release_pr_sctp_chunk()
5238 stcb->asoc.pr_sctp_cnt++; in sctp_release_pr_sctp_chunk()
5240 chk->rec.data.rcv_flags |= SCTP_DATA_LAST_FRAG; in sctp_release_pr_sctp_chunk()
5241 if (sp->sinfo_flags & SCTP_UNORDERED) { in sctp_release_pr_sctp_chunk()
5242 chk->rec.data.rcv_flags |= SCTP_DATA_UNORDERED; in sctp_release_pr_sctp_chunk()
5244 if (stcb->asoc.idata_supported == 0) { in sctp_release_pr_sctp_chunk()
5245 if ((sp->sinfo_flags & SCTP_UNORDERED) == 0) { in sctp_release_pr_sctp_chunk()
5246 strq->next_mid_ordered++; in sctp_release_pr_sctp_chunk()
5249 if (sp->sinfo_flags & SCTP_UNORDERED) { in sctp_release_pr_sctp_chunk()
5250 strq->next_mid_unordered++; in sctp_release_pr_sctp_chunk()
5252 strq->next_mid_ordered++; in sctp_release_pr_sctp_chunk()
5256 if (sp->data) { in sctp_release_pr_sctp_chunk()
5260 * away :-) in sctp_release_pr_sctp_chunk()
5262 sctp_free_spbufspace(stcb, &stcb->asoc, sp); in sctp_release_pr_sctp_chunk()
5263 ret_sz += sp->length; in sctp_release_pr_sctp_chunk()
5265 sp->some_taken = 1; in sctp_release_pr_sctp_chunk()
5266 sctp_m_freem(sp->data); in sctp_release_pr_sctp_chunk()
5267 sp->data = NULL; in sctp_release_pr_sctp_chunk()
5268 sp->tail_mbuf = NULL; in sctp_release_pr_sctp_chunk()
5269 sp->length = 0; in sctp_release_pr_sctp_chunk()
5274 sctp_sowwakeup(stcb->sctp_ep, stcb->sctp_socket); in sctp_release_pr_sctp_chunk()
5295 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { in sctp_find_ifa_in_ep()
5296 if (laddr->ifa == NULL) in sctp_find_ifa_in_ep()
5298 if (addr->sa_family != laddr->ifa->address.sa.sa_family) in sctp_find_ifa_in_ep()
5301 if (addr->sa_family == AF_INET) { in sctp_find_ifa_in_ep()
5302 if (((struct sockaddr_in *)addr)->sin_addr.s_addr == in sctp_find_ifa_in_ep()
5303 laddr->ifa->address.sin.sin_addr.s_addr) { in sctp_find_ifa_in_ep()
5310 if (addr->sa_family == AF_INET6) { in sctp_find_ifa_in_ep()
5312 &laddr->ifa->address.sin6)) { in sctp_find_ifa_in_ep()
5323 return (laddr->ifa); in sctp_find_ifa_in_ep()
5332 switch (addr->sa_family) { in sctp_get_ifa_hash_val()
5339 return (sin->sin_addr.s_addr ^ (sin->sin_addr.s_addr >> 16)); in sctp_get_ifa_hash_val()
5349 hash_of_addr = (sin6->sin6_addr.s6_addr32[0] + in sctp_get_ifa_hash_val()
5350 sin6->sin6_addr.s6_addr32[1] + in sctp_get_ifa_hash_val()
5351 sin6->sin6_addr.s6_addr32[2] + in sctp_get_ifa_hash_val()
5352 sin6->sin6_addr.s6_addr32[3]); in sctp_get_ifa_hash_val()
5386 hash_head = &vrf->vrf_addr_hash[(hash_of_addr & vrf->vrf_addr_hashmark)]; in sctp_find_ifa_by_addr()
5388 SCTP_PRINTF("hash_of_addr:%x mask:%x table:%x - ", in sctp_find_ifa_by_addr()
5389 hash_of_addr, (uint32_t)vrf->vrf_addr_hashmark, in sctp_find_ifa_by_addr()
5390 (uint32_t)(hash_of_addr & vrf->vrf_addr_hashmark)); in sctp_find_ifa_by_addr()
5399 if (addr->sa_family != sctp_ifap->address.sa.sa_family) in sctp_find_ifa_by_addr()
5402 if (addr->sa_family == AF_INET) { in sctp_find_ifa_by_addr()
5403 if (((struct sockaddr_in *)addr)->sin_addr.s_addr == in sctp_find_ifa_by_addr()
5404 sctp_ifap->address.sin.sin_addr.s_addr) { in sctp_find_ifa_by_addr()
5411 if (addr->sa_family == AF_INET6) { in sctp_find_ifa_by_addr()
5413 &sctp_ifap->address.sin6)) { in sctp_find_ifa_by_addr()
5438 atomic_add_int(&stcb->asoc.refcnt, 1); in sctp_user_rcvd()
5441 (stcb->asoc.state & (SCTP_STATE_ABOUT_TO_BE_FREED | SCTP_STATE_SHUTDOWN_RECEIVED))) { in sctp_user_rcvd()
5442 /* Pre-check If we are freeing no update */ in sctp_user_rcvd()
5445 SCTP_INP_INCR_REF(stcb->sctp_ep); in sctp_user_rcvd()
5446 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || in sctp_user_rcvd()
5447 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { in sctp_user_rcvd()
5450 so = stcb->sctp_socket; in sctp_user_rcvd()
5454 atomic_add_int(&stcb->freed_by_sorcv_sincelast, *freed_so_far); in sctp_user_rcvd()
5460 rwnd = sctp_calc_rwnd(stcb, &stcb->asoc); in sctp_user_rcvd()
5461 if (rwnd >= stcb->asoc.my_last_reported_rwnd) { in sctp_user_rcvd()
5462 dif = rwnd - stcb->asoc.my_last_reported_rwnd; in sctp_user_rcvd()
5468 SCTP_INP_READ_UNLOCK(stcb->sctp_ep); in sctp_user_rcvd()
5471 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { in sctp_user_rcvd()
5480 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { in sctp_user_rcvd()
5489 sctp_chunk_output(stcb->sctp_ep, stcb, in sctp_user_rcvd()
5493 sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, in sctp_user_rcvd()
5498 stcb->freed_by_sorcv_sincelast = dif; in sctp_user_rcvd()
5502 SCTP_INP_READ_LOCK(stcb->sctp_ep); in sctp_user_rcvd()
5505 SCTP_INP_DECR_REF(stcb->sctp_ep); in sctp_user_rcvd()
5507 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_user_rcvd()
5522 * MSG flags we will look at MSG_DONTWAIT - non-blocking IO. in sctp_sorecvmsg()
5523 * MSG_PEEK - Look don't touch :-D (only valid with OUT mbuf copy in sctp_sorecvmsg()
5524 * mp=NULL thus uio is the copy method to userland) MSG_WAITALL - ?? in sctp_sorecvmsg()
5563 slen = uio->uio_resid; in sctp_sorecvmsg()
5581 inp = (struct sctp_inpcb *)so->so_pcb; in sctp_sorecvmsg()
5593 rwnd_req, in_eeor_mode, SCTP_SBAVAIL(&so->so_rcv), (uint32_t)uio->uio_resid); in sctp_sorecvmsg()
5597 rwnd_req, block_allowed, SCTP_SBAVAIL(&so->so_rcv), (uint32_t)uio->uio_resid); in sctp_sorecvmsg()
5609 SOCKBUF_LOCK(&so->so_rcv); in sctp_sorecvmsg()
5612 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || in sctp_sorecvmsg()
5613 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { in sctp_sorecvmsg()
5616 if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) && SCTP_SBAVAIL(&so->so_rcv) == 0) { in sctp_sorecvmsg()
5617 if (so->so_error) { in sctp_sorecvmsg()
5618 error = so->so_error; in sctp_sorecvmsg()
5620 so->so_error = 0; in sctp_sorecvmsg()
5623 if (SCTP_SBAVAIL(&so->so_rcv) == 0) { in sctp_sorecvmsg()
5630 if (SCTP_SBAVAIL(&so->so_rcv) <= held_length) { in sctp_sorecvmsg()
5631 if (so->so_error) { in sctp_sorecvmsg()
5632 error = so->so_error; in sctp_sorecvmsg()
5634 so->so_error = 0; in sctp_sorecvmsg()
5638 if ((SCTP_SBAVAIL(&so->so_rcv) == 0) && in sctp_sorecvmsg()
5639 ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || in sctp_sorecvmsg()
5640 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { in sctp_sorecvmsg()
5641 if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0) { in sctp_sorecvmsg()
5644 * re-use passive open is blocked by in sctp_sorecvmsg()
5647 if (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED) { in sctp_sorecvmsg()
5655 so->so_state &= ~(SS_ISCONNECTING | in sctp_sorecvmsg()
5659 if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) == 0) { in sctp_sorecvmsg()
5681 SOCKBUF_UNLOCK(&so->so_rcv); in sctp_sorecvmsg()
5686 control = TAILQ_FIRST(&inp->read_queue); in sctp_sorecvmsg()
5696 control = TAILQ_FIRST(&inp->read_queue); in sctp_sorecvmsg()
5697 if ((control == NULL) && (SCTP_SBAVAIL(&so->so_rcv) > 0)) { in sctp_sorecvmsg()
5701 SCTP_SB_CLEAR(so->so_rcv); in sctp_sorecvmsg()
5708 if ((control->length == 0) && in sctp_sorecvmsg()
5709 (control->do_not_ref_stcb)) { in sctp_sorecvmsg()
5719 control->held_length = 0; in sctp_sorecvmsg()
5720 if (control->data) { in sctp_sorecvmsg()
5725 m_tmp = control->data; in sctp_sorecvmsg()
5729 control->tail_mbuf = m_tmp; in sctp_sorecvmsg()
5730 control->end_added = 1; in sctp_sorecvmsg()
5734 control->length = cnt; in sctp_sorecvmsg()
5737 TAILQ_REMOVE(&inp->read_queue, control, next); in sctp_sorecvmsg()
5739 sctp_free_remote_addr(control->whoFrom); in sctp_sorecvmsg()
5748 if ((control->length == 0) && in sctp_sorecvmsg()
5749 (control->end_added == 1)) { in sctp_sorecvmsg()
5751 * Do we also need to check for (control->pdapi_aborted == in sctp_sorecvmsg()
5758 TAILQ_REMOVE(&inp->read_queue, control, next); in sctp_sorecvmsg()
5759 if (control->data) { in sctp_sorecvmsg()
5761 panic("control->data not null but control->length == 0"); in sctp_sorecvmsg()
5764 sctp_m_freem(control->data); in sctp_sorecvmsg()
5765 control->data = NULL; in sctp_sorecvmsg()
5768 if (control->aux_data) { in sctp_sorecvmsg()
5769 sctp_m_free(control->aux_data); in sctp_sorecvmsg()
5770 control->aux_data = NULL; in sctp_sorecvmsg()
5773 if (control->on_strm_q) { in sctp_sorecvmsg()
5775 control, so, control->on_strm_q); in sctp_sorecvmsg()
5778 sctp_free_remote_addr(control->whoFrom); in sctp_sorecvmsg()
5786 if (control->length == 0) { in sctp_sorecvmsg()
5792 if ((ctl->stcb != control->stcb) && (ctl->length) && in sctp_sorecvmsg()
5793 (ctl->some_taken || in sctp_sorecvmsg()
5794 (ctl->spec_flags & M_NOTIFICATION) || in sctp_sorecvmsg()
5795 ((ctl->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
5796 (ctl->stcb->asoc.strmin[ctl->sinfo_stream].delivery_started == 0))) in sctp_sorecvmsg()
5798 /*- in sctp_sorecvmsg()
5808 (ctl->length) && in sctp_sorecvmsg()
5809 ((ctl->some_taken) || in sctp_sorecvmsg()
5810 ((ctl->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
5811 ((ctl->spec_flags & M_NOTIFICATION) == 0) && in sctp_sorecvmsg()
5812 (ctl->stcb->asoc.strmin[ctl->sinfo_stream].delivery_started == 0)))) { in sctp_sorecvmsg()
5813 /*- in sctp_sorecvmsg()
5832 held_length = SCTP_SBAVAIL(&so->so_rcv); in sctp_sorecvmsg()
5833 control->held_length = SCTP_SBAVAIL(&so->so_rcv); in sctp_sorecvmsg()
5837 control->held_length = 0; in sctp_sorecvmsg()
5847 control->some_taken++; in sctp_sorecvmsg()
5848 stcb = control->stcb; in sctp_sorecvmsg()
5850 if ((control->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
5851 (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED)) { in sctp_sorecvmsg()
5854 } else if (control->do_not_ref_stcb == 0) { in sctp_sorecvmsg()
5870 atomic_add_int(&stcb->asoc.refcnt, 1); in sctp_sorecvmsg()
5880 * lock until it KNOWs it MUST send a WUP-SACK. in sctp_sorecvmsg()
5882 freed_so_far = (uint32_t)stcb->freed_by_sorcv_sincelast; in sctp_sorecvmsg()
5883 stcb->freed_by_sorcv_sincelast = 0; in sctp_sorecvmsg()
5887 ((control->spec_flags & M_NOTIFICATION) == 0) && in sctp_sorecvmsg()
5888 control->do_not_ref_stcb == 0) { in sctp_sorecvmsg()
5889 stcb->asoc.strmin[control->sinfo_stream].delivery_started = 1; in sctp_sorecvmsg()
5894 sinfo->sinfo_stream = control->sinfo_stream; in sctp_sorecvmsg()
5895 sinfo->sinfo_ssn = (uint16_t)control->mid; in sctp_sorecvmsg()
5896 sinfo->sinfo_flags = control->sinfo_flags; in sctp_sorecvmsg()
5897 sinfo->sinfo_ppid = control->sinfo_ppid; in sctp_sorecvmsg()
5898 sinfo->sinfo_context = control->sinfo_context; in sctp_sorecvmsg()
5899 sinfo->sinfo_timetolive = control->sinfo_timetolive; in sctp_sorecvmsg()
5900 sinfo->sinfo_tsn = control->sinfo_tsn; in sctp_sorecvmsg()
5901 sinfo->sinfo_cumtsn = control->sinfo_cumtsn; in sctp_sorecvmsg()
5902 sinfo->sinfo_assoc_id = control->sinfo_assoc_id; in sctp_sorecvmsg()
5910 (nxt->length)) { in sctp_sorecvmsg()
5911 s_extra->serinfo_next_flags = SCTP_NEXT_MSG_AVAIL; in sctp_sorecvmsg()
5912 if (nxt->sinfo_flags & SCTP_UNORDERED) { in sctp_sorecvmsg()
5913 s_extra->serinfo_next_flags |= SCTP_NEXT_MSG_IS_UNORDERED; in sctp_sorecvmsg()
5915 if (nxt->spec_flags & M_NOTIFICATION) { in sctp_sorecvmsg()
5916 s_extra->serinfo_next_flags |= SCTP_NEXT_MSG_IS_NOTIFICATION; in sctp_sorecvmsg()
5918 s_extra->serinfo_next_aid = nxt->sinfo_assoc_id; in sctp_sorecvmsg()
5919 s_extra->serinfo_next_length = nxt->length; in sctp_sorecvmsg()
5920 s_extra->serinfo_next_ppid = nxt->sinfo_ppid; in sctp_sorecvmsg()
5921 s_extra->serinfo_next_stream = nxt->sinfo_stream; in sctp_sorecvmsg()
5922 if (nxt->tail_mbuf != NULL) { in sctp_sorecvmsg()
5923 if (nxt->end_added) { in sctp_sorecvmsg()
5924 s_extra->serinfo_next_flags |= SCTP_NEXT_MSG_ISCOMPLETE; in sctp_sorecvmsg()
5932 * :-D in sctp_sorecvmsg()
5935 s_extra->serinfo_next_flags = SCTP_NO_NEXT_MSG; in sctp_sorecvmsg()
5936 s_extra->serinfo_next_aid = 0; in sctp_sorecvmsg()
5937 s_extra->serinfo_next_length = 0; in sctp_sorecvmsg()
5938 s_extra->serinfo_next_ppid = 0; in sctp_sorecvmsg()
5939 s_extra->serinfo_next_stream = 0; in sctp_sorecvmsg()
5943 * update off the real current cum-ack, if we have an stcb. in sctp_sorecvmsg()
5945 if ((control->do_not_ref_stcb == 0) && stcb) in sctp_sorecvmsg()
5946 sinfo->sinfo_cumtsn = stcb->asoc.cumulative_tsn; in sctp_sorecvmsg()
5951 sinfo->sinfo_flags &= 0x00ff; in sctp_sorecvmsg()
5952 if ((control->sinfo_flags >> 8) & SCTP_DATA_UNORDERED) { in sctp_sorecvmsg()
5953 sinfo->sinfo_flags |= SCTP_UNORDERED; in sctp_sorecvmsg()
5962 index = inp->readlog_index; in sctp_sorecvmsg()
5967 } while (atomic_cmpset_int(&inp->readlog_index, index, newindex) == 0); in sctp_sorecvmsg()
5968 entry = &inp->readlog[index]; in sctp_sorecvmsg()
5969 entry->vtag = control->sinfo_assoc_id; in sctp_sorecvmsg()
5970 entry->strm = control->sinfo_stream; in sctp_sorecvmsg()
5971 entry->seq = (uint16_t)control->mid; in sctp_sorecvmsg()
5972 entry->sz = control->length; in sctp_sorecvmsg()
5973 entry->flgs = control->sinfo_flags; in sctp_sorecvmsg()
5980 switch (control->whoFrom->ro._l_addr.sa.sa_family) { in sctp_sorecvmsg()
5984 store.sin6 = control->whoFrom->ro._l_addr.sin6; in sctp_sorecvmsg()
5985 store.sin6.sin6_port = control->port_from; in sctp_sorecvmsg()
5993 in6_sin_2_v4mapsin6(&control->whoFrom->ro._l_addr.sin, in sctp_sorecvmsg()
5995 store.sin6.sin6_port = control->port_from; in sctp_sorecvmsg()
5998 store.sin = control->whoFrom->ro._l_addr.sin; in sctp_sorecvmsg()
5999 store.sin.sin_port = control->port_from; in sctp_sorecvmsg()
6003 store.sin = control->whoFrom->ro._l_addr.sin; in sctp_sorecvmsg()
6004 store.sin.sin_port = control->port_from; in sctp_sorecvmsg()
6027 SOCKBUF_UNLOCK(&so->so_rcv); in sctp_sorecvmsg()
6034 m = control->data; in sctp_sorecvmsg()
6037 cp_len = uio->uio_resid; in sctp_sorecvmsg()
6049 /* re-read */ in sctp_sorecvmsg()
6050 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) { in sctp_sorecvmsg()
6054 if ((control->do_not_ref_stcb == 0) && stcb && in sctp_sorecvmsg()
6055 stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { in sctp_sorecvmsg()
6066 (control->end_added)) { in sctp_sorecvmsg()
6068 if ((control->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
6069 (control->stcb != NULL) && in sctp_sorecvmsg()
6070 ((control->spec_flags & M_NOTIFICATION) == 0)) in sctp_sorecvmsg()
6071 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0; in sctp_sorecvmsg()
6073 if (control->spec_flags & M_NOTIFICATION) { in sctp_sorecvmsg()
6084 sctp_sblog(&so->so_rcv, in sctp_sorecvmsg()
6085 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m)); in sctp_sorecvmsg()
6087 sctp_sbfree(control, stcb, &so->so_rcv, m); in sctp_sorecvmsg()
6089 sctp_sblog(&so->so_rcv, in sctp_sorecvmsg()
6090 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0); in sctp_sorecvmsg()
6095 atomic_subtract_int(&control->length, (int)cp_len); in sctp_sorecvmsg()
6096 control->data = sctp_m_free(m); in sctp_sorecvmsg()
6097 m = control->data; in sctp_sorecvmsg()
6099 * been through it all, must hold sb in sctp_sorecvmsg()
6102 if (control->data == NULL) { in sctp_sorecvmsg()
6104 if ((control->end_added == 0) || in sctp_sorecvmsg()
6113 if (mtx_owned(&inp->inp_rdata_mtx) == 0) { in sctp_sorecvmsg()
6118 control->tail_mbuf = NULL; in sctp_sorecvmsg()
6120 if ((control->end_added) && ((out_flags & MSG_EOR) == 0)) { in sctp_sorecvmsg()
6128 if (control->spec_flags & M_NOTIFICATION) { in sctp_sorecvmsg()
6133 SCTP_BUF_LEN(m) -= (int)cp_len; in sctp_sorecvmsg()
6135 sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, (int)cp_len); in sctp_sorecvmsg()
6137 SCTP_SB_DECR(&so->so_rcv, cp_len); in sctp_sorecvmsg()
6138 if ((control->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
6140 atomic_subtract_int(&stcb->asoc.sb_cc, (int)cp_len); in sctp_sorecvmsg()
6146 sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, in sctp_sorecvmsg()
6149 atomic_subtract_int(&control->length, (int)cp_len); in sctp_sorecvmsg()
6154 if ((out_flags & MSG_EOR) || (uio->uio_resid == 0)) { in sctp_sorecvmsg()
6158 (control->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
6166 * control->length == 0. in sctp_sorecvmsg()
6170 if (control->length == 0) { in sctp_sorecvmsg()
6171 if (control->data) { in sctp_sorecvmsg()
6173 panic("control->data not null at read eor?"); in sctp_sorecvmsg()
6176 sctp_m_freem(control->data); in sctp_sorecvmsg()
6177 control->data = NULL; in sctp_sorecvmsg()
6185 TAILQ_REMOVE(&inp->read_queue, control, next); in sctp_sorecvmsg()
6187 if (control->held_length) { in sctp_sorecvmsg()
6189 control->held_length = 0; in sctp_sorecvmsg()
6192 if (control->aux_data) { in sctp_sorecvmsg()
6193 sctp_m_free(control->aux_data); in sctp_sorecvmsg()
6194 control->aux_data = NULL; in sctp_sorecvmsg()
6196 no_rcv_needed = control->do_not_ref_stcb; in sctp_sorecvmsg()
6197 sctp_free_remote_addr(control->whoFrom); in sctp_sorecvmsg()
6198 control->data = NULL; in sctp_sorecvmsg()
6200 if (control->on_strm_q) { in sctp_sorecvmsg()
6202 control, so, control->on_strm_q); in sctp_sorecvmsg()
6219 if (control->end_added && in sctp_sorecvmsg()
6220 (control->data == NULL) && in sctp_sorecvmsg()
6221 (control->tail_mbuf == NULL)) { in sctp_sorecvmsg()
6222 panic("Gak, control->length is corrupt?"); in sctp_sorecvmsg()
6225 no_rcv_needed = control->do_not_ref_stcb; in sctp_sorecvmsg()
6232 if ((uio->uio_resid == 0) || in sctp_sorecvmsg()
6234 (copied_so_far >= max(so->so_rcv.sb_lowat, 1)))) { in sctp_sorecvmsg()
6239 * NOT done (pd-api). So two questions. Can we block? if not in sctp_sorecvmsg()
6246 * We need to wait for more data a few things: - We don't in sctp_sorecvmsg()
6248 * reading. - We must be sure to account for the case where in sctp_sorecvmsg()
6258 (control->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
6263 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { in sctp_sorecvmsg()
6267 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) in sctp_sorecvmsg()
6275 SOCKBUF_LOCK(&so->so_rcv); in sctp_sorecvmsg()
6278 if ((copied_so_far) && (control->length == 0) && in sctp_sorecvmsg()
6282 if (SCTP_SBAVAIL(&so->so_rcv) <= control->held_length) { in sctp_sorecvmsg()
6287 control->held_length = 0; in sctp_sorecvmsg()
6290 SOCKBUF_UNLOCK(&so->so_rcv); in sctp_sorecvmsg()
6293 if (control->length == 0) { in sctp_sorecvmsg()
6295 if (control->end_added == 1) { in sctp_sorecvmsg()
6298 if (control->pdapi_aborted) { in sctp_sorecvmsg()
6299 if ((control->do_not_ref_stcb == 0) && ((control->spec_flags & M_NOTIFICATION) == 0)) in sctp_sorecvmsg()
6300 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0; in sctp_sorecvmsg()
6304 if ((control->do_not_ref_stcb == 0) && ((control->spec_flags & M_NOTIFICATION) == 0)) in sctp_sorecvmsg()
6305 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0; in sctp_sorecvmsg()
6309 if (SCTP_SBAVAIL(&so->so_rcv) > held_length) { in sctp_sorecvmsg()
6310 control->held_length = SCTP_SBAVAIL(&so->so_rcv); in sctp_sorecvmsg()
6314 } else if (control->data == NULL) { in sctp_sorecvmsg()
6316 * we must re-sync since data is probably being in sctp_sorecvmsg()
6320 if ((control->length > 0) && (control->data == NULL)) { in sctp_sorecvmsg()
6330 control->length = 0; in sctp_sorecvmsg()
6339 /*- in sctp_sorecvmsg()
6344 if ((control->end_added == 0) || in sctp_sorecvmsg()
6352 if (control->end_added) { in sctp_sorecvmsg()
6354 if ((control->do_not_ref_stcb == 0) && in sctp_sorecvmsg()
6355 (control->stcb != NULL) && in sctp_sorecvmsg()
6356 ((control->spec_flags & M_NOTIFICATION) == 0)) in sctp_sorecvmsg()
6357 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0; in sctp_sorecvmsg()
6359 if (control->spec_flags & M_NOTIFICATION) { in sctp_sorecvmsg()
6362 uio->uio_resid = control->length; in sctp_sorecvmsg()
6363 *mp = control->data; in sctp_sorecvmsg()
6364 m = control->data; in sctp_sorecvmsg()
6367 sctp_sblog(&so->so_rcv, in sctp_sorecvmsg()
6368 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m)); in sctp_sorecvmsg()
6370 sctp_sbfree(control, stcb, &so->so_rcv, m); in sctp_sorecvmsg()
6374 sctp_sblog(&so->so_rcv, in sctp_sorecvmsg()
6375 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0); in sctp_sorecvmsg()
6379 control->data = control->tail_mbuf = NULL; in sctp_sorecvmsg()
6380 control->length = 0; in sctp_sorecvmsg()
6392 SOCKBUF_UNLOCK(&so->so_rcv); in sctp_sorecvmsg()
6401 SOCKBUF_UNLOCK(&so->so_rcv); in sctp_sorecvmsg()
6406 (control && (control->do_not_ref_stcb == 0)) && in sctp_sorecvmsg()
6422 s_extra->serinfo_next_flags = SCTP_NO_NEXT_MSG; in sctp_sorecvmsg()
6428 SOCKBUF_UNLOCK(&so->so_rcv); in sctp_sorecvmsg()
6450 stcb->freed_by_sorcv_sincelast = freed_so_far; in sctp_sorecvmsg()
6451 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_sorecvmsg()
6457 (uint32_t)((uio) ? (slen - uio->uio_resid) : slen), in sctp_sorecvmsg()
6458 stcb->asoc.my_rwnd, in sctp_sorecvmsg()
6459 SCTP_SBAVAIL(&so->so_rcv)); in sctp_sorecvmsg()
6463 (uint32_t)((uio) ? (slen - uio->uio_resid) : slen), in sctp_sorecvmsg()
6465 SCTP_SBAVAIL(&so->so_rcv)); in sctp_sorecvmsg()
6499 * address, request a peer-set-primary. in sctp_dynamic_set_primary()
6521 (void)SCTP_GETTIME_TIMEVAL(&wi->start_time); in sctp_dynamic_set_primary()
6522 wi->ifa = ifa; in sctp_dynamic_set_primary()
6523 wi->action = SCTP_SET_PRIM_ADDR; in sctp_dynamic_set_primary()
6524 atomic_add_int(&ifa->refcount, 1); in sctp_dynamic_set_primary()
6530 * newest first :-0 in sctp_dynamic_set_primary()
6557 inp = (struct sctp_inpcb *)so->so_pcb; in sctp_soreceive()
6573 from->sa_len = 0; in sctp_soreceive()
6603 if (from && from->sa_len) { in sctp_soreceive()
6629 inp = stcb->sctp_ep; in sctp_connectx_helper_add()
6632 switch (sa->sa_family) { in sctp_connectx_helper_add()
6637 if ((sin->sin_addr.s_addr == INADDR_ANY) || in sctp_connectx_helper_add()
6638 (sin->sin_addr.s_addr == INADDR_BROADCAST) || in sctp_connectx_helper_add()
6639 IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) { in sctp_connectx_helper_add()
6646 if (sctp_add_remote_addr(stcb, sa, NULL, stcb->asoc.port, in sctp_connectx_helper_add()
6649 /* assoc gone no un-lock */ in sctp_connectx_helper_add()
6663 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) || in sctp_connectx_helper_add()
6664 IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { in sctp_connectx_helper_add()
6671 if (sctp_add_remote_addr(stcb, sa, NULL, stcb->asoc.port, in sctp_connectx_helper_add()
6674 /* assoc gone no un-lock */ in sctp_connectx_helper_add()
6714 switch (sa->sa_family) { in sctp_connectx_helper_find()
6718 if (sa->sa_len != incr) { in sctp_connectx_helper_find()
6730 if (sa->sa_len != incr) { in sctp_connectx_helper_find()
6734 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp_connectx_helper_find()
6735 /* Must be non-mapped for connectx */ in sctp_connectx_helper_find()
6785 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { in sctp_bindx_add_address()
6790 switch (sa->sa_family) { in sctp_bindx_add_address()
6793 if (sa->sa_len != sizeof(struct sockaddr_in6)) { in sctp_bindx_add_address()
6798 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) { in sctp_bindx_add_address()
6805 port = sin6->sin6_port; in sctp_bindx_add_address()
6807 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp_bindx_add_address()
6808 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && in sctp_bindx_add_address()
6810 /* can't bind v4-mapped on PF_INET sockets */ in sctp_bindx_add_address()
6827 if (sa->sa_len != sizeof(struct sockaddr_in)) { in sctp_bindx_add_address()
6832 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && in sctp_bindx_add_address()
6840 port = sinp->sin_port; in sctp_bindx_add_address()
6849 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) { in sctp_bindx_add_address()
6860 if ((port != 0) && (port != inp->sctp_lport)) { in sctp_bindx_add_address()
6893 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { in sctp_bindx_delete_address()
6898 switch (sa->sa_family) { in sctp_bindx_delete_address()
6901 if (sa->sa_len != sizeof(struct sockaddr_in6)) { in sctp_bindx_delete_address()
6906 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) { in sctp_bindx_delete_address()
6914 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp_bindx_delete_address()
6915 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && in sctp_bindx_delete_address()
6917 /* can't bind mapped-v4 on PF_INET sockets */ in sctp_bindx_delete_address()
6934 if (sa->sa_len != sizeof(struct sockaddr_in)) { in sctp_bindx_delete_address()
6939 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && in sctp_bindx_delete_address()
6979 loopback_scope = stcb->asoc.scope.loopback_scope; in sctp_local_addr_count()
6981 ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; in sctp_local_addr_count()
6982 ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; in sctp_local_addr_count()
6985 local_scope = stcb->asoc.scope.local_scope; in sctp_local_addr_count()
6986 site_scope = stcb->asoc.scope.site_scope; in sctp_local_addr_count()
6987 ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; in sctp_local_addr_count()
6990 vrf = sctp_find_vrf(stcb->asoc.vrf_id); in sctp_local_addr_count()
6997 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { in sctp_local_addr_count()
7001 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { in sctp_local_addr_count()
7006 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { in sctp_local_addr_count()
7009 switch (sctp_ifa->address.sa.sa_family) { in sctp_local_addr_count()
7015 sin = &sctp_ifa->address.sin; in sctp_local_addr_count()
7016 if (sin->sin_addr.s_addr == 0) { in sctp_local_addr_count()
7023 if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred, in sctp_local_addr_count()
7024 &sin->sin_addr) != 0) { in sctp_local_addr_count()
7028 (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) { in sctp_local_addr_count()
7043 sin6 = &sctp_ifa->address.sin6; in sctp_local_addr_count()
7044 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { in sctp_local_addr_count()
7047 if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred, in sctp_local_addr_count()
7048 &sin6->sin6_addr) != 0) { in sctp_local_addr_count()
7051 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { in sctp_local_addr_count()
7054 if (sin6->sin6_scope_id == 0) { in sctp_local_addr_count()
7069 (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { in sctp_local_addr_count()
7089 LIST_FOREACH(laddr, &stcb->sctp_ep->sctp_addr_list, in sctp_local_addr_count()
7091 if (sctp_is_addr_restricted(stcb, laddr->ifa)) { in sctp_local_addr_count()
7143 if ((m->m_flags & M_PKTHDR) == 0) { in sctp_recv_udp_tunneled_packet()
7150 port = uhdr->uh_sport; in sctp_recv_udp_tunneled_packet()
7160 if (sp->m_pkthdr.len < sizeof(struct udphdr) + sizeof(struct sctphdr)) { in sctp_recv_udp_tunneled_packet()
7161 /* Gak, packet can't have an SCTP header in it - too small */ in sctp_recv_udp_tunneled_packet()
7175 for (last = m; last->m_next; last = last->m_next); in sctp_recv_udp_tunneled_packet()
7176 last->m_next = sp; in sctp_recv_udp_tunneled_packet()
7177 m->m_pkthdr.len += sp->m_pkthdr.len; in sctp_recv_udp_tunneled_packet()
7186 m->m_pkthdr.len, in sctp_recv_udp_tunneled_packet()
7187 if_name(m->m_pkthdr.rcvif), in sctp_recv_udp_tunneled_packet()
7188 (int)m->m_pkthdr.csum_flags, CSUM_BITS); in sctp_recv_udp_tunneled_packet()
7189 m->m_pkthdr.csum_flags &= ~CSUM_DATA_VALID; in sctp_recv_udp_tunneled_packet()
7191 switch (iph->ip_v) { in sctp_recv_udp_tunneled_packet()
7194 iph->ip_len = htons(ntohs(iph->ip_len) - sizeof(struct udphdr)); in sctp_recv_udp_tunneled_packet()
7201 ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - sizeof(struct udphdr)); in sctp_recv_udp_tunneled_packet()
7231 inner_ip = &icmp->icmp_ip; in sctp_recv_icmp_tunneled_packet()
7232 outer_ip = (struct ip *)((caddr_t)icmp - sizeof(struct ip)); in sctp_recv_icmp_tunneled_packet()
7233 if (ntohs(outer_ip->ip_len) < in sctp_recv_icmp_tunneled_packet()
7234 sizeof(struct ip) + 8 + (inner_ip->ip_hl << 2) + sizeof(struct udphdr) + 8) { in sctp_recv_icmp_tunneled_packet()
7237 udp = (struct udphdr *)((caddr_t)inner_ip + (inner_ip->ip_hl << 2)); in sctp_recv_icmp_tunneled_packet()
7242 src.sin_port = sh->src_port; in sctp_recv_icmp_tunneled_packet()
7243 src.sin_addr = inner_ip->ip_src; in sctp_recv_icmp_tunneled_packet()
7247 dst.sin_port = sh->dest_port; in sctp_recv_icmp_tunneled_packet()
7248 dst.sin_addr = inner_ip->ip_dst; in sctp_recv_icmp_tunneled_packet()
7264 if ((udp->uh_dport != net->port) || in sctp_recv_icmp_tunneled_packet()
7265 (udp->uh_sport != htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)))) { in sctp_recv_icmp_tunneled_packet()
7270 if (ntohl(sh->v_tag) != 0) { in sctp_recv_icmp_tunneled_packet()
7276 if (ntohl(sh->v_tag) != stcb->asoc.peer_vtag) { in sctp_recv_icmp_tunneled_packet()
7281 if (ntohs(outer_ip->ip_len) >= in sctp_recv_icmp_tunneled_packet()
7283 8 + (inner_ip->ip_hl << 2) + 8 + 20) { in sctp_recv_icmp_tunneled_packet()
7290 if ((ch->ch.chunk_type != SCTP_INITIATION) || in sctp_recv_icmp_tunneled_packet()
7291 (ntohl(ch->init.initiate_tag) != stcb->asoc.my_vtag)) { in sctp_recv_icmp_tunneled_packet()
7300 type = icmp->icmp_type; in sctp_recv_icmp_tunneled_packet()
7301 code = icmp->icmp_code; in sctp_recv_icmp_tunneled_packet()
7307 ntohs(inner_ip->ip_len), in sctp_recv_icmp_tunneled_packet()
7308 (uint32_t)ntohs(icmp->icmp_nextmtu)); in sctp_recv_icmp_tunneled_packet()
7311 /* reduce ref-count */ in sctp_recv_icmp_tunneled_packet()
7340 if (ip6cp->ip6c_m == NULL) { in sctp_recv_icmp6_tunneled_packet()
7347 if (ip6cp->ip6c_m->m_pkthdr.len < in sctp_recv_icmp6_tunneled_packet()
7348 ip6cp->ip6c_off + sizeof(struct udphdr) + offsetof(struct sctphdr, checksum)) { in sctp_recv_icmp6_tunneled_packet()
7353 m_copydata(ip6cp->ip6c_m, in sctp_recv_icmp6_tunneled_packet()
7354 ip6cp->ip6c_off, in sctp_recv_icmp6_tunneled_packet()
7359 m_copydata(ip6cp->ip6c_m, in sctp_recv_icmp6_tunneled_packet()
7360 ip6cp->ip6c_off + sizeof(struct udphdr), in sctp_recv_icmp6_tunneled_packet()
7367 src.sin6_addr = ip6cp->ip6c_ip6->ip6_src; in sctp_recv_icmp6_tunneled_packet()
7368 if (in6_setscope(&src.sin6_addr, ip6cp->ip6c_m->m_pkthdr.rcvif, NULL) != 0) { in sctp_recv_icmp6_tunneled_packet()
7375 dst.sin6_addr = ip6cp->ip6c_ip6->ip6_dst; in sctp_recv_icmp6_tunneled_packet()
7376 if (in6_setscope(&dst.sin6_addr, ip6cp->ip6c_m->m_pkthdr.rcvif, NULL) != 0) { in sctp_recv_icmp6_tunneled_packet()
7388 if ((udp.uh_dport != net->port) || in sctp_recv_icmp6_tunneled_packet()
7400 if (ntohl(sh.v_tag) != stcb->asoc.peer_vtag) { in sctp_recv_icmp6_tunneled_packet()
7405 if (ip6cp->ip6c_m->m_pkthdr.len >= in sctp_recv_icmp6_tunneled_packet()
7406 ip6cp->ip6c_off + sizeof(struct udphdr) + in sctp_recv_icmp6_tunneled_packet()
7418 m_copydata(ip6cp->ip6c_m, in sctp_recv_icmp6_tunneled_packet()
7419 ip6cp->ip6c_off + in sctp_recv_icmp6_tunneled_packet()
7424 m_copydata(ip6cp->ip6c_m, in sctp_recv_icmp6_tunneled_packet()
7425 ip6cp->ip6c_off + in sctp_recv_icmp6_tunneled_packet()
7432 (ntohl(initiate_tag) != stcb->asoc.my_vtag)) { in sctp_recv_icmp6_tunneled_packet()
7441 type = ip6cp->ip6c_icmp6->icmp6_type; in sctp_recv_icmp6_tunneled_packet()
7442 code = ip6cp->ip6c_icmp6->icmp6_code; in sctp_recv_icmp6_tunneled_packet()
7449 ntohl(ip6cp->ip6c_icmp6->icmp6_mtu)); in sctp_recv_icmp6_tunneled_packet()
7452 /* reduce inp's ref-count */ in sctp_recv_icmp6_tunneled_packet()
7507 /* Already running -- must stop first */ in sctp_over_udp_start()
7513 /* Already running -- must stop first */ in sctp_over_udp_start()
7520 curthread->td_ucred, curthread))) { in sctp_over_udp_start()
7546 curthread->td_ucred, curthread))) { in sctp_over_udp_start()
7573 * sctp_min_mtu ()returns the minimum of all non-zero arguments.
7613 switch (addr->sa.sa_family) { in sctp_hc_set_mtu()
7616 inc.inc_faddr = addr->sin.sin_addr; in sctp_hc_set_mtu()
7622 inc.inc6_faddr = addr->sin6.sin6_addr; in sctp_hc_set_mtu()
7638 switch (addr->sa.sa_family) { in sctp_hc_get_mtu()
7641 inc.inc_faddr = addr->sin.sin_addr; in sctp_hc_get_mtu()
7647 inc.inc6_faddr = addr->sin6.sin6_addr; in sctp_hc_get_mtu()
7660 int old_state = stcb->asoc.state; in sctp_set_state()
7666 stcb->asoc.state = (stcb->asoc.state & ~SCTP_STATE_MASK) | new_state; in sctp_set_state()
7685 int old_state = stcb->asoc.state; in sctp_add_substate()
7691 stcb->asoc.state |= substate; in sctp_add_substate()