Lines Matching defs:inp

887 						if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred,
906 if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred,
1006 struct sctp_inpcb *inp;
1046 LIST_FOREACH(inp, ephead, sctp_hash) {
1047 SCTP_INP_RLOCK(inp);
1048 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1049 SCTP_INP_RUNLOCK(inp);
1052 if (lport != inp->sctp_lport) {
1053 SCTP_INP_RUNLOCK(inp);
1063 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
1065 SCTP_INP_RUNLOCK(inp);
1077 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
1079 SCTP_INP_RUNLOCK(inp);
1086 SCTP_INP_RUNLOCK(inp);
1089 if (inp->def_vrf_id != vrf_id) {
1090 SCTP_INP_RUNLOCK(inp);
1094 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
1098 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1144 SCTP_INP_RUNLOCK(inp);
1153 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1155 SCTP_INP_RUNLOCK(inp);
1161 SCTP_INP_RUNLOCK(inp);
1167 SCTP_INP_RUNLOCK(inp);
1172 SCTP_INP_RUNLOCK(inp);
1177 SCTP_INP_RUNLOCK(inp);
1204 *inp_p = inp;
1205 SCTP_INP_RUNLOCK(inp);
1228 *inp_p = inp;
1229 SCTP_INP_RUNLOCK(inp);
1241 SCTP_INP_RUNLOCK(inp);
1260 struct sctp_inpcb *inp;
1265 inp = *inp_p;
1289 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
1290 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
1296 * and find the real inp.
1298 if ((inp->sctp_socket) && SCTP_IS_LISTENING(inp)) {
1301 netp, inp->def_vrf_id);
1304 SCTP_INP_DECR_REF(inp);
1315 SCTP_INP_WLOCK(inp);
1316 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1319 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1367 SCTP_INP_DECR_REF(inp);
1375 SCTP_INP_WUNLOCK(inp);
1397 SCTP_INP_DECR_REF(inp);
1404 SCTP_INP_WUNLOCK(inp);
1419 SCTP_INP_WLOCK(inp);
1420 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1423 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(rport,
1424 inp->sctp_hashmark)];
1468 SCTP_INP_DECR_REF(inp);
1475 SCTP_INP_WUNLOCK(inp);
1498 SCTP_INP_DECR_REF(inp);
1505 SCTP_INP_WUNLOCK(inp);
1526 SCTP_INP_WUNLOCK(inp);
1537 sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1546 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1551 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
1559 if (inp != stcb->sctp_ep) {
1580 sctp_findassociation_ep_asocid(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1584 SCTP_INP_RLOCK(inp);
1585 stcb = sctp_findasoc_ep_asocid_locked(inp, asoc_id, want_lock);
1586 SCTP_INP_RUNLOCK(inp);
1597 struct sctp_inpcb *inp;
1633 LIST_FOREACH(inp, head, sctp_hash) {
1634 SCTP_INP_RLOCK(inp);
1635 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1636 SCTP_INP_RUNLOCK(inp);
1639 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) &&
1640 (inp->sctp_lport == lport)) {
1645 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1646 SCTP_IPV6_V6ONLY(inp)) {
1651 SCTP_INP_RUNLOCK(inp);
1654 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
1656 SCTP_INP_RUNLOCK(inp);
1667 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) {
1668 SCTP_INP_RUNLOCK(inp);
1671 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
1673 SCTP_INP_RUNLOCK(inp);
1683 if (inp->def_vrf_id == vrf_id)
1686 SCTP_INP_RUNLOCK(inp);
1689 return (inp);
1691 SCTP_INP_RUNLOCK(inp);
1717 LIST_FOREACH(inp, head, sctp_hash) {
1718 SCTP_INP_RLOCK(inp);
1719 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1720 SCTP_INP_RUNLOCK(inp);
1723 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL)) {
1724 SCTP_INP_RUNLOCK(inp);
1731 if (inp->sctp_lport != lport) {
1732 SCTP_INP_RUNLOCK(inp);
1737 if (inp->def_vrf_id == vrf_id)
1741 SCTP_INP_RUNLOCK(inp);
1744 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1763 SCTP_INP_RUNLOCK(inp);
1764 return (inp);
1773 SCTP_INP_RUNLOCK(inp);
1774 return (inp);
1781 SCTP_INP_RUNLOCK(inp);
1787 sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id)
1810 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
1814 /* inp is BOUND_V4 no conflict */
1822 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1823 SCTP_IPV6_V6ONLY(inp)) {
1835 sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp)
1842 SCTP_INP_WLOCK_ASSERT(inp);
1844 if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) {
1848 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) == 0) {
1851 SCTP_INP_WUNLOCK(inp);
1852 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport,
1856 if (tinp->sctp_lport != inp->sctp_lport) {
1875 SCTP_INP_WLOCK(inp);
1877 LIST_REMOVE(inp, sctp_hash);
1878 inp->sctp_flags &= ~SCTP_PCB_FLAGS_IN_TCPPOOL;
1879 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))];
1880 LIST_INSERT_HEAD(head, inp, sctp_hash);
1892 struct sctp_inpcb *inp;
1930 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1942 if (inp == NULL && find_tcp_pool) {
1945 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1946 if (inp) {
1951 if (inp) {
1952 SCTP_INP_INCR_REF(inp);
1957 return (inp);
1970 struct sctp_inpcb *inp = NULL;
1979 stcb = sctp_tcb_special_locate(&inp, from, to, netp,
1987 inp = sctp_pcb_findep(to, 0, 1, vrf_id);
1989 *inp_p = inp;
1992 if (inp == NULL) {
2005 stcb = sctp_findassociation_ep_addr(&inp, from, netp, to,
2216 struct sctp_inpcb *inp;
2230 inp = *inp_p;
2232 stcb = sctp_findassociation_addr_sa(src, dst, &inp, netp,
2235 SCTPDBG(SCTP_DEBUG_PCB1, "stcb:%p inp:%p\n", (void *)stcb, (void *)inp);
2236 if (stcb == NULL && inp) {
2248 if (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) {
2255 offset, sh, &inp, netp, dst);
2257 *inp_p = inp;
2387 struct sctp_inpcb *inp;
2395 inp = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_ep), struct sctp_inpcb);
2396 if (inp == NULL) {
2399 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2403 memset(inp, 0, sizeof(*inp));
2407 inp->sctp_socket = so;
2408 inp->ip_inp.inp.inp_socket = so;
2409 inp->ip_inp.inp.inp_cred = crhold(so->so_cred);
2413 inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL;
2416 inp->ip_inp.inp.inp_flags |= IN6P_IPV6_V6ONLY;
2420 inp->sctp_associd_counter = 1;
2421 inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT;
2422 inp->sctp_frag_point = 0;
2423 inp->max_cwnd = 0;
2424 inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off);
2425 inp->ecn_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_ecn_enable);
2426 inp->prsctp_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pr_enable);
2427 inp->auth_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_auth_enable);
2428 inp->asconf_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_asconf_enable);
2429 inp->reconfig_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_reconfig_enable);
2430 inp->nrsack_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_nrsack_enable);
2431 inp->pktdrop_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
2432 inp->idata_supported = 0;
2433 inp->rcv_edmid = SCTP_EDMID_NONE;
2435 inp->fibnum = so->so_fibnum;
2437 inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark);
2438 if (inp->sctp_asocidhash == NULL) {
2439 crfree(inp->ip_inp.inp.inp_cred);
2440 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2445 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
2448 so->so_pcb = (caddr_t)inp;
2452 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
2458 inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE |
2469 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EOPNOTSUPP);
2471 crfree(inp->ip_inp.inp.inp_cred);
2472 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2476 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2477 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2479 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2480 sctp_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2482 sctp_feature_off(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2483 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2485 inp->sctp_tcbhash = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_pcbtblsize),
2486 &inp->sctp_hashmark);
2487 if (inp->sctp_tcbhash == NULL) {
2489 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2491 crfree(inp->ip_inp.inp.inp_cred);
2492 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2495 inp->def_vrf_id = vrf_id;
2498 SCTP_INP_LOCK_INIT(inp);
2499 rw_init_flags(&inp->ip_inp.inp.inp_lock, "sctpinp",
2501 SCTP_INP_READ_LOCK_INIT(inp);
2502 SCTP_ASOC_CREATE_LOCK_INIT(inp);
2504 SCTP_INP_WLOCK(inp);
2507 LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list);
2510 TAILQ_INIT(&inp->read_queue);
2511 LIST_INIT(&inp->sctp_addr_list);
2513 LIST_INIT(&inp->sctp_asoc_list);
2517 LIST_INIT(&inp->sctp_asoc_free_list);
2520 SCTP_OS_TIMER_INIT(&inp->sctp_ep.signature_change.timer);
2521 inp->sctp_ep.signature_change.type = SCTP_TIMER_TYPE_NEWCOOKIE;
2524 m = &inp->sctp_ep;
2578 sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);
2587 if (inp->asconf_supported) {
2600 SCTP_INP_WUNLOCK(inp);
2602 sctp_log_closing(inp, NULL, 12);
2626 new_inp->ip_inp.inp.inp_flags |= old_inp->ip_inp.inp.inp_flags & INP_CONTROLOPTS;
2627 if (old_inp->ip_inp.inp.in6p_outputopts) {
2628 new_inp->ip_inp.inp.in6p_outputopts = ip6_copypktopts(old_inp->ip_inp.inp.in6p_outputopts, M_NOWAIT);
2637 new_inp->ip_inp.inp.inp_ip_tos = old_inp->ip_inp.inp.inp_ip_tos;
2638 new_inp->ip_inp.inp.inp_ip_ttl = old_inp->ip_inp.inp.inp_ip_ttl;
2822 sctp_inpcb_bind_locked(struct sctp_inpcb *inp, struct sockaddr *addr,
2840 ip_inp = &inp->ip_inp.inp;
2843 SCTP_INP_WLOCK_ASSERT(inp);
2853 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
2856 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2867 if (SCTP_IPV6_V6ONLY(inp)) {
2869 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2874 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2886 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2907 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2917 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
2918 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2926 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2937 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2942 vrf_id = inp->def_vrf_id;
2954 SCTP_INP_INCR_REF(inp);
2955 SCTP_INP_WUNLOCK(inp);
2957 vrf_id = inp->def_vrf_id;
2963 * NEVER be inp. And it is this inp
2969 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
2978 SCTP_INP_WLOCK(inp);
2979 SCTP_INP_DECR_REF(inp);
2981 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2990 * NEVER be inp. And it is this inp
2996 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3005 SCTP_INP_WLOCK(inp);
3006 SCTP_INP_DECR_REF(inp);
3008 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3013 SCTP_INP_WLOCK(inp);
3014 SCTP_INP_DECR_REF(inp);
3018 (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id))) {
3020 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3025 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3039 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3056 candidate = first + sctp_select_initial_TSN(&inp->sctp_ep) % (count);
3059 if (sctp_isport_inuse(inp, htons(candidate), inp->def_vrf_id) == NULL) {
3065 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3074 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE |
3081 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3087 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUNDALL;
3090 sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3091 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3093 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3094 sctp_feature_on(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3097 sctp_feature_off(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3099 sctp_feature_on(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3106 sctp_mobility_feature_off(inp, SCTP_MOBILITY_BASE);
3107 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3109 sctp_mobility_feature_on(inp, SCTP_MOBILITY_BASE);
3110 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3117 sctp_mobility_feature_off(inp, SCTP_MOBILITY_FASTHANDOFF);
3118 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3120 sctp_mobility_feature_on(inp, SCTP_MOBILITY_FASTHANDOFF);
3121 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3172 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3181 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3187 inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUNDALL;
3189 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3191 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3194 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0);
3197 inp->laddr_count++;
3203 inp->sctp_flags |= SCTP_PCB_FLAGS_IN_TCPPOOL;
3208 LIST_INSERT_HEAD(head, inp, sctp_hash);
3212 inp->sctp_lport = lport;
3215 KASSERT((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) != 0,
3216 ("%s: inp %p is already bound", __func__, inp));
3217 inp->sctp_flags &= ~SCTP_PCB_FLAGS_UNBOUND;
3226 struct sctp_inpcb *inp;
3229 inp = so->so_pcb;
3231 SCTP_INP_WLOCK(inp);
3232 error = sctp_inpcb_bind_locked(inp, addr, sctp_ifap, td);
3233 SCTP_INP_WUNLOCK(inp);
3239 sctp_iterator_inp_being_freed(struct sctp_inpcb *inp)
3252 if (it && (it->inp == inp)) {
3256 * iterator will try to operate on inp. We need to stop that
3258 * reference on the stcb and inp. We can mark it and it will
3263 * next inp.
3273 * Now go through and remove any single reference to our inp that
3281 if (it->inp == inp) {
3282 /* This one points to me is it inp specific? */
3292 it->inp = LIST_NEXT(it->inp, sctp_list);
3293 if (it->inp) {
3294 SCTP_INP_INCR_REF(it->inp);
3301 SCTP_INP_DECR_REF(inp);
3309 sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
3329 sctp_log_closing(inp, NULL, 0);
3333 sctp_iterator_inp_being_freed(inp);
3336 SCTP_ASOC_CREATE_LOCK(inp);
3338 SCTP_INP_WLOCK(inp);
3339 so = inp->sctp_socket;
3340 KASSERT((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) != 0,
3341 ("%s: inp %p still has socket", __func__, inp));
3342 KASSERT((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) == 0,
3343 ("%s: double free of inp %p", __func__, inp));
3345 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CLOSE_IP;
3347 inp->sctp_flags |= SCTP_PCB_FLAGS_DONT_WAKE;
3348 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
3349 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
3352 sctp_timer_stop(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL,
3355 if (inp->control) {
3356 sctp_m_freem(inp->control);
3357 inp->control = NULL;
3359 if (inp->pkt) {
3360 sctp_m_freem(inp->pkt);
3361 inp->pkt = NULL;
3363 ip_pcb = &inp->ip_inp.inp; /* we could just cast the main pointer
3370 LIST_FOREACH_SAFE(stcb, &inp->sctp_asoc_list, sctp_tcblist, nstcb) {
3386 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
3401 if (sctp_free_assoc(inp, stcb, SCTP_PCBFREE_NOFORCE,
3421 if (sctp_free_assoc(inp, stcb,
3455 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED);
3477 if (sctp_free_assoc(inp, stcb,
3484 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
3493 sctp_log_closing(inp, NULL, 2);
3495 inp->sctp_socket = NULL;
3496 SCTP_INP_WUNLOCK(inp);
3497 SCTP_ASOC_CREATE_UNLOCK(inp);
3502 inp->sctp_socket = NULL;
3503 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
3508 LIST_REMOVE(inp, sctp_hash);
3509 inp->sctp_flags |= SCTP_PCB_FLAGS_UNBOUND;
3517 LIST_FOREACH_SAFE(stcb, &inp->sctp_asoc_list, sctp_tcblist, nstcb) {
3527 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
3551 if (sctp_free_assoc(inp, stcb, SCTP_PCBFREE_FORCE,
3559 sctp_log_closing(inp, NULL, 3);
3561 SCTP_INP_WUNLOCK(inp);
3562 SCTP_ASOC_CREATE_UNLOCK(inp);
3566 if (SCTP_INP_LOCK_CONTENDED(inp))
3568 if (SCTP_INP_READ_CONTENDED(inp))
3570 if (SCTP_ASOC_CREATE_LOCK_CONTENDED(inp))
3573 if ((inp->refcount) ||
3575 (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) {
3577 sctp_log_closing(inp, NULL, 4);
3579 sctp_timer_start(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL);
3580 SCTP_INP_WUNLOCK(inp);
3581 SCTP_ASOC_CREATE_UNLOCK(inp);
3585 inp->sctp_ep.signature_change.type = 0;
3586 inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_ALLGONE;
3590 LIST_REMOVE(inp, sctp_list);
3591 SCTP_INP_WUNLOCK(inp);
3592 SCTP_ASOC_CREATE_UNLOCK(inp);
3596 sctp_log_closing(inp, NULL, 5);
3598 if ((inp->sctp_asocidhash) != NULL) {
3599 SCTP_HASH_FREE(inp->sctp_asocidhash, inp->hashasocidmark);
3600 inp->sctp_asocidhash = NULL;
3603 TAILQ_FOREACH_SAFE(sq, &inp->read_queue, next, nsq) {
3608 TAILQ_REMOVE(&inp->read_queue, sq, next);
3639 if (inp->sctp_ep.local_auth_chunks != NULL)
3640 sctp_free_chunklist(inp->sctp_ep.local_auth_chunks);
3641 if (inp->sctp_ep.local_hmacs != NULL)
3642 sctp_free_hmaclist(inp->sctp_ep.local_hmacs);
3644 LIST_FOREACH_SAFE(shared_key, &inp->sctp_ep.shared_keys, next, nshared_key) {
3655 LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
3661 LIST_FOREACH_SAFE(stcb, &inp->sctp_asoc_free_list, sctp_tcblist, nstcb) {
3669 if (inp->sctp_tcbhash != NULL) {
3670 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
3671 inp->sctp_tcbhash = NULL;
3674 crfree(inp->ip_inp.inp.inp_cred);
3675 INP_LOCK_DESTROY(&inp->ip_inp.inp);
3676 SCTP_INP_LOCK_DESTROY(inp);
3677 SCTP_INP_READ_LOCK_DESTROY(inp);
3678 SCTP_ASOC_CREATE_LOCK_DESTROY(inp);
3679 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
4132 sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
4139 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
4147 if (inp->sctp_associd_counter <= SCTP_ALL_ASSOC) {
4148 inp->sctp_associd_counter = SCTP_ALL_ASSOC + 1;
4150 id = inp->sctp_associd_counter;
4151 inp->sctp_associd_counter++;
4152 lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t)id, 0);
4156 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
4168 sctp_aloc_assoc_locked(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4183 SCTP_INP_WLOCK_ASSERT(inp);
4192 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4197 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4201 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
4202 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4206 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) &&
4207 ((sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) ||
4208 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) {
4215 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4219 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
4220 (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) {
4221 if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) ||
4222 (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED)) {
4223 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4263 ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
4264 (SCTP_IPV6_V6ONLY(inp) != 0))) {
4266 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4283 ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0)) {
4285 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4295 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4299 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) {
4304 if ((err = sctp_inpcb_bind_locked(inp, NULL, NULL, p))) {
4313 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
4325 stcb->sctp_ep = inp;
4326 stcb->sctp_socket = inp->sctp_socket;
4327 if ((err = sctp_init_asoc(inp, stcb, override_tag, initial_tsn, vrf_id, o_streams))) {
4337 asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
4363 SCTP_INP_WUNLOCK(inp);
4364 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4376 LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist);
4378 if (inp->sctp_tcbhash != NULL) {
4379 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(stcb->rport,
4380 inp->sctp_hashmark)];
4384 sctp_initialize_auth_params(inp, stcb);
4391 sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4400 SCTP_INP_WLOCK(inp);
4401 stcb = sctp_aloc_assoc_locked(inp, firstaddr, error, override_tag,
4404 SCTP_INP_WUNLOCK(inp);
4409 sctp_aloc_assoc_connected(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4418 SCTP_INP_WLOCK(inp);
4419 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) &&
4420 SCTP_IS_LISTENING(inp)) {
4422 SCTP_INP_WUNLOCK(inp);
4426 stcb = sctp_aloc_assoc_locked(inp, firstaddr, error, override_tag,
4429 if (stcb != NULL && (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) {
4430 inp->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED;
4431 soisconnecting(inp->sctp_socket);
4433 SCTP_INP_WUNLOCK(inp);
4440 struct sctp_inpcb *inp;
4443 inp = stcb->sctp_ep;
4495 sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net,
4497 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net,
4680 sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfree, int from_location)
4699 sctp_log_closing(inp, stcb, 6);
4703 sctp_log_closing(inp, NULL, 7);
4720 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4721 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4725 so = inp->sctp_socket;
4740 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4744 sctp_log_closing(inp, stcb, 8);
4754 SCTP_INP_READ_LOCK(inp);
4755 TAILQ_FOREACH(sq, &inp->read_queue, next) {
4767 if (sctp_stcb_is_feature_on(inp, stcb, SCTP_PCB_FLAGS_PDAPIEVNT) && (so != NULL)) {
4779 SCTP_INP_READ_UNLOCK(inp);
4781 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PCB, ECONNRESET);
4792 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4793 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
4795 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4797 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4798 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4803 sctp_sorwakeup(inp, so);
4804 sctp_sowwakeup(inp, so);
4809 sctp_log_closing(inp, stcb, 9);
4815 sctp_log_closing(inp, stcb, 10);
4832 SCTP_INP_WLOCK(inp);
4836 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4837 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4841 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
4842 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
4847 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
4848 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
4849 inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
4858 sctp_sowwakeup(inp, so);
4859 sctp_sorwakeup(inp, so);
4875 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4878 SCTP_INP_WUNLOCK(inp);
4884 if (inp->sctp_tcbhash) {
4890 if (inp->sctp_socket == NULL) {
4896 SCTP_INP_INCR_REF(inp);
4897 SCTP_INP_WUNLOCK(inp);
4901 sctp_add_vtag_to_timewait(asoc->my_vtag, inp->sctp_lport, stcb->rport);
5148 SCTP_INP_RLOCK(inp);
5151 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5156 LIST_INSERT_HEAD(&inp->sctp_asoc_free_list, stcb, sctp_tcblist);
5163 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5168 SCTP_INP_RUNLOCK(inp);
5176 sctp_inpcb_free(inp,
5179 SCTP_INP_DECR_REF(inp);
5182 SCTP_INP_DECR_REF(inp);
5183 SCTP_INP_RUNLOCK(inp);
5188 sctp_log_closing(inp, NULL, 11);
5205 struct sctp_inpcb *inp;
5218 inp = stcb->sctp_ep;
5219 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5232 answer = inp->ip_inp.inp.inp_vflag & INP_IPV6;
5237 answer = inp->ip_inp.inp.inp_vflag & INP_IPV4;
5252 sctp_update_ep_vflag(struct sctp_inpcb *inp)
5257 inp->ip_inp.inp.inp_vflag = 0;
5259 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5272 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5277 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5291 sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
5299 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5312 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5321 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, action);
5324 inp->laddr_count++;
5329 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5334 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5340 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5375 sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
5381 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5385 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5391 if (fnd && (inp->laddr_count < 2)) {
5405 if (inp->next_addr_touse == laddr)
5407 inp->next_addr_touse = NULL;
5410 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5434 inp->laddr_count--;
5436 sctp_update_ep_vflag(inp);
5484 struct sctp_inpcb *inp;
5497 inp = stcb->sctp_ep;
5499 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) &&
5500 sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
5993 struct sctp_inpcb *inp;
6061 inp = stcb->sctp_ep;
6063 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb);
6066 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
6144 inp = stcb->sctp_ep;
6146 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6150 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
6151 inp == NULL) {
6243 inp = stcb->sctp_ep;
6245 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6249 (inp == stcb->sctp_ep || inp == NULL)) {
6970 struct sctp_inpcb *inp;
6983 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
6985 SCTP_INP_RLOCK(inp);
6986 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
6992 SCTP_INP_RUNLOCK(inp);
7010 * iterated through. inpe (optional) is called when the inp completes
7060 it->inp = s_inp;
7061 SCTP_INP_INCR_REF(it->inp);
7065 it->inp = LIST_FIRST(&SCTP_BASE_INFO(listhead));
7066 if (it->inp) {
7067 SCTP_INP_INCR_REF(it->inp);
7090 * Atomically add flags to the sctp_flags of an inp.
7091 * To be used when the write lock of the inp is not held.
7094 sctp_pcb_add_flags(struct sctp_inpcb *inp, uint32_t flags)
7099 old_flags = inp->sctp_flags;
7101 } while (atomic_cmpset_int(&inp->sctp_flags, old_flags, new_flags) == 0);