Lines Matching refs:inp

903 						if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred,
922 if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred,
1024 struct sctp_inpcb *inp;
1063 LIST_FOREACH(inp, ephead, sctp_hash) {
1064 SCTP_INP_RLOCK(inp);
1065 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1066 SCTP_INP_RUNLOCK(inp);
1069 if (lport != inp->sctp_lport) {
1070 SCTP_INP_RUNLOCK(inp);
1080 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
1082 SCTP_INP_RUNLOCK(inp);
1094 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
1096 SCTP_INP_RUNLOCK(inp);
1103 SCTP_INP_RUNLOCK(inp);
1106 if (inp->def_vrf_id != vrf_id) {
1107 SCTP_INP_RUNLOCK(inp);
1111 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
1115 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1162 SCTP_INP_RUNLOCK(inp);
1171 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1173 SCTP_INP_RUNLOCK(inp);
1179 SCTP_INP_RUNLOCK(inp);
1185 SCTP_INP_RUNLOCK(inp);
1190 SCTP_INP_RUNLOCK(inp);
1195 SCTP_INP_RUNLOCK(inp);
1223 *inp_p = inp;
1224 SCTP_INP_RUNLOCK(inp);
1247 *inp_p = inp;
1248 SCTP_INP_RUNLOCK(inp);
1260 SCTP_INP_RUNLOCK(inp);
1280 struct sctp_inpcb *inp;
1285 inp = *inp_p;
1309 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
1310 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
1316 * and find the real inp.
1318 if ((inp->sctp_socket) && (inp->sctp_socket->so_qlimit)) {
1321 netp, inp->def_vrf_id);
1324 SCTP_INP_DECR_REF(inp);
1335 SCTP_INP_WLOCK(inp);
1336 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1339 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1387 SCTP_INP_DECR_REF(inp);
1394 SCTP_INP_WUNLOCK(inp);
1416 SCTP_INP_DECR_REF(inp);
1423 SCTP_INP_WUNLOCK(inp);
1438 SCTP_INP_WLOCK(inp);
1439 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1442 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(rport,
1443 inp->sctp_hashmark)];
1487 SCTP_INP_DECR_REF(inp);
1494 SCTP_INP_WUNLOCK(inp);
1517 SCTP_INP_DECR_REF(inp);
1524 SCTP_INP_WUNLOCK(inp);
1545 SCTP_INP_WUNLOCK(inp);
1557 sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1566 if (inp == NULL) {
1570 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1575 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
1583 if (inp != stcb->sctp_ep) {
1605 sctp_findassociation_ep_asocid(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1609 SCTP_INP_RLOCK(inp);
1610 stcb = sctp_findasoc_ep_asocid_locked(inp, asoc_id, want_lock);
1611 SCTP_INP_RUNLOCK(inp);
1623 struct sctp_inpcb *inp;
1662 LIST_FOREACH(inp, head, sctp_hash) {
1663 SCTP_INP_RLOCK(inp);
1664 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1665 SCTP_INP_RUNLOCK(inp);
1668 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) &&
1669 (inp->sctp_lport == lport)) {
1674 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1675 SCTP_IPV6_V6ONLY(inp)) {
1680 SCTP_INP_RUNLOCK(inp);
1683 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
1685 SCTP_INP_RUNLOCK(inp);
1696 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) {
1697 SCTP_INP_RUNLOCK(inp);
1700 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
1702 SCTP_INP_RUNLOCK(inp);
1712 if (inp->def_vrf_id == vrf_id)
1715 SCTP_INP_RUNLOCK(inp);
1718 return (inp);
1720 SCTP_INP_RUNLOCK(inp);
1746 LIST_FOREACH(inp, head, sctp_hash) {
1747 SCTP_INP_RLOCK(inp);
1748 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1749 SCTP_INP_RUNLOCK(inp);
1752 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL)) {
1753 SCTP_INP_RUNLOCK(inp);
1760 if (inp->sctp_lport != lport) {
1761 SCTP_INP_RUNLOCK(inp);
1766 if (inp->def_vrf_id == vrf_id)
1770 SCTP_INP_RUNLOCK(inp);
1773 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1792 SCTP_INP_RUNLOCK(inp);
1793 return (inp);
1802 SCTP_INP_RUNLOCK(inp);
1803 return (inp);
1810 SCTP_INP_RUNLOCK(inp);
1817 sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id)
1840 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
1844 /* inp is BOUND_V4 no conflict */
1852 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1853 SCTP_IPV6_V6ONLY(inp)) {
1866 sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp)
1872 if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) {
1876 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) == 0) {
1879 SCTP_INP_RUNLOCK(inp);
1881 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport,
1885 if (tinp->sctp_lport != inp->sctp_lport) {
1904 SCTP_INP_WLOCK(inp);
1906 LIST_REMOVE(inp, sctp_hash);
1907 inp->sctp_flags &= ~SCTP_PCB_FLAGS_IN_TCPPOOL;
1908 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))];
1909 LIST_INSERT_HEAD(head, inp, sctp_hash);
1910 SCTP_INP_WUNLOCK(inp);
1911 SCTP_INP_RLOCK(inp);
1925 struct sctp_inpcb *inp;
1966 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1978 if (inp == NULL && find_tcp_pool) {
1981 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1982 if (inp) {
1987 if (inp) {
1988 SCTP_INP_INCR_REF(inp);
1993 return (inp);
2007 struct sctp_inpcb *inp = NULL;
2016 stcb = sctp_tcb_special_locate(&inp, from, to, netp,
2024 inp = sctp_pcb_findep(to, 0, 1, vrf_id);
2026 *inp_p = inp;
2029 if (inp == NULL) {
2042 stcb = sctp_findassociation_ep_addr(&inp, from, netp, to,
2260 struct sctp_inpcb *inp;
2273 inp = *inp_p;
2275 stcb = sctp_findassociation_addr_sa(src, dst, &inp, netp,
2278 SCTPDBG(SCTP_DEBUG_PCB1, "stcb:%p inp:%p\n", (void *)stcb, (void *)inp);
2279 if (stcb == NULL && inp) {
2291 if (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) {
2298 offset, sh, &inp, netp, dst);
2300 *inp_p = inp;
2434 struct sctp_inpcb *inp;
2442 inp = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_ep), struct sctp_inpcb);
2443 if (inp == NULL) {
2446 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2450 bzero(inp, sizeof(*inp));
2454 inp->sctp_socket = so;
2455 inp->ip_inp.inp.inp_socket = so;
2456 inp->ip_inp.inp.inp_cred = crhold(so->so_cred);
2460 inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL;
2463 inp->ip_inp.inp.inp_flags |= IN6P_IPV6_V6ONLY;
2467 inp->sctp_associd_counter = 1;
2468 inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT;
2469 inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT;
2470 inp->max_cwnd = 0;
2471 inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off);
2472 inp->ecn_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_ecn_enable);
2473 inp->prsctp_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pr_enable);
2474 inp->auth_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_auth_enable);
2475 inp->asconf_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_asconf_enable);
2476 inp->reconfig_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_reconfig_enable);
2477 inp->nrsack_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_nrsack_enable);
2478 inp->pktdrop_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
2479 inp->idata_supported = 0;
2481 inp->fibnum = so->so_fibnum;
2483 inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark);
2484 if (inp->sctp_asocidhash == NULL) {
2485 crfree(inp->ip_inp.inp.inp_cred);
2486 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2491 error = ipsec_init_policy(so, &inp->ip_inp.inp.inp_sp);
2493 crfree(inp->ip_inp.inp.inp_cred);
2494 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2500 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
2503 so->so_pcb = (caddr_t)inp;
2507 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
2513 inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE |
2522 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EOPNOTSUPP);
2524 crfree(inp->ip_inp.inp.inp_cred);
2526 ipsec_delete_pcbpolicy(&inp->ip_inp.inp);
2528 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2532 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2533 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2535 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2536 sctp_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2538 sctp_feature_off(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2539 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2541 inp->sctp_tcbhash = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_pcbtblsize),
2542 &inp->sctp_hashmark);
2543 if (inp->sctp_tcbhash == NULL) {
2545 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2547 crfree(inp->ip_inp.inp.inp_cred);
2549 ipsec_delete_pcbpolicy(&inp->ip_inp.inp);
2551 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2554 inp->def_vrf_id = vrf_id;
2557 SCTP_INP_LOCK_INIT(inp);
2558 INP_LOCK_INIT(&inp->ip_inp.inp, "inp", "sctpinp");
2559 SCTP_INP_READ_INIT(inp);
2560 SCTP_ASOC_CREATE_LOCK_INIT(inp);
2562 SCTP_INP_WLOCK(inp);
2565 LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list);
2568 TAILQ_INIT(&inp->read_queue);
2569 LIST_INIT(&inp->sctp_addr_list);
2571 LIST_INIT(&inp->sctp_asoc_list);
2575 LIST_INIT(&inp->sctp_asoc_free_list);
2578 SCTP_OS_TIMER_INIT(&inp->sctp_ep.signature_change.timer);
2579 inp->sctp_ep.signature_change.type = SCTP_TIMER_TYPE_NEWCOOKIE;
2582 m = &inp->sctp_ep;
2635 sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);
2644 if (inp->asconf_supported) {
2657 SCTP_INP_WUNLOCK(inp);
2659 sctp_log_closing(inp, NULL, 12);
2835 struct sctp_inpcb *inp, *inp_tmp;
2845 inp = (struct sctp_inpcb *)so->so_pcb;
2855 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
2857 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2873 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2877 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2888 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2909 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2919 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
2920 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2927 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2937 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EAFNOSUPPORT);
2942 SCTP_INP_WLOCK(inp);
2944 vrf_id = inp->def_vrf_id;
2947 SCTP_INP_INCR_REF(inp);
2958 SCTP_INP_DECR_REF(inp);
2959 SCTP_INP_WUNLOCK(inp);
2964 SCTP_INP_WUNLOCK(inp);
2966 vrf_id = inp->def_vrf_id;
2972 * NEVER be inp. And it is this inp
2978 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
2987 SCTP_INP_DECR_REF(inp);
2989 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
2998 * NEVER be inp. And it is this inp
3004 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3013 SCTP_INP_DECR_REF(inp);
3015 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3020 SCTP_INP_WLOCK(inp);
3024 (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id))) {
3026 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3030 SCTP_INP_DECR_REF(inp);
3031 SCTP_INP_WUNLOCK(inp);
3033 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3050 SCTP_INP_DECR_REF(inp);
3051 SCTP_INP_WUNLOCK(inp);
3053 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3070 candidate = first + sctp_select_initial_TSN(&inp->sctp_ep) % (count);
3074 if (sctp_isport_inuse(inp, htons(candidate), inp->def_vrf_id) == NULL) {
3079 SCTP_INP_DECR_REF(inp);
3080 SCTP_INP_WUNLOCK(inp);
3082 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3093 SCTP_INP_DECR_REF(inp);
3094 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE |
3100 SCTP_INP_WUNLOCK(inp);
3102 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3108 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUNDALL;
3111 sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3112 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3114 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3115 sctp_feature_on(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3118 sctp_feature_off(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3120 sctp_feature_on(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3127 sctp_mobility_feature_off(inp, SCTP_MOBILITY_BASE);
3128 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3130 sctp_mobility_feature_on(inp, SCTP_MOBILITY_BASE);
3131 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3138 sctp_mobility_feature_off(inp, SCTP_MOBILITY_FASTHANDOFF);
3139 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3141 sctp_mobility_feature_on(inp, SCTP_MOBILITY_FASTHANDOFF);
3142 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3193 SCTP_INP_WUNLOCK(inp);
3195 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRNOTAVAIL);
3203 SCTP_INP_WUNLOCK(inp);
3205 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3211 inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUNDALL;
3213 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3215 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3218 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0);
3220 SCTP_INP_WUNLOCK(inp);
3224 inp->laddr_count++;
3230 inp->sctp_flags |= SCTP_PCB_FLAGS_IN_TCPPOOL;
3235 LIST_INSERT_HEAD(head, inp, sctp_hash);
3239 inp->sctp_lport = lport;
3242 inp->sctp_flags &= ~SCTP_PCB_FLAGS_UNBOUND;
3243 SCTP_INP_WUNLOCK(inp);
3250 sctp_iterator_inp_being_freed(struct sctp_inpcb *inp)
3263 if (it && (it->inp == inp)) {
3267 * iterator will try to operate on inp. We need to stop that
3269 * reference on the stcb and inp. We can mark it and it will
3274 * inp.
3284 * Now go through and remove any single reference to our inp that
3292 if (it->inp == inp) {
3293 /* This one points to me is it inp specific? */
3303 it->inp = LIST_NEXT(it->inp, sctp_list);
3304 if (it->inp) {
3305 SCTP_INP_INCR_REF(it->inp);
3312 SCTP_INP_DECR_REF(inp);
3320 sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
3341 sctp_log_closing(inp, NULL, 0);
3345 sctp_iterator_inp_being_freed(inp);
3347 so = inp->sctp_socket;
3348 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
3352 sctp_log_closing(inp, NULL, 1);
3356 SCTP_ASOC_CREATE_LOCK(inp);
3359 SCTP_INP_WLOCK(inp);
3361 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CLOSE_IP;
3363 inp->sctp_flags |= SCTP_PCB_FLAGS_DONT_WAKE;
3364 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
3365 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
3369 sctp_timer_stop(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL,
3372 if (inp->control) {
3373 sctp_m_freem(inp->control);
3374 inp->control = NULL;
3376 if (inp->pkt) {
3377 sctp_m_freem(inp->pkt);
3378 inp->pkt = NULL;
3380 ip_pcb = &inp->ip_inp.inp; /* we could just cast the main pointer
3387 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3400 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3415 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_NOFORCE,
3439 if (sctp_free_assoc(inp, asoc,
3475 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED);
3499 if (sctp_free_assoc(inp, asoc,
3506 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
3515 sctp_log_closing(inp, NULL, 2);
3517 inp->sctp_socket = NULL;
3518 SCTP_INP_WUNLOCK(inp);
3519 SCTP_ASOC_CREATE_UNLOCK(inp);
3524 inp->sctp_socket = NULL;
3525 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) !=
3531 LIST_REMOVE(inp, sctp_hash);
3532 inp->sctp_flags |= SCTP_PCB_FLAGS_UNBOUND;
3539 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3544 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3568 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_FORCE,
3575 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3577 sctp_log_closing(inp, NULL, 3);
3579 SCTP_INP_WUNLOCK(inp);
3580 SCTP_ASOC_CREATE_UNLOCK(inp);
3584 if (SCTP_INP_LOCK_CONTENDED(inp))
3586 if (SCTP_INP_READ_CONTENDED(inp))
3588 if (SCTP_ASOC_CREATE_LOCK_CONTENDED(inp))
3591 if ((inp->refcount) ||
3593 (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) {
3594 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3596 sctp_log_closing(inp, NULL, 4);
3598 sctp_timer_start(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL);
3599 SCTP_INP_WUNLOCK(inp);
3600 SCTP_ASOC_CREATE_UNLOCK(inp);
3604 inp->sctp_ep.signature_change.type = 0;
3605 inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_ALLGONE;
3609 LIST_REMOVE(inp, sctp_list);
3610 SCTP_INP_WUNLOCK(inp);
3611 SCTP_ASOC_CREATE_UNLOCK(inp);
3621 (void)SCTP_OS_TIMER_STOP_DRAIN(&inp->sctp_ep.signature_change.timer);
3624 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3628 sctp_log_closing(inp, NULL, 5);
3632 if ((inp->sctp_asocidhash) != NULL) {
3633 SCTP_HASH_FREE(inp->sctp_asocidhash, inp->hashasocidmark);
3634 inp->sctp_asocidhash = NULL;
3637 TAILQ_FOREACH_SAFE(sq, &inp->read_queue, next, nsq) {
3642 TAILQ_REMOVE(&inp->read_queue, sq, next);
3673 in6p = (struct in6pcb *)inp;
3679 if (inp->sctp_ep.local_auth_chunks != NULL)
3680 sctp_free_chunklist(inp->sctp_ep.local_auth_chunks);
3681 if (inp->sctp_ep.local_hmacs != NULL)
3682 sctp_free_hmaclist(inp->sctp_ep.local_hmacs);
3684 LIST_FOREACH_SAFE(shared_key, &inp->sctp_ep.shared_keys, next, nshared_key) {
3695 LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
3701 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_free_list, sctp_tcblist, nasoc) {
3709 if (inp->sctp_tcbhash != NULL) {
3710 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
3711 inp->sctp_tcbhash = NULL;
3714 crfree(inp->ip_inp.inp.inp_cred);
3715 INP_LOCK_DESTROY(&inp->ip_inp.inp);
3716 SCTP_INP_LOCK_DESTROY(inp);
3717 SCTP_INP_READ_DESTROY(inp);
3718 SCTP_ASOC_CREATE_LOCK_DESTROY(inp);
3719 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
4142 sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
4148 SCTP_INP_WLOCK(inp);
4150 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
4152 SCTP_INP_WUNLOCK(inp);
4159 if (inp->sctp_associd_counter <= SCTP_ALL_ASSOC) {
4160 inp->sctp_associd_counter = SCTP_ALL_ASSOC + 1;
4162 id = inp->sctp_associd_counter;
4163 inp->sctp_associd_counter++;
4164 lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t) id, 0);
4168 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
4171 SCTP_INP_WUNLOCK(inp);
4181 sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4202 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4207 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4211 SCTP_INP_RLOCK(inp);
4212 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) &&
4213 ((sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) ||
4214 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) {
4221 SCTP_INP_RUNLOCK(inp);
4222 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4226 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
4227 (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) {
4228 if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) ||
4229 (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED)) {
4230 SCTP_INP_RUNLOCK(inp);
4231 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4272 SCTP_INP_RUNLOCK(inp);
4273 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4291 SCTP_INP_RUNLOCK(inp);
4292 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4302 SCTP_INP_RUNLOCK(inp);
4303 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4307 SCTP_INP_RUNLOCK(inp);
4308 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) {
4313 if ((err = sctp_inpcb_bind(inp->sctp_socket,
4326 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
4335 asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
4340 stcb->sctp_ep = inp;
4341 stcb->sctp_socket = inp->sctp_socket;
4342 if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id, o_streams))) {
4354 SCTP_INP_WLOCK(inp);
4355 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
4361 SCTP_INP_WUNLOCK(inp);
4364 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4396 SCTP_INP_WUNLOCK(inp);
4397 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4410 LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist);
4412 if (inp->sctp_tcbhash != NULL) {
4413 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(stcb->rport,
4414 inp->sctp_hashmark)];
4417 SCTP_INP_WUNLOCK(inp);
4692 sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfree, int from_location)
4710 sctp_log_closing(inp, stcb, 6);
4714 sctp_log_closing(inp, NULL, 7);
4731 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4732 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4736 so = inp->sctp_socket;
4751 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4755 sctp_log_closing(inp, stcb, 8);
4794 SCTP_INP_READ_LOCK(inp);
4795 TAILQ_FOREACH(sq, &inp->read_queue, next) {
4807 if (sctp_stcb_is_feature_on(inp, stcb, SCTP_PCB_FLAGS_PDAPIEVNT) && (so != NULL)) {
4832 SCTP_INP_READ_UNLOCK(inp);
4834 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PCB, ECONNRESET);
4845 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4846 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
4848 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4851 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4852 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4857 sctp_sorwakeup(inp, so);
4858 sctp_sowwakeup(inp, so);
4861 sctp_log_closing(inp, stcb, 9);
4867 sctp_log_closing(inp, stcb, 10);
4884 SCTP_INP_WLOCK(inp);
4888 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4889 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4893 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
4894 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
4899 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
4900 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
4901 inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
4911 sctp_sowwakeup(inp, so);
4912 sctp_sorwakeup(inp, so);
4927 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4930 SCTP_INP_WUNLOCK(inp);
4936 if (inp->sctp_tcbhash) {
4945 SCTP_INP_INCR_REF(inp);
4946 SCTP_INP_WUNLOCK(inp);
4951 inp->sctp_lport, stcb->rport);
5211 SCTP_INP_RLOCK(inp);
5214 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5219 LIST_INSERT_HEAD(&inp->sctp_asoc_free_list, stcb, sctp_tcblist);
5226 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5231 SCTP_INP_RUNLOCK(inp);
5239 sctp_inpcb_free(inp,
5242 SCTP_INP_DECR_REF(inp);
5246 SCTP_INP_DECR_REF(inp);
5250 SCTP_INP_RUNLOCK(inp);
5255 sctp_log_closing(inp, NULL, 11);
5274 struct sctp_inpcb *inp;
5287 inp = stcb->sctp_ep;
5288 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5301 answer = inp->ip_inp.inp.inp_vflag & INP_IPV6;
5306 answer = inp->ip_inp.inp.inp_vflag & INP_IPV4;
5321 sctp_update_ep_vflag(struct sctp_inpcb *inp)
5326 inp->ip_inp.inp.inp_vflag = 0;
5328 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5340 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5345 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5359 sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
5367 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5380 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5389 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, action);
5392 inp->laddr_count++;
5397 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5402 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5408 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5445 sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
5451 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5455 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5461 if (fnd && (inp->laddr_count < 2)) {
5475 if (inp->next_addr_touse == laddr)
5477 inp->next_addr_touse = NULL;
5480 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5511 inp->laddr_count--;
5513 sctp_update_ep_vflag(inp);
5561 struct sctp_inpcb *inp;
5574 inp = stcb->sctp_ep;
5576 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) &&
5577 sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
6071 struct sctp_inpcb *inp;
6141 inp = stcb->sctp_ep;
6143 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb);
6146 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
6224 inp = stcb->sctp_ep;
6226 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6230 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
6231 inp == NULL) {
6322 inp = stcb->sctp_ep;
6324 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6328 (inp == stcb->sctp_ep || inp == NULL)) {
7017 struct sctp_inpcb *inp;
7029 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
7031 SCTP_INP_RLOCK(inp);
7032 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
7038 SCTP_INP_RUNLOCK(inp);
7052 * iterated through. inpe (optional) is called when the inp completes
7102 it->inp = s_inp;
7103 SCTP_INP_INCR_REF(it->inp);
7107 it->inp = LIST_FIRST(&SCTP_BASE_INFO(listhead));
7108 if (it->inp) {
7109 SCTP_INP_INCR_REF(it->inp);