Home | History | Annotate | Download | only in netinet

Lines Matching refs:inp

1147 	struct sctp_inpcb *inp;
1200 LIST_FOREACH(inp, ephead, sctp_hash) {
1201 SCTP_INP_RLOCK(inp);
1202 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1203 SCTP_INP_RUNLOCK(inp);
1206 if (lport != inp->sctp_lport) {
1207 SCTP_INP_RUNLOCK(inp);
1212 for (i = 0; i < inp->num_vrfs; i++) {
1213 if (inp->m_vrf_ids[i] == vrf_id) {
1219 SCTP_INP_RUNLOCK(inp);
1223 if (inp->def_vrf_id != vrf_id) {
1224 SCTP_INP_RUNLOCK(inp);
1229 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
1233 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1292 SCTP_INP_RUNLOCK(inp);
1301 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1303 SCTP_INP_RUNLOCK(inp);
1309 SCTP_INP_RUNLOCK(inp);
1315 SCTP_INP_RUNLOCK(inp);
1320 SCTP_INP_RUNLOCK(inp);
1325 SCTP_INP_RUNLOCK(inp);
1350 *inp_p = inp;
1351 SCTP_INP_RUNLOCK(inp);
1371 *inp_p = inp;
1372 SCTP_INP_RUNLOCK(inp);
1391 *inp_p = inp;
1392 SCTP_INP_RUNLOCK(inp);
1404 SCTP_INP_RUNLOCK(inp);
1413 * 1) If I return a NULL you must decrement any INP ref cnt. 2) If I find an
1424 struct sctp_inpcb *inp;
1429 inp = *inp_p;
1458 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
1459 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
1465 * and find the real inp.
1467 if ((inp->sctp_socket) && (inp->sctp_socket->so_qlimit)) {
1471 netp, inp->def_vrf_id);
1474 SCTP_INP_DECR_REF(inp);
1489 for (i = 0; i < inp->num_vrfs; i++) {
1491 netp, inp->m_vrf_ids[i]);
1494 SCTP_INP_DECR_REF(inp);
1509 SCTP_INP_WLOCK(inp);
1510 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1513 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1560 SCTP_INP_DECR_REF(inp);
1568 SCTP_INP_WUNLOCK(inp);
1589 SCTP_INP_DECR_REF(inp);
1596 SCTP_INP_WUNLOCK(inp);
1616 SCTP_INP_DECR_REF(inp);
1623 SCTP_INP_WUNLOCK(inp);
1638 SCTP_INP_WLOCK(inp);
1639 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1642 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(rport,
1643 inp->sctp_hashmark)];
1689 SCTP_INP_DECR_REF(inp);
1696 SCTP_INP_WUNLOCK(inp);
1718 SCTP_INP_DECR_REF(inp);
1725 SCTP_INP_WUNLOCK(inp);
1745 SCTP_INP_DECR_REF(inp);
1752 SCTP_INP_WUNLOCK(inp);
1773 SCTP_INP_WUNLOCK(inp);
1785 sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1794 if (inp == NULL) {
1798 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1803 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
1811 if (inp != stcb->sctp_ep) {
1833 sctp_findassociation_ep_asocid(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1837 SCTP_INP_RLOCK(inp);
1838 stcb = sctp_findasoc_ep_asocid_locked(inp, asoc_id, want_lock);
1839 SCTP_INP_RUNLOCK(inp);
1851 struct sctp_inpcb *inp;
1901 LIST_FOREACH(inp, head, sctp_hash) {
1902 SCTP_INP_RLOCK(inp);
1903 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1904 SCTP_INP_RUNLOCK(inp);
1907 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) &&
1908 (inp->sctp_lport == lport)) {
1912 (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1913 SCTP_IPV6_V6ONLY(inp)) {
1915 SCTP_INP_RUNLOCK(inp);
1922 (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) {
1923 SCTP_INP_RUNLOCK(inp);
1930 for (i = 0; i < inp->num_vrfs; i++) {
1931 if (inp->m_vrf_ids[i] == vrf_id) {
1937 if (inp->def_vrf_id == vrf_id)
1941 SCTP_INP_RUNLOCK(inp);
1944 return (inp);
1946 SCTP_INP_RUNLOCK(inp);
1979 LIST_FOREACH(inp, head, sctp_hash) {
1980 SCTP_INP_RLOCK(inp);
1981 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1982 SCTP_INP_RUNLOCK(inp);
1985 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL)) {
1986 SCTP_INP_RUNLOCK(inp);
1993 if (inp->sctp_lport != lport) {
1994 SCTP_INP_RUNLOCK(inp);
2000 for (i = 0; i < inp->num_vrfs; i++) {
2001 if (inp->m_vrf_ids[i] == vrf_id) {
2007 if (inp->def_vrf_id == vrf_id)
2012 SCTP_INP_RUNLOCK(inp);
2015 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
2040 SCTP_INP_RUNLOCK(inp);
2041 return (inp);
2050 SCTP_INP_RUNLOCK(inp);
2051 return (inp);
2058 SCTP_INP_RUNLOCK(inp);
2059 return (inp);
2066 SCTP_INP_RUNLOCK(inp);
2073 sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id)
2091 for (i = 0; i < inp->num_vrfs; i++) {
2108 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
2112 /* inp is BOUND_V4 no conflict */
2120 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
2121 SCTP_IPV6_V6ONLY(inp)) {
2134 sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp)
2140 if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) {
2144 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) == 0) {
2147 SCTP_INP_RUNLOCK(inp);
2148 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport,
2152 if (tinp->sctp_lport != inp->sctp_lport) {
2171 SCTP_INP_WLOCK(inp);
2173 LIST_REMOVE(inp, sctp_hash);
2174 inp->sctp_flags &= ~SCTP_PCB_FLAGS_IN_TCPPOOL;
2175 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))];
2176 LIST_INSERT_HEAD(head, inp, sctp_hash);
2177 SCTP_INP_WUNLOCK(inp);
2178 SCTP_INP_RLOCK(inp);
2191 struct sctp_inpcb *inp;
2238 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
2244 * be the correct one so the caller should be wary on the returned INP.
2250 if (inp == NULL && find_tcp_pool) {
2253 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
2254 if (inp) {
2259 if (inp) {
2260 SCTP_INP_INCR_REF(inp);
2265 return (inp);
2279 struct sctp_inpcb *inp = NULL;
2288 stcb = sctp_tcb_special_locate(&inp, from, to, netp,
2296 inp = sctp_pcb_findep(to, 0, 1, vrf_id);
2298 *inp_p = inp;
2301 if (inp == NULL) {
2314 stcb = sctp_findassociation_ep_addr(&inp, from, netp, to,
2460 SCTP_INP_RUNLOCK(inp);
2547 struct sctp_inpcb *inp;
2569 inp = *inp_p;
2571 stcb = sctp_findassociation_addr_sa(src, dst, &inp, netp,
2574 SCTPDBG(SCTP_DEBUG_PCB1, "stcb:%p inp:%p\n", (void *)stcb, (void *)inp);
2575 if (stcb == NULL && inp) {
2587 if (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) {
2594 offset, sh, &inp, netp, dst);
2596 *inp_p = inp;
2731 struct sctp_inpcb *inp;
2739 inp = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_ep), struct sctp_inpcb);
2740 if (inp == NULL) {
2743 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2747 bzero(inp, sizeof(*inp));
2751 inp->ip_inp.inp.inp_state = INPCB_STATE_INUSE;
2754 inp->sctp_socket = so;
2755 inp->ip_inp.inp.inp_socket = so;
2760 inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL;
2763 inp->ip_inp.inp.inp_flags |= IN6P_IPV6_V6ONLY;
2768 inp->sctp_associd_counter = 1;
2769 inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT;
2770 inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT;
2771 inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off);
2772 inp->sctp_ecn_enable = SCTP_BASE_SYSCTL(sctp_ecn_enable);
2774 inp->ulp_info = NULL;
2775 inp->recv_callback = NULL;
2776 inp->send_callback = NULL;
2777 inp->send_sb_threshold = 0;
2780 inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark);
2781 if (inp->sctp_asocidhash == NULL) {
2782 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2793 inp->ip_inp.inp.inp_sp = pcb_sp;
2794 ((struct in6pcb *)(&inp->ip_inp.inp))->in6p_sp = pcb_sp;
2801 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2807 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
2810 so->so_pcb = (caddr_t)inp;
2819 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
2825 inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE |
2831 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
2833 sctp_feature_on(inp, SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE);
2835 inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE |
2837 sctp_feature_on(inp, SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE);
2844 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EOPNOTSUPP);
2846 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2850 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2851 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2853 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2854 sctp_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2856 sctp_feature_off(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2857 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2859 inp->sctp_tcbhash = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_pcbtblsize),
2860 &inp->sctp_hashmark);
2861 if (inp->sctp_tcbhash == NULL) {
2863 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2865 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2869 inp->vrf_size = SCTP_DEFAULT_VRF_SIZE;
2870 SCTP_MALLOC(inp->m_vrf_ids, uint32_t *,
2871 (sizeof(uint32_t) * inp->vrf_size), SCTP_M_MVRF);
2872 if (inp->m_vrf_ids == NULL) {
2873 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2875 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
2876 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2879 inp->m_vrf_ids[0] = vrf_id;
2880 inp->num_vrfs = 1;
2882 inp->def_vrf_id = vrf_id;
2886 inp->ip_inp.inp.inpcb_mtx = lck_mtx_alloc_init(SCTP_BASE_INFO(sctbinfo).mtx_grp, SCTP_BASE_INFO(sctbinfo).mtx_attr);
2887 if (inp->ip_inp.inp.inpcb_mtx == NULL) {
2890 SCTP_FREE(inp->m_vrf_ids, SCTP_M_MVRF);
2892 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
2894 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2896 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
2900 lck_mtx_init(&inp->ip_inp.inp.inpcb_mtx, SCTP_BASE_INFO(sctbinfo).mtx_grp, SCTP_BASE_INFO(sctbinfo).mtx_attr);
2902 lck_mtx_init(&inp->ip_inp.inp.inpcb_mtx, SCTP_BASE_INFO(sctbinfo).ipi_lock_grp, SCTP_BASE_INFO(sctbinfo).ipi_lock_attr);
2906 SCTP_INP_LOCK_INIT(inp);
2908 INP_LOCK_INIT(&inp->ip_inp.inp, "inp", "sctpinp");
2910 SCTP_INP_READ_INIT(inp);
2911 SCTP_ASOC_CREATE_LOCK_INIT(inp);
2913 SCTP_INP_WLOCK(inp);
2916 LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list);
2918 inp->ip_inp.inp.inp_pcbinfo = &SCTP_BASE_INFO(sctbinfo);
2920 LIST_INSERT_HEAD(SCTP_BASE_INFO(sctbinfo).listhead, &inp->ip_inp.inp, inp_list);
2922 LIST_INSERT_HEAD(SCTP_BASE_INFO(sctbinfo).ipi_listhead, &inp->ip_inp.inp, inp_list);
2927 TAILQ_INIT(&inp->read_queue);
2928 LIST_INIT(&inp->sctp_addr_list);
2930 LIST_INIT(&inp->sctp_asoc_list);
2934 LIST_INIT(&inp->sctp_asoc_free_list);
2937 SCTP_OS_TIMER_INIT(&inp->sctp_ep.signature_change.timer);
2938 inp->sctp_ep.signature_change.type = SCTP_TIMER_TYPE_NEWCOOKIE;
2941 m = &inp->sctp_ep;
2994 sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);
3013 SCTP_INP_WUNLOCK(inp);
3015 sctp_log_closing(inp, NULL, 12);
3166 struct sctp_inpcb *inp, *inp_tmp;
3181 inp = (struct sctp_inpcb *)so->so_pcb;
3193 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
3195 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3213 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3218 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3231 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3251 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3262 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
3263 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3273 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3282 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3288 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3293 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3313 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3326 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EAFNOSUPPORT);
3331 SCTP_INP_WLOCK(inp);
3333 vrf_id = inp->def_vrf_id;
3336 SCTP_INP_INCR_REF(inp);
3362 SCTP_INP_DECR_REF(inp);
3363 SCTP_INP_WUNLOCK(inp);
3369 SCTP_INP_DECR_REF(inp);
3370 SCTP_INP_WUNLOCK(inp);
3372 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EACCES);
3378 SCTP_INP_WUNLOCK(inp);
3381 for (i = 0; i < inp->num_vrfs; i++) {
3382 vrf_id = inp->m_vrf_ids[i];
3384 vrf_id = inp->def_vrf_id;
3391 * inp_tmp should NEVER be inp. And
3392 * it is this inp (inp_tmp) that gets
3398 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3404 SCTP_INP_DECR_REF(inp);
3406 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3418 * NEVER be inp. And it is this inp (inp_tmp)
3424 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3430 SCTP_INP_DECR_REF(inp);
3432 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3437 SCTP_INP_WLOCK(inp);
3441 (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id))) {
3443 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3447 SCTP_INP_DECR_REF(inp);
3448 SCTP_INP_WUNLOCK(inp);
3450 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3486 SCTP_INP_DECR_REF(inp);
3487 SCTP_INP_WUNLOCK(inp);
3489 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3510 candidate = first + sctp_select_initial_TSN(&inp->sctp_ep) % (count);
3515 for (i = 0; i < inp->num_vrfs; i++) {
3516 if (sctp_isport_inuse(inp, htons(candidate), inp->m_vrf_ids[i]) != NULL) {
3520 if (i == inp->num_vrfs) {
3524 if (sctp_isport_inuse(inp, htons(candidate), inp->def_vrf_id) == NULL) {
3530 SCTP_INP_DECR_REF(inp);
3531 SCTP_INP_WUNLOCK(inp);
3533 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3544 SCTP_INP_DECR_REF(inp);
3545 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE |
3551 SCTP_INP_WUNLOCK(inp);
3553 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3559 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUNDALL;
3562 sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3563 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3565 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3566 sctp_feature_on(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3569 sctp_feature_off(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3571 sctp_feature_on(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3577 sctp_mobility_feature_off(inp, SCTP_MOBILITY_BASE);
3578 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3580 sctp_mobility_feature_on(inp, SCTP_MOBILITY_BASE);
3581 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3587 sctp_mobility_feature_off(inp, SCTP_MOBILITY_FASTHANDOFF);
3588 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3590 inp, SCTP_MOBILITY_FASTHANDOFF);
3591 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3662 SCTP_INP_WUNLOCK(inp);
3664 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRNOTAVAIL);
3672 SCTP_INP_WUNLOCK(inp);
3674 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3680 inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUNDALL;
3682 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3684 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3687 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0);
3689 SCTP_INP_WUNLOCK(inp);
3693 inp->laddr_count++;
3699 inp->sctp_flags |= SCTP_PCB_FLAGS_IN_TCPPOOL;
3704 LIST_INSERT_HEAD(head, inp, sctp_hash);
3708 inp->sctp_lport = lport;
3711 inp->sctp_flags &= ~SCTP_PCB_FLAGS_UNBOUND;
3712 SCTP_INP_WUNLOCK(inp);
3719 sctp_iterator_inp_being_freed(struct sctp_inpcb *inp)
3734 if (it && (it->inp == inp)) {
3739 * inp. We need to stop that from happening. But
3741 * stcb and inp. We can mark it and it will stop.
3745 * we set the iterator to go to the next inp.
3755 * our inp that may be still pending on the list
3764 if (it->inp == inp) {
3765 /* This one points to me is it inp specific? */
3775 it->inp = LIST_NEXT(it->inp, sctp_list);
3776 if (it->inp) {
3777 SCTP_INP_INCR_REF(it->inp);
3781 SCTP_INP_DECR_REF(inp);
3789 sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
3815 sctp_lock_assert(SCTP_INP_SO(inp));
3818 sctp_log_closing(inp, NULL, 0);
3822 sctp_iterator_inp_being_freed(inp);
3824 so = inp->sctp_socket;
3825 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
3829 sctp_log_closing(inp, NULL, 1);
3833 SCTP_ASOC_CREATE_LOCK(inp);
3836 SCTP_INP_WLOCK(inp);
3838 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CLOSE_IP;
3840 inp->sctp_flags |= SCTP_PCB_FLAGS_DONT_WAKE;
3841 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
3842 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
3846 sctp_timer_stop(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL,
3849 if (inp->control) {
3850 sctp_m_freem(inp->control);
3851 inp->control = NULL;
3853 if (inp->pkt) {
3854 sctp_m_freem(inp->pkt);
3855 inp->pkt = NULL;
3857 ip_pcb = &inp->ip_inp.inp; /* we could just cast the main pointer
3864 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3876 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3890 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_NOFORCE,
3914 if (sctp_free_assoc(inp, asoc,
3950 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED);
3984 if (sctp_free_assoc(inp, asoc,
3991 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
4000 sctp_log_closing(inp, NULL, 2);
4002 inp->sctp_socket = NULL;
4003 SCTP_INP_WUNLOCK(inp);
4004 SCTP_ASOC_CREATE_UNLOCK(inp);
4009 inp->sctp_socket = NULL;
4010 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) !=
4017 LIST_REMOVE(inp, sctp_hash);
4018 inp->sctp_flags |= SCTP_PCB_FLAGS_UNBOUND;
4023 * on the INP lock.. which would cause us
4027 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
4032 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
4056 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_FORCE, SCTP_FROM_SCTP_PCB+SCTP_LOC_8) == 0) {
4062 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
4064 sctp_log_closing(inp, NULL, 3);
4066 SCTP_INP_WUNLOCK(inp);
4067 SCTP_ASOC_CREATE_UNLOCK(inp);
4071 if (SCTP_INP_LOCK_CONTENDED(inp))
4073 if (SCTP_INP_READ_CONTENDED(inp))
4075 if (SCTP_ASOC_CREATE_LOCK_CONTENDED(inp))
4078 if ((inp->refcount) ||
4080 (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) {
4081 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
4083 sctp_log_closing(inp, NULL, 4);
4085 sctp_timer_start(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL);
4086 SCTP_INP_WUNLOCK(inp);
4087 SCTP_ASOC_CREATE_UNLOCK(inp);
4091 inp->sctp_ep.signature_change.type = 0;
4092 inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_ALLGONE;
4096 LIST_REMOVE(inp, sctp_list);
4097 SCTP_INP_WUNLOCK(inp);
4098 SCTP_ASOC_CREATE_UNLOCK(inp);
4100 /* Now we release all locks. Since this INP
4108 (void)SCTP_OS_TIMER_STOP_DRAIN(&inp->sctp_ep.signature_change.timer);
4111 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
4115 sctp_log_closing(inp, NULL, 5);
4125 if (inp->pak_to_read) {
4126 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.zero_copy_timer.timer);
4127 SCTP_RELEASE_PKT(inp->pak_to_read);
4128 inp->pak_to_read = NULL;
4130 if (inp->pak_to_read_sendq) {
4131 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.zero_copy_sendq_timer.timer);
4132 SCTP_RELEASE_PKT(inp->pak_to_read_sendq);
4133 inp->pak_to_read_sendq = NULL;
4136 if ((inp->sctp_asocidhash) != NULL) {
4137 SCTP_HASH_FREE(inp->sctp_asocidhash, inp->hashasocidmark);
4138 inp->sctp_asocidhash = NULL;
4141 TAILQ_FOREACH_SAFE(sq, &inp->read_queue, next, nsq) {
4146 TAILQ_REMOVE(&inp->read_queue, sq, next);
4203 if (inp->inp_vflag & INP_IPV6) {
4207 in6p = (struct in6pcb *)inp;
4213 inp->inp_vflag = 0;
4218 if (inp->sctp_ep.local_auth_chunks != NULL)
4219 sctp_free_chunklist(inp->sctp_ep.local_auth_chunks);
4220 if (inp->sctp_ep.local_hmacs != NULL)
4221 sctp_free_hmaclist(inp->sctp_ep.local_hmacs);
4223 LIST_FOREACH_SAFE(shared_key, &inp->sctp_ep.shared_keys, next, nshared_key) {
4230 inp->ip_inp.inp.inp_state = INPCB_STATE_DEAD;
4231 if (in_pcb_checkstate(&inp->ip_inp.inp, WNT_STOPUSING, 1) != WNT_STOPUSING) {
4233 panic("sctp_inpcb_free inp = %p couldn't set to STOPUSING\n", (void *)inp);
4235 SCTP_PRINTF("sctp_inpcb_free inp = %p couldn't set to STOPUSING\n", (void *)inp);
4238 inp->ip_inp.inp.inp_socket->so_flags |= SOF_PCBCLEARING;
4245 LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
4251 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_free_list, sctp_tcblist, nasoc) {
4259 SCTP_FREE(inp->m_vrf_ids, SCTP_M_MVRF);
4262 if (inp->sctp_tcbhash != NULL) {
4263 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
4264 inp->sctp_tcbhash = NULL;
4268 INP_LOCK_DESTROY(&inp->ip_inp.inp);
4270 SCTP_INP_LOCK_DESTROY(inp);
4271 SCTP_INP_READ_DESTROY(inp);
4272 SCTP_ASOC_CREATE_LOCK_DESTROY(inp);
4274 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
4563 (void)in6_embedscope(&sin6->sin6_addr, sin6, &stcb->sctp_ep->ip_inp.inp, NULL);
4565 (void)in6_embedscope(&sin6->sin6_addr, sin6, &stcb->sctp_ep->ip_inp.inp, NULL, NULL);
4765 sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
4771 SCTP_INP_WLOCK(inp);
4773 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
4775 SCTP_INP_WUNLOCK(inp);
4782 if (inp->sctp_associd_counter <= SCTP_ALL_ASSOC) {
4783 inp->sctp_associd_counter = SCTP_ALL_ASSOC + 1;
4785 id = inp->sctp_associd_counter;
4786 inp->sctp_associd_counter++;
4787 lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t)id, 0);
4791 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
4794 SCTP_INP_WUNLOCK(inp);
4804 sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4833 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4838 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4842 SCTP_INP_RLOCK(inp);
4843 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) &&
4844 ((sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) ||
4845 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) {
4852 SCTP_INP_RUNLOCK(inp);
4853 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4857 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
4858 (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) {
4859 if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) ||
4860 (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED)) {
4861 SCTP_INP_RUNLOCK(inp);
4862 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4909 SCTP_INP_RUNLOCK(inp);
4910 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4928 SCTP_INP_RUNLOCK(inp);
4929 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4946 SCTP_INP_RUNLOCK(inp);
4947 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4957 SCTP_INP_RUNLOCK(inp);
4958 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4962 SCTP_INP_RUNLOCK(inp);
4963 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) {
4968 if ((err = sctp_inpcb_bind(inp->sctp_socket,
4985 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
4994 asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
4999 stcb->sctp_ep = inp;
5000 stcb->sctp_socket = inp->sctp_socket;
5001 if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id))) {
5013 SCTP_INP_WLOCK(inp);
5014 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
5020 SCTP_INP_WUNLOCK(inp);
5023 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
5055 SCTP_INP_WUNLOCK(inp);
5056 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
5069 LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist);
5071 if (inp->sctp_tcbhash != NULL) {
5072 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(stcb->rport,
5073 inp->sctp_hashmark)];
5076 SCTP_INP_WUNLOCK(inp);
5315 sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfree, int from_location)
5332 sctp_lock_assert(SCTP_INP_SO(inp));
5336 sctp_log_closing(inp, stcb, 6);
5340 sctp_log_closing(inp, NULL, 7);
5359 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
5360 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
5364 so = inp->sctp_socket;
5379 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
5383 sctp_log_closing(inp, stcb, 8);
5422 SCTP_INP_READ_LOCK(inp);
5423 TAILQ_FOREACH(sq, &inp->read_queue, next) {
5434 if (sctp_stcb_is_feature_on(inp, stcb, SCTP_PCB_FLAGS_PDAPIEVNT) && (so != NULL)) {
5455 SCTP_INP_READ_UNLOCK(inp);
5457 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PCB, ECONNRESET);
5466 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
5467 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
5469 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
5472 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
5473 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
5478 sctp_sorwakeup(inp, so);
5479 sctp_sowwakeup(inp, so);
5483 sctp_log_closing(inp, stcb, 9);
5489 sctp_log_closing(inp, stcb, 10);
5511 SCTP_INP_WLOCK(inp);
5515 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
5516 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
5520 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
5521 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
5526 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
5527 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
5528 inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
5542 sctp_sowwakeup(inp, so);
5543 sctp_sorwakeup(inp, so);
5558 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
5561 SCTP_INP_WUNLOCK(inp);
5567 if (inp->sctp_tcbhash) {
5576 SCTP_INP_INCR_REF(inp);
5577 SCTP_INP_WUNLOCK(inp);
5582 inp->sctp_lport, stcb->rport);
5870 SCTP_INP_RLOCK(inp);
5876 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5881 LIST_INSERT_HEAD(&inp->sctp_asoc_free_list, stcb, sctp_tcblist);
5888 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5893 SCTP_INP_RUNLOCK(inp);
5901 sctp_inpcb_free(inp,
5904 SCTP_INP_DECR_REF(inp);
5908 SCTP_INP_DECR_REF(inp);
5912 SCTP_INP_RUNLOCK(inp);
5917 sctp_log_closing(inp, NULL, 11);
5936 struct sctp_inpcb *inp;
5941 * assoc is up. There is either a INP lock by the caller applied (in
5943 * however if HB then the INP increment is up and the INP will not
5949 inp = stcb->sctp_ep;
5950 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5964 answer = inp->inp_vflag & INP_IPV6;
5966 answer = inp->ip_inp.inp.inp_vflag & INP_IPV6;
5973 answer = inp->inp_vflag & INP_IPV4;
5975 answer = inp->ip_inp.inp.inp_vflag & INP_IPV4;
5981 answer = inp->ip_inp.inp.inp_vflag & INP_CONN;
5996 sctp_update_ep_vflag(struct sctp_inpcb *inp)
6002 inp->inp_vflag = 0;
6004 inp->ip_inp.inp.inp_vflag = 0;
6007 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
6021 inp->inp_vflag |= INP_IPV6;
6023 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
6030 inp->inp_vflag |= INP_IPV4;
6032 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
6038 inp->ip_inp.inp.inp_vflag |= INP_CONN;
6052 sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
6059 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
6072 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
6081 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, action);
6084 inp->laddr_count++;
6090 inp->inp_vflag |= INP_IPV6;
6092 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
6099 inp->inp_vflag |= INP_IPV4;
6101 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
6107 inp->ip_inp.inp.inp_vflag |= INP_CONN;
6147 sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
6153 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
6157 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
6163 if (fnd && (inp->laddr_count < 2)) {
6177 if (inp->next_addr_touse == laddr)
6179 inp->next_addr_touse = NULL;
6182 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
6210 inp->laddr_count--;
6212 sctp_update_ep_vflag(inp);
6229 * Assumes TCB is locked.. and possibly the INP. May need to
6300 struct sctp_inpcb *inp;
6305 * locked and b) The INP is locked. This is true in as much as I can
6308 * the INP during its work often times. This must be since we don't
6313 inp = stcb->sctp_ep;
6315 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) &&
6316 sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
6988 struct sctp_inpcb *inp;
7045 inp = stcb->sctp_ep;
7047 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb);
7050 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
7143 inp = stcb->sctp_ep;
7145 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
7149 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
7150 inp == NULL) {
7228 inp = stcb->sctp_ep;
7230 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
7234 (inp == stcb->sctp_ep || inp == NULL)) {
7657 * be freed on us, same thing for the INP. I may
7836 struct sctp_inpcb *inp;
7848 struct sctp_inpcb *inp;
7863 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
7865 SCTP_INP_RLOCK(inp);
7866 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
7872 SCTP_INP_RUNLOCK(inp);
7888 * iterated through. inpe (optional) is called when the inp completes
7935 it->inp = s_inp;
7936 SCTP_INP_INCR_REF(it->inp);
7940 it->inp = LIST_FIRST(&SCTP_BASE_INFO(listhead));
7941 if (it->inp) {
7942 SCTP_INP_INCR_REF(it->inp);