Lines Matching refs:inp

900 						if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred,
919 if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred,
1021 struct sctp_inpcb *inp;
1061 LIST_FOREACH(inp, ephead, sctp_hash) {
1062 SCTP_INP_RLOCK(inp);
1063 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1064 SCTP_INP_RUNLOCK(inp);
1067 if (lport != inp->sctp_lport) {
1068 SCTP_INP_RUNLOCK(inp);
1078 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
1080 SCTP_INP_RUNLOCK(inp);
1092 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
1094 SCTP_INP_RUNLOCK(inp);
1101 SCTP_INP_RUNLOCK(inp);
1104 if (inp->def_vrf_id != vrf_id) {
1105 SCTP_INP_RUNLOCK(inp);
1109 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
1113 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1160 SCTP_INP_RUNLOCK(inp);
1169 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1171 SCTP_INP_RUNLOCK(inp);
1177 SCTP_INP_RUNLOCK(inp);
1183 SCTP_INP_RUNLOCK(inp);
1188 SCTP_INP_RUNLOCK(inp);
1193 SCTP_INP_RUNLOCK(inp);
1221 *inp_p = inp;
1222 SCTP_INP_RUNLOCK(inp);
1245 *inp_p = inp;
1246 SCTP_INP_RUNLOCK(inp);
1258 SCTP_INP_RUNLOCK(inp);
1278 struct sctp_inpcb *inp;
1283 inp = *inp_p;
1307 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
1308 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
1314 * and find the real inp.
1316 if ((inp->sctp_socket) && (inp->sctp_socket->so_qlimit)) {
1319 netp, inp->def_vrf_id);
1322 SCTP_INP_DECR_REF(inp);
1333 SCTP_INP_WLOCK(inp);
1334 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1337 stcb = LIST_FIRST(&inp->sctp_asoc_list);
1385 SCTP_INP_DECR_REF(inp);
1393 SCTP_INP_WUNLOCK(inp);
1415 SCTP_INP_DECR_REF(inp);
1422 SCTP_INP_WUNLOCK(inp);
1437 SCTP_INP_WLOCK(inp);
1438 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1441 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(rport,
1442 inp->sctp_hashmark)];
1486 SCTP_INP_DECR_REF(inp);
1493 SCTP_INP_WUNLOCK(inp);
1516 SCTP_INP_DECR_REF(inp);
1523 SCTP_INP_WUNLOCK(inp);
1544 SCTP_INP_WUNLOCK(inp);
1556 sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1565 if (inp == NULL) {
1569 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1574 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
1582 if (inp != stcb->sctp_ep) {
1604 sctp_findassociation_ep_asocid(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock)
1608 SCTP_INP_RLOCK(inp);
1609 stcb = sctp_findasoc_ep_asocid_locked(inp, asoc_id, want_lock);
1610 SCTP_INP_RUNLOCK(inp);
1622 struct sctp_inpcb *inp;
1658 LIST_FOREACH(inp, head, sctp_hash) {
1659 SCTP_INP_RLOCK(inp);
1660 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1661 SCTP_INP_RUNLOCK(inp);
1664 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) &&
1665 (inp->sctp_lport == lport)) {
1670 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1671 SCTP_IPV6_V6ONLY(inp)) {
1676 SCTP_INP_RUNLOCK(inp);
1679 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
1681 SCTP_INP_RUNLOCK(inp);
1692 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) {
1693 SCTP_INP_RUNLOCK(inp);
1696 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
1698 SCTP_INP_RUNLOCK(inp);
1708 if (inp->def_vrf_id == vrf_id)
1711 SCTP_INP_RUNLOCK(inp);
1714 return (inp);
1716 SCTP_INP_RUNLOCK(inp);
1742 LIST_FOREACH(inp, head, sctp_hash) {
1743 SCTP_INP_RLOCK(inp);
1744 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
1745 SCTP_INP_RUNLOCK(inp);
1748 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL)) {
1749 SCTP_INP_RUNLOCK(inp);
1756 if (inp->sctp_lport != lport) {
1757 SCTP_INP_RUNLOCK(inp);
1762 if (inp->def_vrf_id == vrf_id)
1766 SCTP_INP_RUNLOCK(inp);
1769 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1788 SCTP_INP_RUNLOCK(inp);
1789 return (inp);
1798 SCTP_INP_RUNLOCK(inp);
1799 return (inp);
1806 SCTP_INP_RUNLOCK(inp);
1813 sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id)
1836 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
1840 /* inp is BOUND_V4 no conflict */
1848 if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
1849 SCTP_IPV6_V6ONLY(inp)) {
1862 sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp)
1868 if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) {
1872 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) == 0) {
1875 SCTP_INP_RUNLOCK(inp);
1877 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport,
1881 if (tinp->sctp_lport != inp->sctp_lport) {
1900 SCTP_INP_WLOCK(inp);
1902 LIST_REMOVE(inp, sctp_hash);
1903 inp->sctp_flags &= ~SCTP_PCB_FLAGS_IN_TCPPOOL;
1904 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(inp->sctp_lport, SCTP_BASE_INFO(hashmark))];
1905 LIST_INSERT_HEAD(head, inp, sctp_hash);
1906 SCTP_INP_WUNLOCK(inp);
1907 SCTP_INP_RLOCK(inp);
1921 struct sctp_inpcb *inp;
1959 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1971 if (inp == NULL && find_tcp_pool) {
1974 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1975 if (inp) {
1980 if (inp) {
1981 SCTP_INP_INCR_REF(inp);
1986 return (inp);
2000 struct sctp_inpcb *inp = NULL;
2009 stcb = sctp_tcb_special_locate(&inp, from, to, netp,
2017 inp = sctp_pcb_findep(to, 0, 1, vrf_id);
2019 *inp_p = inp;
2022 if (inp == NULL) {
2035 stcb = sctp_findassociation_ep_addr(&inp, from, netp, to,
2248 struct sctp_inpcb *inp;
2262 inp = *inp_p;
2264 stcb = sctp_findassociation_addr_sa(src, dst, &inp, netp,
2267 SCTPDBG(SCTP_DEBUG_PCB1, "stcb:%p inp:%p\n", (void *)stcb, (void *)inp);
2268 if (stcb == NULL && inp) {
2280 if (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) {
2287 offset, sh, &inp, netp, dst);
2289 *inp_p = inp;
2420 struct sctp_inpcb *inp;
2428 inp = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_ep), struct sctp_inpcb);
2429 if (inp == NULL) {
2432 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2436 memset(inp, 0, sizeof(*inp));
2440 inp->sctp_socket = so;
2441 inp->ip_inp.inp.inp_socket = so;
2442 inp->ip_inp.inp.inp_cred = crhold(so->so_cred);
2446 inp->ip_inp.inp.inp_flags |= IN6P_AUTOFLOWLABEL;
2449 inp->ip_inp.inp.inp_flags |= IN6P_IPV6_V6ONLY;
2453 inp->sctp_associd_counter = 1;
2454 inp->partial_delivery_point = SCTP_SB_LIMIT_RCV(so) >> SCTP_PARTIAL_DELIVERY_SHIFT;
2455 inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT;
2456 inp->max_cwnd = 0;
2457 inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off);
2458 inp->ecn_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_ecn_enable);
2459 inp->prsctp_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pr_enable);
2460 inp->auth_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_auth_enable);
2461 inp->asconf_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_asconf_enable);
2462 inp->reconfig_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_reconfig_enable);
2463 inp->nrsack_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_nrsack_enable);
2464 inp->pktdrop_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
2465 inp->idata_supported = 0;
2467 inp->fibnum = so->so_fibnum;
2469 inp->sctp_asocidhash = SCTP_HASH_INIT(SCTP_STACK_VTAG_HASH_SIZE, &inp->hashasocidmark);
2470 if (inp->sctp_asocidhash == NULL) {
2471 crfree(inp->ip_inp.inp.inp_cred);
2472 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2477 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
2480 so->so_pcb = (caddr_t)inp;
2484 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
2490 inp->sctp_flags = (SCTP_PCB_FLAGS_TCPTYPE |
2501 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EOPNOTSUPP);
2503 crfree(inp->ip_inp.inp.inp_cred);
2504 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2508 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2509 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2511 sctp_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2512 sctp_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2514 sctp_feature_off(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE);
2515 sctp_feature_off(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS);
2517 inp->sctp_tcbhash = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_pcbtblsize),
2518 &inp->sctp_hashmark);
2519 if (inp->sctp_tcbhash == NULL) {
2521 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
2523 crfree(inp->ip_inp.inp.inp_cred);
2524 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2527 inp->def_vrf_id = vrf_id;
2530 SCTP_INP_LOCK_INIT(inp);
2531 INP_LOCK_INIT(&inp->ip_inp.inp, "inp", "sctpinp");
2532 SCTP_INP_READ_INIT(inp);
2533 SCTP_ASOC_CREATE_LOCK_INIT(inp);
2535 SCTP_INP_WLOCK(inp);
2538 LIST_INSERT_HEAD(&SCTP_BASE_INFO(listhead), inp, sctp_list);
2541 TAILQ_INIT(&inp->read_queue);
2542 LIST_INIT(&inp->sctp_addr_list);
2544 LIST_INIT(&inp->sctp_asoc_list);
2548 LIST_INIT(&inp->sctp_asoc_free_list);
2551 SCTP_OS_TIMER_INIT(&inp->sctp_ep.signature_change.timer);
2552 inp->sctp_ep.signature_change.type = SCTP_TIMER_TYPE_NEWCOOKIE;
2555 m = &inp->sctp_ep;
2609 sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);
2618 if (inp->asconf_supported) {
2631 SCTP_INP_WUNLOCK(inp);
2633 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);
2862 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2883 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2893 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
2894 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2901 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2911 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EAFNOSUPPORT);
2916 SCTP_INP_WLOCK(inp);
2918 vrf_id = inp->def_vrf_id;
2921 SCTP_INP_INCR_REF(inp);
2932 SCTP_INP_DECR_REF(inp);
2933 SCTP_INP_WUNLOCK(inp);
2938 SCTP_INP_WUNLOCK(inp);
2940 vrf_id = inp->def_vrf_id;
2946 * NEVER be inp. And it is this inp
2952 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
2961 SCTP_INP_DECR_REF(inp);
2963 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
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);
2994 SCTP_INP_WLOCK(inp);
2998 (inp_tmp = sctp_isport_inuse(inp, lport, vrf_id))) {
3000 if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
3004 SCTP_INP_DECR_REF(inp);
3005 SCTP_INP_WUNLOCK(inp);
3007 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3024 SCTP_INP_DECR_REF(inp);
3025 SCTP_INP_WUNLOCK(inp);
3027 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
3044 candidate = first + sctp_select_initial_TSN(&inp->sctp_ep) % (count);
3048 if (sctp_isport_inuse(inp, htons(candidate), inp->def_vrf_id) == NULL) {
3053 SCTP_INP_DECR_REF(inp);
3054 SCTP_INP_WUNLOCK(inp);
3056 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRINUSE);
3067 SCTP_INP_DECR_REF(inp);
3068 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE |
3074 SCTP_INP_WUNLOCK(inp);
3076 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3082 inp->sctp_flags |= SCTP_PCB_FLAGS_BOUNDALL;
3085 sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3086 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3088 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3089 sctp_feature_on(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3092 sctp_feature_off(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3094 sctp_feature_on(inp, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS);
3101 sctp_mobility_feature_off(inp, SCTP_MOBILITY_BASE);
3102 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3104 sctp_mobility_feature_on(inp, SCTP_MOBILITY_BASE);
3105 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3112 sctp_mobility_feature_off(inp, SCTP_MOBILITY_FASTHANDOFF);
3113 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3115 sctp_mobility_feature_on(inp, SCTP_MOBILITY_FASTHANDOFF);
3116 sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
3167 SCTP_INP_WUNLOCK(inp);
3169 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EADDRNOTAVAIL);
3177 SCTP_INP_WUNLOCK(inp);
3179 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
3185 inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUNDALL;
3187 sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
3189 sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
3192 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0);
3194 SCTP_INP_WUNLOCK(inp);
3198 inp->laddr_count++;
3204 inp->sctp_flags |= SCTP_PCB_FLAGS_IN_TCPPOOL;
3209 LIST_INSERT_HEAD(head, inp, sctp_hash);
3213 inp->sctp_lport = lport;
3216 inp->sctp_flags &= ~SCTP_PCB_FLAGS_UNBOUND;
3217 SCTP_INP_WUNLOCK(inp);
3224 sctp_iterator_inp_being_freed(struct sctp_inpcb *inp)
3237 if (it && (it->inp == inp)) {
3241 * iterator will try to operate on inp. We need to stop that
3243 * reference on the stcb and inp. We can mark it and it will
3248 * next inp.
3258 * Now go through and remove any single reference to our inp that
3266 if (it->inp == inp) {
3267 /* This one points to me is it inp specific? */
3277 it->inp = LIST_NEXT(it->inp, sctp_list);
3278 if (it->inp) {
3279 SCTP_INP_INCR_REF(it->inp);
3286 SCTP_INP_DECR_REF(inp);
3294 sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
3315 sctp_log_closing(inp, NULL, 0);
3319 sctp_iterator_inp_being_freed(inp);
3321 so = inp->sctp_socket;
3322 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
3326 sctp_log_closing(inp, NULL, 1);
3330 SCTP_ASOC_CREATE_LOCK(inp);
3333 SCTP_INP_WLOCK(inp);
3335 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CLOSE_IP;
3337 inp->sctp_flags |= SCTP_PCB_FLAGS_DONT_WAKE;
3338 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
3339 inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
3343 sctp_timer_stop(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL,
3346 if (inp->control) {
3347 sctp_m_freem(inp->control);
3348 inp->control = NULL;
3350 if (inp->pkt) {
3351 sctp_m_freem(inp->pkt);
3352 inp->pkt = NULL;
3354 ip_pcb = &inp->ip_inp.inp; /* we could just cast the main pointer
3361 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3374 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3389 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_NOFORCE,
3413 if (sctp_free_assoc(inp, asoc,
3449 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_LOCKED);
3473 if (sctp_free_assoc(inp, asoc,
3480 sctp_chunk_output(inp, asoc, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
3489 sctp_log_closing(inp, NULL, 2);
3491 inp->sctp_socket = NULL;
3492 SCTP_INP_WUNLOCK(inp);
3493 SCTP_ASOC_CREATE_UNLOCK(inp);
3498 inp->sctp_socket = NULL;
3499 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) !=
3505 LIST_REMOVE(inp, sctp_hash);
3506 inp->sctp_flags |= SCTP_PCB_FLAGS_UNBOUND;
3514 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_list, sctp_tcblist, nasoc) {
3519 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
3543 if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_FORCE,
3551 sctp_log_closing(inp, NULL, 3);
3553 SCTP_INP_WUNLOCK(inp);
3554 SCTP_ASOC_CREATE_UNLOCK(inp);
3558 if (SCTP_INP_LOCK_CONTENDED(inp))
3560 if (SCTP_INP_READ_CONTENDED(inp))
3562 if (SCTP_ASOC_CREATE_LOCK_CONTENDED(inp))
3565 if ((inp->refcount) ||
3567 (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) {
3569 sctp_log_closing(inp, NULL, 4);
3571 sctp_timer_start(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL);
3572 SCTP_INP_WUNLOCK(inp);
3573 SCTP_ASOC_CREATE_UNLOCK(inp);
3577 inp->sctp_ep.signature_change.type = 0;
3578 inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_ALLGONE;
3582 LIST_REMOVE(inp, sctp_list);
3583 SCTP_INP_WUNLOCK(inp);
3584 SCTP_ASOC_CREATE_UNLOCK(inp);
3594 (void)SCTP_OS_TIMER_STOP_DRAIN(&inp->sctp_ep.signature_change.timer);
3597 (void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
3601 sctp_log_closing(inp, NULL, 5);
3605 if ((inp->sctp_asocidhash) != NULL) {
3606 SCTP_HASH_FREE(inp->sctp_asocidhash, inp->hashasocidmark);
3607 inp->sctp_asocidhash = NULL;
3610 TAILQ_FOREACH_SAFE(sq, &inp->read_queue, next, nsq) {
3615 TAILQ_REMOVE(&inp->read_queue, sq, next);
3645 in6p = (struct in6pcb *)inp;
3651 if (inp->sctp_ep.local_auth_chunks != NULL)
3652 sctp_free_chunklist(inp->sctp_ep.local_auth_chunks);
3653 if (inp->sctp_ep.local_hmacs != NULL)
3654 sctp_free_hmaclist(inp->sctp_ep.local_hmacs);
3656 LIST_FOREACH_SAFE(shared_key, &inp->sctp_ep.shared_keys, next, nshared_key) {
3667 LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
3673 LIST_FOREACH_SAFE(asoc, &inp->sctp_asoc_free_list, sctp_tcblist, nasoc) {
3681 if (inp->sctp_tcbhash != NULL) {
3682 SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
3683 inp->sctp_tcbhash = NULL;
3686 crfree(inp->ip_inp.inp.inp_cred);
3687 INP_LOCK_DESTROY(&inp->ip_inp.inp);
3688 SCTP_INP_LOCK_DESTROY(inp);
3689 SCTP_INP_READ_DESTROY(inp);
3690 SCTP_ASOC_CREATE_LOCK_DESTROY(inp);
3691 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
4150 sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
4157 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
4165 if (inp->sctp_associd_counter <= SCTP_ALL_ASSOC) {
4166 inp->sctp_associd_counter = SCTP_ALL_ASSOC + 1;
4168 id = inp->sctp_associd_counter;
4169 inp->sctp_associd_counter++;
4170 lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t)id, 0);
4174 head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
4186 sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
4207 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4212 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4216 SCTP_INP_RLOCK(inp);
4217 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) &&
4218 ((sctp_is_feature_off(inp, SCTP_PCB_FLAGS_PORTREUSE)) ||
4219 (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) {
4226 SCTP_INP_RUNLOCK(inp);
4227 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4231 if ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
4232 (inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)) {
4233 if ((inp->sctp_flags & SCTP_PCB_FLAGS_WAS_CONNECTED) ||
4234 (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED)) {
4235 SCTP_INP_RUNLOCK(inp);
4236 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4277 SCTP_INP_RUNLOCK(inp);
4278 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4296 SCTP_INP_RUNLOCK(inp);
4297 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4307 SCTP_INP_RUNLOCK(inp);
4308 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4312 SCTP_INP_RUNLOCK(inp);
4313 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) {
4318 if ((err = sctp_inpcb_bind(inp->sctp_socket,
4331 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
4344 stcb->sctp_ep = inp;
4345 stcb->sctp_socket = inp->sctp_socket;
4346 if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id, o_streams))) {
4357 SCTP_INP_WLOCK(inp);
4358 if (inp->sctp_flags & (SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
4363 SCTP_INP_WUNLOCK(inp);
4366 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
4372 asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
4399 SCTP_INP_WUNLOCK(inp);
4400 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOBUFS);
4412 LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist);
4414 if (inp->sctp_tcbhash != NULL) {
4415 head = &inp->sctp_tcbhash[SCTP_PCBHASH_ALLADDR(stcb->rport,
4416 inp->sctp_hashmark)];
4420 sctp_initialize_auth_params(inp, stcb);
4422 SCTP_INP_WUNLOCK(inp);
4431 struct sctp_inpcb *inp;
4434 inp = stcb->sctp_ep;
4482 sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net,
4484 sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net,
4701 sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfree, int from_location)
4719 sctp_log_closing(inp, stcb, 6);
4723 sctp_log_closing(inp, NULL, 7);
4741 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4742 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4746 so = inp->sctp_socket;
4761 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4766 sctp_log_closing(inp, stcb, 8);
4776 SCTP_INP_READ_LOCK(inp);
4777 TAILQ_FOREACH(sq, &inp->read_queue, next) {
4789 if (sctp_stcb_is_feature_on(inp, stcb, SCTP_PCB_FLAGS_PDAPIEVNT) && (so != NULL)) {
4814 SCTP_INP_READ_UNLOCK(inp);
4816 SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PCB, ECONNRESET);
4827 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4828 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
4830 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4834 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4835 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4840 sctp_sorwakeup(inp, so);
4841 sctp_sowwakeup(inp, so);
4845 sctp_log_closing(inp, stcb, 9);
4851 sctp_log_closing(inp, stcb, 10);
4869 SCTP_INP_WLOCK(inp);
4874 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
4875 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE))
4879 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
4880 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
4885 if (inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) {
4886 inp->sctp_flags &= ~SCTP_PCB_FLAGS_CONNECTED;
4887 inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
4897 sctp_sowwakeup(inp, so);
4898 sctp_sorwakeup(inp, so);
4914 sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
4917 SCTP_INP_WUNLOCK(inp);
4924 if (inp->sctp_tcbhash) {
4933 SCTP_INP_INCR_REF(inp);
4934 SCTP_INP_WUNLOCK(inp);
4939 inp->sctp_lport, stcb->rport);
5188 SCTP_INP_RLOCK(inp);
5191 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5196 LIST_INSERT_HEAD(&inp->sctp_asoc_free_list, stcb, sctp_tcblist);
5203 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
5208 SCTP_INP_RUNLOCK(inp);
5216 sctp_inpcb_free(inp,
5219 SCTP_INP_DECR_REF(inp);
5222 SCTP_INP_DECR_REF(inp);
5223 SCTP_INP_RUNLOCK(inp);
5228 sctp_log_closing(inp, NULL, 11);
5247 struct sctp_inpcb *inp;
5260 inp = stcb->sctp_ep;
5261 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5274 answer = inp->ip_inp.inp.inp_vflag & INP_IPV6;
5279 answer = inp->ip_inp.inp.inp_vflag & INP_IPV4;
5294 sctp_update_ep_vflag(struct sctp_inpcb *inp)
5299 inp->ip_inp.inp.inp_vflag = 0;
5301 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5314 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5319 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5333 sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
5341 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5354 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5363 error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, action);
5366 inp->laddr_count++;
5371 inp->ip_inp.inp.inp_vflag |= INP_IPV6;
5376 inp->ip_inp.inp.inp_vflag |= INP_IPV4;
5382 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5419 sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
5425 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
5429 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
5435 if (fnd && (inp->laddr_count < 2)) {
5449 if (inp->next_addr_touse == laddr)
5451 inp->next_addr_touse = NULL;
5454 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
5485 inp->laddr_count--;
5487 sctp_update_ep_vflag(inp);
5535 struct sctp_inpcb *inp;
5548 inp = stcb->sctp_ep;
5550 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) &&
5551 sctp_is_feature_off(inp, SCTP_PCB_FLAGS_DO_ASCONF)) {
6045 struct sctp_inpcb *inp;
6112 inp = stcb->sctp_ep;
6114 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb);
6117 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
6195 inp = stcb->sctp_ep;
6197 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6201 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
6202 inp == NULL) {
6294 inp = stcb->sctp_ep;
6296 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
6300 (inp == stcb->sctp_ep || inp == NULL)) {
7033 struct sctp_inpcb *inp;
7045 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
7047 SCTP_INP_RLOCK(inp);
7048 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
7054 SCTP_INP_RUNLOCK(inp);
7068 * iterated through. inpe (optional) is called when the inp completes
7118 it->inp = s_inp;
7119 SCTP_INP_INCR_REF(it->inp);
7123 it->inp = LIST_FIRST(&SCTP_BASE_INFO(listhead));
7124 if (it->inp) {
7125 SCTP_INP_INCR_REF(it->inp);