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,
2261 struct sctp_inpcb *inp;
2282 inp = *inp_p;
2284 stcb = sctp_findassociation_addr_sa(src, dst, &inp, netp,
2287 SCTPDBG(SCTP_DEBUG_PCB1, "stcb:%p inp:%p\n", (void *)stcb, (void *)inp);
2288 if (stcb == NULL && inp) {
2300 if (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) {
2307 offset, sh, &inp, netp, dst);
2309 *inp_p = inp;
2443 struct sctp_inpcb *inp;
2451 inp = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_ep), struct sctp_inpcb);
2452 if (inp == NULL) {
2455 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2459 bzero(inp, sizeof(*inp));
2463 inp->sctp_socket = so;
2464 inp->ip_inp.inp.inp_socket = so;
2465 inp->ip_inp.inp.inp_cred = crhold(so->so_cred);
2469 inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL;
2472 inp->ip_inp.inp.inp_flags |= IN6P_IPV6_V6ONLY;
2476 inp->sctp_associd_counter = 1;
2477 inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT;
2478 inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT;
2479 inp->max_cwnd = 0;
2480 inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off);
2481 inp->ecn_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_ecn_enable);
2482 inp->prsctp_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pr_enable);
2484 inp->auth_supported = 0;
2486 inp->auth_supported = 1;
2488 inp->asconf_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_asconf_enable);
2489 inp->reconfig_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_reconfig_enable);
2490 inp->nrsack_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_nrsack_enable);
2491 inp->pktdrop_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
2492 inp->fibnum = so->so_fibnum;
2494 inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark);
2495 if (inp->sctp_asocidhash == NULL) {
2496 crfree(inp->ip_inp.inp.inp_cred);
2497 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2507 inp->ip_inp.inp.inp_sp = pcb_sp;
2508 ((struct in6pcb *)(&inp->ip_inp.inp))->in6p_sp = pcb_sp;
2511 crfree(inp->ip_inp.inp.inp_cred);
2512 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2518 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
2521 so->so_pcb = (caddr_t)inp;
2525 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
2531 inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE |
2540 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EOPNOTSUPP);
2542 crfree(inp->ip_inp.inp.inp_cred);
2543 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2547 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2548 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2550 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2551 sctp_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2553 sctp_feature_off(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2554 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2556 inp->sctp_tcbhash = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_pcbtblsize),
2557 &inp->sctp_hashmark);
2558 if (inp->sctp_tcbhash == NULL) {
2560 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2562 crfree(inp->ip_inp.inp.inp_cred);
2563 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2566 inp->def_vrf_id = vrf_id;
2569 SCTP_INP_LOCK_INIT(inp);
2570 INP_LOCK_INIT(&inp->ip_inp.inp, "inp", "sctpinp");
2571 SCTP_INP_READ_INIT(inp);
2572 SCTP_ASOC_CREATE_LOCK_INIT(inp);
2574 SCTP_INP_WLOCK(inp);
2577 LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list);
2580 TAILQ_INIT(&inp->read_queue);
2581 LIST_INIT(&inp->sctp_addr_list);
2583 LIST_INIT(&inp->sctp_asoc_list);
2587 LIST_INIT(&inp->sctp_asoc_free_list);
2590 SCTP_OS_TIMER_INIT(&inp->sctp_ep.signature_change.timer);
2591 inp->sctp_ep.signature_change.type = SCTP_TIMER_TYPE_NEWCOOKIE;
2594 m = &inp->sctp_ep;
2647 sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);
2656 if (inp->asconf_supported) {
2669 SCTP_INP_WUNLOCK(inp);
2671 sctp_log_closing(inp, NULL, 12);
2808 struct sctp_inpcb *inp, *inp_tmp;
2818 inp = (struct sctp_inpcb *)so->so_pcb;
2828 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
2830 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2846 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2850 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2861 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2882 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2892 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
2893 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2900 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2910 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EAFNOSUPPORT);
2915 SCTP_INP_WLOCK(inp);
2917 vrf_id = inp->def_vrf_id;
2920 SCTP_INP_INCR_REF(inp);
2931 SCTP_INP_DECR_REF(inp);
2932 SCTP_INP_WUNLOCK(inp);
2937 SCTP_INP_WUNLOCK(inp);
2939 vrf_id = inp->def_vrf_id;
2945 * NEVER be inp. And it is this inp
2951 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
2960 SCTP_INP_DECR_REF(inp);
2962 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
2971 * NEVER be inp. And it is this inp
2977 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
2986 SCTP_INP_DECR_REF(inp);
2988 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
2993 SCTP_INP_WLOCK(inp);
2997 (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id))) {
2999 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3003 SCTP_INP_DECR_REF(inp);
3004 SCTP_INP_WUNLOCK(inp);
3006 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3023 SCTP_INP_DECR_REF(inp);
3024 SCTP_INP_WUNLOCK(inp);
3026 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3043 candidate = first + sctp_select_initial_TSN(&inp->sctp_ep) % (count);
3047 if (sctp_isport_inuse(inp, htons(candidate), inp->def_vrf_id) == NULL) {
3052 SCTP_INP_DECR_REF(inp);
3053 SCTP_INP_WUNLOCK(inp);
3055 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3066 SCTP_INP_DECR_REF(inp);
3067 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE |
3073 SCTP_INP_WUNLOCK(inp);
3075 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3081 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUNDALL;
3084 sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3085 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3087 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3088 sctp_feature_on(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3091 sctp_feature_off(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3093 sctp_feature_on(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3100 sctp_mobility_feature_off(inp, SCTP_MOBILITY_BASE);
3101 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3103 sctp_mobility_feature_on(inp, SCTP_MOBILITY_BASE);
3104 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3111 sctp_mobility_feature_off(inp, SCTP_MOBILITY_FASTHANDOFF);
3112 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3114 sctp_mobility_feature_on(inp, SCTP_MOBILITY_FASTHANDOFF);
3115 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3166 SCTP_INP_WUNLOCK(inp);
3168 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRNOTAVAIL);
3176 SCTP_INP_WUNLOCK(inp);
3178 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3184 inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUNDALL;
3186 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3188 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3191 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0);
3193 SCTP_INP_WUNLOCK(inp);
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 inp->sctp_flags &= ~SCTP_PCB_FLAGS_UNBOUND;
3216 SCTP_INP_WUNLOCK(inp);
3223 sctp_iterator_inp_being_freed(struct sctp_inpcb *inp)
3236 if (it && (it->inp == inp)) {
3240 * iterator will try to operate on inp. We need to stop that
3242 * reference on the stcb and inp. We can mark it and it will
3247 * inp.
3257 * Now go through and remove any single reference to our inp that
3265 if (it->inp == inp) {
3266 /* This one points to me is it inp specific? */
3276 it->inp = LIST_NEXT(it->inp, sctp_list);
3277 if (it->inp) {
3278 SCTP_INP_INCR_REF(it->inp);
3285 SCTP_INP_DECR_REF(inp);
3293 sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
3314 sctp_log_closing(inp, NULL, 0);
3318 sctp_iterator_inp_being_freed(inp);
3320 so = inp->sctp_socket;
3321 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
3325 sctp_log_closing(inp, NULL, 1);
3329 SCTP_ASOC_CREATE_LOCK(inp);
3332 SCTP_INP_WLOCK(inp);
3334 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CLOSE_IP;
3336 inp->sctp_flags |= SCTP_PCB_FLAGS_DONT_WAKE;
3337 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
3338 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
3342 sctp_timer_stop(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL,
3345 if (inp->control) {
3346 sctp_m_freem(inp->control);
3347 inp->control = NULL;
3349 if (inp->pkt) {
3350 sctp_m_freem(inp->pkt);
3351 inp->pkt = NULL;
3353 ip_pcb = &inp->ip_inp.inp; /* we could just cast the main pointer
3360 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3373 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3388 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_NOFORCE,
3412 if (sctp_free_assoc(inp, asoc,
3448 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED);
3483 if (sctp_free_assoc(inp, asoc,
3490 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
3499 sctp_log_closing(inp, NULL, 2);
3501 inp->sctp_socket = NULL;
3502 SCTP_INP_WUNLOCK(inp);
3503 SCTP_ASOC_CREATE_UNLOCK(inp);
3508 inp->sctp_socket = NULL;
3509 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) !=
3515 LIST_REMOVE(inp, sctp_hash);
3516 inp->sctp_flags |= SCTP_PCB_FLAGS_UNBOUND;
3523 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3528 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3552 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_FORCE,
3559 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3561 sctp_log_closing(inp, NULL, 3);
3563 SCTP_INP_WUNLOCK(inp);
3564 SCTP_ASOC_CREATE_UNLOCK(inp);
3568 if (SCTP_INP_LOCK_CONTENDED(inp))
3570 if (SCTP_INP_READ_CONTENDED(inp))
3572 if (SCTP_ASOC_CREATE_LOCK_CONTENDED(inp))
3575 if ((inp->refcount) ||
3577 (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) {
3578 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3580 sctp_log_closing(inp, NULL, 4);
3582 sctp_timer_start(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL);
3583 SCTP_INP_WUNLOCK(inp);
3584 SCTP_ASOC_CREATE_UNLOCK(inp);
3588 inp->sctp_ep.signature_change.type = 0;
3589 inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_ALLGONE;
3593 LIST_REMOVE(inp, sctp_list);
3594 SCTP_INP_WUNLOCK(inp);
3595 SCTP_ASOC_CREATE_UNLOCK(inp);
3605 (void)SCTP_OS_TIMER_STOP_DRAIN(&inp->sctp_ep.signature_change.timer);
3608 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3612 sctp_log_closing(inp, NULL, 5);
3616 if ((inp->sctp_asocidhash) != NULL) {
3617 SCTP_HASH_FREE(inp->sctp_asocidhash, inp->hashasocidmark);
3618 inp->sctp_asocidhash = NULL;
3621 TAILQ_FOREACH_SAFE(sq, &inp->read_queue, next, nsq) {
3626 TAILQ_REMOVE(&inp->read_queue, sq, next);
3662 in6p = (struct in6pcb *)inp;
3668 if (inp->sctp_ep.local_auth_chunks != NULL)
3669 sctp_free_chunklist(inp->sctp_ep.local_auth_chunks);
3670 if (inp->sctp_ep.local_hmacs != NULL)
3671 sctp_free_hmaclist(inp->sctp_ep.local_hmacs);
3673 LIST_FOREACH_SAFE(shared_key, &inp->sctp_ep.shared_keys, next, nshared_key) {
3684 LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
3690 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_free_list, sctp_tcblist, nasoc) {
3698 if (inp->sctp_tcbhash != NULL) {
3699 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
3700 inp->sctp_tcbhash = NULL;
3703 crfree(inp->ip_inp.inp.inp_cred);
3704 INP_LOCK_DESTROY(&inp->ip_inp.inp);
3705 SCTP_INP_LOCK_DESTROY(inp);
3706 SCTP_INP_READ_DESTROY(inp);
3707 SCTP_ASOC_CREATE_LOCK_DESTROY(inp);
3708 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
4131 sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
4137 SCTP_INP_WLOCK(inp);
4139 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
4141 SCTP_INP_WUNLOCK(inp);
4148 if (inp->sctp_associd_counter <= SCTP_ALL_ASSOC) {
4149 inp->sctp_associd_counter = SCTP_ALL_ASSOC + 1;
4151 id = inp->sctp_associd_counter;
4152 inp->sctp_associd_counter++;
4153 lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t) id, 0);
4157 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
4160 SCTP_INP_WUNLOCK(inp);
4170 sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4190 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4195 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4199 SCTP_INP_RLOCK(inp);
4200 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) &&
4201 ((sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) ||
4202 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) {
4209 SCTP_INP_RUNLOCK(inp);
4210 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4214 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
4215 (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) {
4216 if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) ||
4217 (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED)) {
4218 SCTP_INP_RUNLOCK(inp);
4219 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4260 SCTP_INP_RUNLOCK(inp);
4261 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4279 SCTP_INP_RUNLOCK(inp);
4280 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4290 SCTP_INP_RUNLOCK(inp);
4291 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4295 SCTP_INP_RUNLOCK(inp);
4296 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) {
4301 if ((err = sctp_inpcb_bind(inp->sctp_socket,
4314 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
4323 asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
4328 stcb->sctp_ep = inp;
4329 stcb->sctp_socket = inp->sctp_socket;
4330 if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id))) {
4342 SCTP_INP_WLOCK(inp);
4343 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
4349 SCTP_INP_WUNLOCK(inp);
4352 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4384 SCTP_INP_WUNLOCK(inp);
4385 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4398 LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist);
4400 if (inp->sctp_tcbhash != NULL) {
4401 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(stcb->rport,
4402 inp->sctp_hashmark)];
4405 SCTP_INP_WUNLOCK(inp);
4641 sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfree, int from_location)
4659 sctp_log_closing(inp, stcb, 6);
4663 sctp_log_closing(inp, NULL, 7);
4680 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4681 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4685 so = inp->sctp_socket;
4700 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4704 sctp_log_closing(inp, stcb, 8);
4743 SCTP_INP_READ_LOCK(inp);
4744 TAILQ_FOREACH(sq, &inp->read_queue, next) {
4756 if (sctp_stcb_is_feature_on(inp, stcb, SCTP_PCB_FLAGS_PDAPIEVNT) && (so != NULL)) {
4781 SCTP_INP_READ_UNLOCK(inp);
4783 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PCB, ECONNRESET);
4794 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4795 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
4797 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4800 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4801 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4806 sctp_sorwakeup(inp, so);
4807 sctp_sowwakeup(inp, so);
4810 sctp_log_closing(inp, stcb, 9);
4816 sctp_log_closing(inp, stcb, 10);
4833 SCTP_INP_WLOCK(inp);
4837 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4838 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4842 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
4843 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
4848 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
4849 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
4850 inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
4860 sctp_sowwakeup(inp, so);
4861 sctp_sorwakeup(inp, so);
4876 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4879 SCTP_INP_WUNLOCK(inp);
4885 if (inp->sctp_tcbhash) {
4894 SCTP_INP_INCR_REF(inp);
4895 SCTP_INP_WUNLOCK(inp);
4900 inp->sctp_lport, stcb->rport);
5187 SCTP_INP_RLOCK(inp);
5190 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5195 LIST_INSERT_HEAD(&inp->sctp_asoc_free_list, stcb, sctp_tcblist);
5202 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5207 SCTP_INP_RUNLOCK(inp);
5215 sctp_inpcb_free(inp,
5218 SCTP_INP_DECR_REF(inp);
5222 SCTP_INP_DECR_REF(inp);
5226 SCTP_INP_RUNLOCK(inp);
5231 sctp_log_closing(inp, NULL, 11);
5250 struct sctp_inpcb *inp;
5263 inp = stcb->sctp_ep;
5264 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5277 answer = inp->ip_inp.inp.inp_vflag & INP_IPV6;
5282 answer = inp->ip_inp.inp.inp_vflag & INP_IPV4;
5297 sctp_update_ep_vflag(struct sctp_inpcb *inp)
5302 inp->ip_inp.inp.inp_vflag = 0;
5304 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5316 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5321 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5335 sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
5342 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5355 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5364 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, action);
5367 inp->laddr_count++;
5372 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5377 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5417 sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
5423 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5427 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5433 if (fnd && (inp->laddr_count < 2)) {
5447 if (inp->next_addr_touse == laddr)
5449 inp->next_addr_touse = NULL;
5452 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5484 inp->laddr_count--;
5486 sctp_update_ep_vflag(inp);
5574 struct sctp_inpcb *inp;
5587 inp = stcb->sctp_ep;
5589 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) &&
5590 sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
6063 struct sctp_inpcb *inp;
6131 inp = stcb->sctp_ep;
6133 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb);
6136 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
6214 inp = stcb->sctp_ep;
6216 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6220 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
6221 inp == NULL) {
6304 inp = stcb->sctp_ep;
6306 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6310 (inp == stcb->sctp_ep || inp == NULL)) {
6935 struct sctp_inpcb *inp;
6947 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
6949 SCTP_INP_RLOCK(inp);
6950 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
6956 SCTP_INP_RUNLOCK(inp);
6970 * iterated through. inpe (optional) is called when the inp completes
7015 it->inp = s_inp;
7016 SCTP_INP_INCR_REF(it->inp);
7020 it->inp = LIST_FIRST(&SCTP_BASE_INFO(listhead));
7021 if (it->inp) {
7022 SCTP_INP_INCR_REF(it->inp);