Lines Matching refs:inp

241 extern void tcp_remove_from_time_wait(struct inpcb *inp);
250 * Use this inp as a key to find an inp in the flowhash tree.
500 struct inpcb *inp;
507 inp = (struct inpcb *)zalloc(pcbinfo->ipi_zone);
508 if (inp == NULL)
510 bzero((caddr_t)inp, sizeof (*inp));
512 inp = (struct inpcb *)(void *)so->so_saved_pcb;
513 temp = inp->inp_saved_ppcb;
514 bzero((caddr_t)inp, sizeof (*inp));
515 inp->inp_saved_ppcb = temp;
518 inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
519 inp->inp_pcbinfo = pcbinfo;
520 inp->inp_socket = so;
522 mac_error = mac_inpcb_label_init(inp, M_WAITOK);
525 zfree(pcbinfo->ipi_zone, inp);
528 mac_inpcb_label_associate(so, inp);
531 inp->inp_stat = (struct inp_stat *)P2ROUNDUP(inp->inp_stat_store,
533 if (((uintptr_t)inp->inp_stat - (uintptr_t)inp->inp_stat_store) +
534 sizeof (*inp->inp_stat) > sizeof (inp->inp_stat_store)) {
540 inp->inp_cstat = (struct inp_stat *)P2ROUNDUP(inp->inp_cstat_store,
542 if (((uintptr_t)inp->inp_cstat - (uintptr_t)inp->inp_cstat_store) +
543 sizeof (*inp->inp_cstat) > sizeof (inp->inp_cstat_store)) {
549 inp->inp_wstat = (struct inp_stat *)P2ROUNDUP(inp->inp_wstat_store,
551 if (((uintptr_t)inp->inp_wstat - (uintptr_t)inp->inp_wstat_store) +
552 sizeof (*inp->inp_wstat) > sizeof (inp->inp_wstat_store)) {
557 so->so_pcb = (caddr_t)inp;
560 lck_mtx_init(&inp->inpcb_mtx, pcbinfo->ipi_lock_grp,
567 inp->inp_flags |= IN6P_IPV6_V6ONLY;
570 inp->inp_flags |= IN6P_AUTOFLOWLABEL;
573 (void) inp_update_policy(inp);
576 inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
577 LIST_INSERT_HEAD(pcbinfo->ipi_listhead, inp, inp_list);
596 struct inpcb *inp;
599 inp = in_pcblookup_local(pcbinfo, laddr, lport_arg, wild_okay);
602 if (inp != NULL && inp->inp_wantcnt == WNT_STOPUSING) {
603 struct socket *so = inp->inp_socket;
605 lck_mtx_lock(&inp->inpcb_mtx);
608 if (inp->inp_state != INPCB_STATE_DEAD)
609 in_pcbdetach(inp);
610 in_pcbdispose(inp); /* will unlock & destroy */
611 inp = NULL;
613 lck_mtx_unlock(&inp->inpcb_mtx);
617 return (inp);
659 in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct proc *p)
661 struct socket *so = inp->inp_socket;
663 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
671 if (inp->inp_lport != 0 || inp->inp_laddr.s_addr != INADDR_ANY)
757 inp->inp_pcbinfo, SIN(nam)->sin_addr, lport,
805 inp->inp_laddr = SIN(nam)->sin_addr;
806 inp->inp_last_outifp = outif;
824 inp->inp_flags |= INP_ANONPORT;
826 if (inp->inp_flags & INP_HIGHPORT) {
830 } else if (inp->inp_flags & INP_LOWPORT) {
874 inp->inp_laddr.s_addr = INADDR_ANY;
875 inp->inp_last_outifp = NULL;
883 inp->inp_laddr, lport, wild));
899 inp->inp_laddr.s_addr = INADDR_ANY;
900 inp->inp_last_outifp = NULL;
908 inp->inp_laddr, lport, wild));
912 inp->inp_lport = lport;
913 if (in_pcbinshash(inp, 1) != 0) {
914 inp->inp_laddr.s_addr = INADDR_ANY;
915 inp->inp_lport = 0;
916 inp->inp_last_outifp = NULL;
946 in_pcbladdr(struct inpcb *inp, struct sockaddr *nam, struct in_addr *laddr,
949 boolean_t nocell = (inp->inp_flags & INP_NO_IFT_CELLULAR);
950 struct route *ro = &inp->inp_route;
991 if (inp->inp_laddr.s_addr != INADDR_ANY) {
993 *laddr = inp->inp_laddr;
1001 if (ifscope == IFSCOPE_NONE && (inp->inp_flags & INP_BOUND_IF))
1002 ifscope = inp->inp_boundifp->if_index;
1014 (inp->inp_socket->so_options & SO_DONTROUTE)) {
1019 if (!(inp->inp_socket->so_options & SO_DONTROUTE) &&
1108 inp->inp_moptions != NULL) {
1112 imo = inp->inp_moptions;
1174 soevent(inp->inp_socket, (SO_FILT_HINT_LOCKED |
1192 in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct proc *p,
1203 if ((error = in_pcbladdr(inp, nam, &laddr, ifscope, outif)) != 0)
1206 socket_unlock(inp->inp_socket, 0);
1207 pcb = in_pcblookup_hash(inp->inp_pcbinfo, sin->sin_addr, sin->sin_port,
1208 inp->inp_laddr.s_addr ? inp->inp_laddr : laddr,
1209 inp->inp_lport, 0, NULL);
1210 socket_lock(inp->inp_socket, 0);
1217 if ((inp->inp_socket->so_flags & SOF_ABORTED) != 0)
1221 in_pcb_checkstate(pcb, WNT_RELEASE, pcb == inp ? 1 : 0);
1224 if (inp->inp_laddr.s_addr == INADDR_ANY) {
1225 if (inp->inp_lport == 0) {
1226 error = in_pcbbind(inp, NULL, p);
1230 if (!lck_rw_try_lock_exclusive(inp->inp_pcbinfo->ipi_lock)) {
1235 socket_unlock(inp->inp_socket, 0);
1236 lck_rw_lock_exclusive(inp->inp_pcbinfo->ipi_lock);
1237 socket_lock(inp->inp_socket, 0);
1239 inp->inp_laddr = laddr;
1241 inp->inp_last_outifp = (outif != NULL) ? *outif : NULL;
1242 inp->inp_flags |= INP_INADDR_ANY;
1244 if (!lck_rw_try_lock_exclusive(inp->inp_pcbinfo->ipi_lock)) {
1249 socket_unlock(inp->inp_socket, 0);
1250 lck_rw_lock_exclusive(inp->inp_pcbinfo->ipi_lock);
1251 socket_lock(inp->inp_socket, 0);
1254 inp->inp_faddr = sin->sin_addr;
1255 inp->inp_fport = sin->sin_port;
1256 in_pcbrehash(inp);
1257 lck_rw_done(inp->inp_pcbinfo->ipi_lock);
1262 in_pcbdisconnect(struct inpcb *inp)
1264 struct socket *so = inp->inp_socket;
1266 inp->inp_faddr.s_addr = INADDR_ANY;
1267 inp->inp_fport = 0;
1269 if (!lck_rw_try_lock_exclusive(inp->inp_pcbinfo->ipi_lock)) {
1272 lck_rw_lock_exclusive(inp->inp_pcbinfo->ipi_lock);
1276 in_pcbrehash(inp);
1277 lck_rw_done(inp->inp_pcbinfo->ipi_lock);
1284 in_pcbdetach(inp);
1288 in_pcbdetach(struct inpcb *inp)
1290 struct socket *so = inp->inp_socket;
1294 panic("%s: inp=%p so=%p proto=%d so_pcb is null!\n", __func__,
1295 inp, so, SOCK_PROTO(so));
1300 if (inp->inp_sp != NULL) {
1301 (void) ipsec4_delete_pcbpolicy(inp);
1306 if (in_pcb_checkstate(inp, WNT_STOPUSING, 1) != WNT_STOPUSING) {
1315 inp->inp_vflag = 0;
1316 if (inp->inp_options != NULL) {
1317 (void) m_free(inp->inp_options);
1318 inp->inp_options = NULL;
1320 ROUTE_RELEASE(&inp->inp_route);
1321 imo = inp->inp_moptions;
1322 inp->inp_moptions = NULL;
1326 inp->inp_state = INPCB_STATE_DEAD;
1330 inpcb_gc_sched(inp->inp_pcbinfo, INPCB_TIMER_FAST);
1336 in_pcbdispose(struct inpcb *inp)
1338 struct socket *so = inp->inp_socket;
1339 struct inpcbinfo *ipi = inp->inp_pcbinfo;
1346 } else if (inp->inp_wantcnt != WNT_STOPUSING) {
1348 panic_plain("%s: inp %p invalid wantcnt %d, so %p "
1350 "flags 0x%x lockhistory %s\n", __func__, inp,
1351 inp->inp_wantcnt, so, SOCK_DOM(so), SOCK_TYPE(so),
1356 panic("%s: inp %p invalid wantcnt %d no socket\n",
1357 __func__, inp, inp->inp_wantcnt);
1364 inp->inp_gencnt = ++ipi->ipi_gencnt;
1366 in_pcbremlists(inp);
1384 lck_mtx_unlock(&inp->inpcb_mtx);
1385 lck_mtx_destroy(&inp->inpcb_mtx, ipi->ipi_lock_grp);
1389 so->so_saved_pcb = (caddr_t)inp;
1391 inp->inp_socket = NULL;
1393 mac_inpcb_label_destroy(inp);
1400 ROUTE_RELEASE(&inp->inp_route);
1402 zfree(ipi->ipi_zone, inp);
1417 struct inpcb *inp;
1430 if ((inp = sotoinpcb(so)) == NULL) {
1434 sin->sin_port = inp->inp_lport;
1435 sin->sin_addr = inp->inp_laddr;
1445 struct inpcb *inp;
1453 if ((inp = sotoinpcb(so)) == NULL ||
1454 (inp->inp_flags2 & INP2_WANT_FLOW_DIVERT))
1455 return (inp == NULL ? EINVAL : EPROTOTYPE);
1457 sin->sin_port = inp->inp_lport;
1458 sin->sin_addr = inp->inp_laddr;
1465 struct inpcb *inp;
1478 if ((inp = sotoinpcb(so)) == NULL) {
1482 sin->sin_port = inp->inp_fport;
1483 sin->sin_addr = inp->inp_faddr;
1493 struct inpcb *inp;
1501 if ((inp = sotoinpcb(so)) == NULL ||
1502 (inp->inp_flags2 & INP2_WANT_FLOW_DIVERT)) {
1503 return (inp == NULL ? EINVAL : EPROTOTYPE);
1506 sin->sin_port = inp->inp_fport;
1507 sin->sin_addr = inp->inp_faddr;
1515 struct inpcb *inp;
1519 LIST_FOREACH(inp, pcbinfo->ipi_listhead, inp_list) {
1521 if (!(inp->inp_vflag & INP_IPV4))
1524 if (inp->inp_faddr.s_addr != faddr.s_addr ||
1525 inp->inp_socket == NULL)
1527 if (in_pcb_checkstate(inp, WNT_ACQUIRE, 0) == WNT_STOPUSING)
1529 socket_lock(inp->inp_socket, 1);
1530 (*notify)(inp, errno);
1531 (void) in_pcb_checkstate(inp, WNT_RELEASE, 1);
1532 socket_unlock(inp->inp_socket, 1);
1544 in_losing(struct inpcb *inp)
1550 if ((rt = inp->inp_route.ro_rt) != NULL) {
1556 (struct sockaddr *)&inp->inp_route.ro_dst;
1574 if (inp->inp_laddr.s_addr != INADDR_ANY &&
1575 (ia = ifa_foraddr(inp->inp_laddr.s_addr)) != NULL) {
1586 ROUTE_RELEASE(&inp->inp_route);
1594 in_rtchange(struct inpcb *inp, int errno)
1600 if ((rt = inp->inp_route.ro_rt) != NULL) {
1604 if (inp->inp_laddr.s_addr != INADDR_ANY &&
1605 (ia = ifa_foraddr(inp->inp_laddr.s_addr)) != NULL) {
1616 ROUTE_RELEASE(&inp->inp_route);
1626 struct inpcb *inp;
1640 LIST_FOREACH(inp, head, inp_hash) {
1642 if (!(inp->inp_vflag & INP_IPV4))
1645 if (inp->inp_faddr.s_addr == INADDR_ANY &&
1646 inp->inp_laddr.s_addr == laddr.s_addr &&
1647 inp->inp_lport == lport) {
1651 return (inp);
1680 LIST_FOREACH(inp, &phd->phd_pcblist, inp_portlist) {
1683 if (!(inp->inp_vflag & INP_IPV4))
1686 if (inp->inp_faddr.s_addr != INADDR_ANY)
1688 if (inp->inp_laddr.s_addr != INADDR_ANY) {
1691 else if (inp->inp_laddr.s_addr !=
1699 match = inp;
1722 struct inpcb *inp;
1744 LIST_FOREACH(inp, head, inp_hash) {
1746 if (!(inp->inp_vflag & INP_IPV4))
1749 if (inp_restricted(inp, ifp))
1753 (inp->inp_flags & INP_NO_IFT_CELLULAR))
1756 if (inp->inp_faddr.s_addr == faddr.s_addr &&
1757 inp->inp_laddr.s_addr == laddr.s_addr &&
1758 inp->inp_fport == fport &&
1759 inp->inp_lport == lport) {
1760 if ((found = (inp->inp_socket != NULL))) {
1765 inp->inp_socket->so_cred);
1767 inp->inp_socket->so_cred);
1784 LIST_FOREACH(inp, head, inp_hash) {
1786 if (!(inp->inp_vflag & INP_IPV4))
1789 if (inp_restricted(inp, ifp))
1793 (inp->inp_flags & INP_NO_IFT_CELLULAR))
1796 if (inp->inp_faddr.s_addr == INADDR_ANY &&
1797 inp->inp_lport == lport) {
1798 if (inp->inp_laddr.s_addr == laddr.s_addr) {
1799 if ((found = (inp->inp_socket != NULL))) {
1801 inp->inp_socket->so_cred);
1803 inp->inp_socket->so_cred);
1807 } else if (inp->inp_laddr.s_addr == INADDR_ANY) {
1809 if (inp->inp_socket &&
1810 SOCK_CHECK_DOM(inp->inp_socket, PF_INET6))
1811 local_wild_mapped = inp;
1814 local_wild = inp;
1853 struct inpcb *inp;
1871 LIST_FOREACH(inp, head, inp_hash) {
1873 if (!(inp->inp_vflag & INP_IPV4))
1876 if (inp_restricted(inp, ifp))
1880 (inp->inp_flags & INP_NO_IFT_CELLULAR))
1883 if (inp->inp_faddr.s_addr == faddr.s_addr &&
1884 inp->inp_laddr.s_addr == laddr.s_addr &&
1885 inp->inp_fport == fport &&
1886 inp->inp_lport == lport) {
1890 if (in_pcb_checkstate(inp, WNT_ACQUIRE, 0) !=
1893 return (inp);
1912 LIST_FOREACH(inp, head, inp_hash) {
1914 if (!(inp->inp_vflag & INP_IPV4))
1917 if (inp_restricted(inp, ifp))
1921 (inp->inp_flags & INP_NO_IFT_CELLULAR))
1924 if (inp->inp_faddr.s_addr == INADDR_ANY &&
1925 inp->inp_lport == lport) {
1926 if (inp->inp_laddr.s_addr == laddr.s_addr) {
1927 if (in_pcb_checkstate(inp, WNT_ACQUIRE, 0) !=
1930 return (inp);
1936 } else if (inp->inp_laddr.s_addr == INADDR_ANY) {
1938 if (SOCK_CHECK_DOM(inp->inp_socket, PF_INET6))
1939 local_wild_mapped = inp;
1942 local_wild = inp;
1978 in_pcbinshash(struct inpcb *inp, int locked)
1982 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
1992 socket_unlock(inp->inp_socket, 0);
1994 socket_lock(inp->inp_socket, 0);
1995 if (inp->inp_state == INPCB_STATE_DEAD) {
2007 if (inp->inp_vflag & INP_IPV6)
2008 hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */;
2011 hashkey_faddr = inp->inp_faddr.s_addr;
2013 inp->inp_hash_element = INP_PCBHASH(hashkey_faddr, inp->inp_lport,
2014 inp->inp_fport, pcbinfo->ipi_hashmask);
2016 pcbhash = &pcbinfo->ipi_hashbase[inp->inp_hash_element];
2018 pcbporthash = &pcbinfo->ipi_porthashbase[INP_PCBPORTHASH(inp->inp_lport,
2025 if (phd->phd_port == inp->inp_lport)
2029 VERIFY(inp->inp_state != INPCB_STATE_DEAD);
2042 phd->phd_port = inp->inp_lport;
2046 inp->inp_phd = phd;
2047 LIST_INSERT_HEAD(&phd->phd_pcblist, inp, inp_portlist);
2048 LIST_INSERT_HEAD(pcbhash, inp, inp_hash);
2061 in_pcbrehash(struct inpcb *inp)
2067 if (inp->inp_vflag & INP_IPV6)
2068 hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */;
2071 hashkey_faddr = inp->inp_faddr.s_addr;
2073 inp->inp_hash_element = INP_PCBHASH(hashkey_faddr, inp->inp_lport,
2074 inp->inp_fport, inp->inp_pcbinfo->ipi_hashmask);
2075 head = &inp->inp_pcbinfo->ipi_hashbase[inp->inp_hash_element];
2077 LIST_REMOVE(inp, inp_hash);
2078 LIST_INSERT_HEAD(head, inp, inp_hash);
2086 in_pcbremlists(struct inpcb *inp)
2088 inp->inp_gencnt = ++inp->inp_pcbinfo->ipi_gencnt;
2090 if (inp->inp_lport) {
2091 struct inpcbport *phd = inp->inp_phd;
2093 LIST_REMOVE(inp, inp_hash);
2094 LIST_REMOVE(inp, inp_portlist);
2101 if (inp->inp_flags2 & INP2_TIMEWAIT) {
2103 tcp_remove_from_time_wait(inp);
2104 inp->inp_flags2 &= ~INP2_TIMEWAIT;
2105 VERIFY(inp->inp_pcbinfo->ipi_twcount != 0);
2106 inp->inp_pcbinfo->ipi_twcount--;
2108 /* Remove from global inp list if it is not time-wait */
2109 LIST_REMOVE(inp, inp_list);
2112 if (inp->inp_flags2 & INP2_IN_FCTREE) {
2113 inp_fc_getinp(inp->inp_flowhash, (INPFC_SOLOCKED|INPFC_REMOVE));
2114 VERIFY(!(inp->inp_flags2 & INP2_IN_FCTREE));
2117 inp->inp_pcbinfo->ipi_count--;
2239 inpcb_to_compat(struct inpcb *inp, struct inpcb_compat *inp_compat)
2242 inp_compat->inp_fport = inp->inp_fport;
2243 inp_compat->inp_lport = inp->inp_lport;
2246 inp_compat->inp_gencnt = inp->inp_gencnt;
2247 inp_compat->inp_flags = inp->inp_flags;
2248 inp_compat->inp_flow = inp->inp_flow;
2249 inp_compat->inp_vflag = inp->inp_vflag;
2250 inp_compat->inp_ip_ttl = inp->inp_ip_ttl;
2251 inp_compat->inp_ip_p = inp->inp_ip_p;
2253 inp->inp_dependfaddr.inp6_foreign;
2255 inp->inp_dependladdr.inp6_local;
2256 inp_compat->inp_depend4.inp4_ip_tos = inp->inp_depend4.inp4_ip_tos;
2258 inp_compat->inp_depend6.inp6_cksum = inp->inp_depend6.inp6_cksum;
2260 inp_compat->inp_depend6.inp6_hops = inp->inp_depend6.inp6_hops;
2264 inpcb_to_xinpcb64(struct inpcb *inp, struct xinpcb64 *xinp)
2266 xinp->inp_fport = inp->inp_fport;
2267 xinp->inp_lport = inp->inp_lport;
2268 xinp->inp_gencnt = inp->inp_gencnt;
2269 xinp->inp_flags = inp->inp_flags;
2270 xinp->inp_flow = inp->inp_flow;
2271 xinp->inp_vflag = inp->inp_vflag;
2272 xinp->inp_ip_ttl = inp->inp_ip_ttl;
2273 xinp->inp_ip_p = inp->inp_ip_p;
2274 xinp->inp_dependfaddr.inp6_foreign = inp->inp_dependfaddr.inp6_foreign;
2275 xinp->inp_dependladdr.inp6_local = inp->inp_dependladdr.inp6_local;
2276 xinp->inp_depend4.inp4_ip_tos = inp->inp_depend4.inp4_ip_tos;
2278 xinp->inp_depend6.inp6_cksum = inp->inp_depend6.inp6_cksum;
2280 xinp->inp_depend6.inp6_hops = inp->inp_depend6.inp6_hops;
2310 inp_route_copyout(struct inpcb *inp, struct route *dst)
2312 struct route *src = &inp->inp_route;
2314 lck_mtx_assert(&inp->inpcb_mtx, LCK_MTX_ASSERT_OWNED);
2327 inp_route_copyin(struct inpcb *inp, struct route *src)
2329 struct route *dst = &inp->inp_route;
2331 lck_mtx_assert(&inp->inpcb_mtx, LCK_MTX_ASSERT_OWNED);
2344 inp_bindif(struct inpcb *inp, unsigned int ifscope, struct ifnet **pifp)
2367 inp->inp_boundifp = ifp;
2368 if (inp->inp_boundifp == NULL)
2369 inp->inp_flags &= ~INP_BOUND_IF;
2371 inp->inp_flags |= INP_BOUND_IF;
2374 ROUTE_RELEASE(&inp->inp_route);
2387 inp_set_nocellular(struct inpcb *inp)
2389 inp->inp_flags |= INP_NO_IFT_CELLULAR;
2392 ROUTE_RELEASE(&inp->inp_route);
2400 inp_clear_nocellular(struct inpcb *inp)
2402 struct socket *so = inp->inp_socket;
2410 inp->inp_flags &= ~INP_NO_IFT_CELLULAR;
2413 ROUTE_RELEASE(&inp->inp_route);
2422 inp_set_flow_divert(struct inpcb *inp)
2424 inp->inp_flags2 |= INP2_WANT_FLOW_DIVERT;
2431 inp_clear_flow_divert(struct inpcb *inp)
2433 inp->inp_flags2 &= ~INP2_WANT_FLOW_DIVERT;
2438 * Calculate flow hash for an inp, used by an interface to identify a
2443 inp_calc_flowhash(struct inpcb *inp)
2454 bcopy(&inp->inp_dependladdr, &fh.infh_laddr, sizeof (fh.infh_laddr));
2455 bcopy(&inp->inp_dependfaddr, &fh.infh_faddr, sizeof (fh.infh_faddr));
2457 fh.infh_lport = inp->inp_lport;
2458 fh.infh_fport = inp->inp_fport;
2459 fh.infh_af = (inp->inp_vflag & INP_IPV6) ? AF_INET6 : AF_INET;
2460 fh.infh_proto = inp->inp_ip_p;
2472 inp->inp_flowhash = flowhash;
2474 /* Insert the inp into inp_fc_tree */
2476 tmp_inp = RB_FIND(inp_fc_tree, &inp_fc_tree, inp);
2479 * There is a different inp with the same flowhash.
2490 RB_INSERT(inp_fc_tree, &inp_fc_tree, inp);
2491 inp->inp_flags2 |= INP2_IN_FCTREE;
2500 struct inpcb *inp;
2502 inp = inp_fc_getinp(flowhash, 0);
2504 if (inp == NULL)
2506 inp_fc_feedback(inp);
2510 * Function to compare inp_fc_entries in inp flow control tree
2522 struct inpcb *inp = NULL;
2527 inp = RB_FIND(inp_fc_tree, &inp_fc_tree, &key_inp);
2528 if (inp == NULL) {
2529 /* inp is not present, return */
2535 RB_REMOVE(inp_fc_tree, &inp_fc_tree, inp);
2538 bzero(&(inp->infc_link), sizeof (inp->infc_link));
2539 inp->inp_flags2 &= ~INP2_IN_FCTREE;
2543 if (in_pcb_checkstate(inp, WNT_ACQUIRE, locked) == WNT_STOPUSING)
2544 inp = NULL;
2547 return (inp);
2551 inp_fc_feedback(struct inpcb *inp)
2553 struct socket *so = inp->inp_socket;
2555 /* we already hold a want_cnt on this inp, socket can't be null */
2559 if (in_pcb_checkstate(inp, WNT_RELEASE, 1) == WNT_STOPUSING) {
2569 if (!INP_WAIT_FOR_IF_FEEDBACK(inp)) {
2573 inp_reset_fc_state(inp);
2576 inp_fc_unthrottle_tcp(inp);
2582 inp_reset_fc_state(struct inpcb *inp)
2584 struct socket *so = inp->inp_socket;
2585 int suspended = (INP_IS_FLOW_SUSPENDED(inp)) ? 1 : 0;
2586 int needwakeup = (INP_WAIT_FOR_IF_FEEDBACK(inp)) ? 1 : 0;
2588 inp->inp_flags &= ~(INP_FLOW_CONTROLLED | INP_FLOW_SUSPENDED);
2595 if (inp->inp_sndinprog_cnt > 0)
2596 inp->inp_flags |= INP_FC_FEEDBACK;
2604 inp_set_fc_state(struct inpcb *inp, int advcode)
2614 if (inp->inp_flags & INP_FC_FEEDBACK)
2617 inp->inp_flags &= ~(INP_FLOW_CONTROLLED | INP_FLOW_SUSPENDED);
2618 if ((tmp_inp = inp_fc_getinp(inp->inp_flowhash,
2622 VERIFY(tmp_inp == inp);
2625 inp->inp_flags |= INP_FLOW_CONTROLLED;
2628 inp->inp_flags |= INP_FLOW_SUSPENDED;
2629 soevent(inp->inp_socket,
2633 inp->inp_socket->so_flags |= SOF_SUSPENDED;
2645 inp_flush(struct inpcb *inp, int optval)
2647 u_int32_t flowhash = inp->inp_flowhash;
2659 rtifp = ((inp->inp_route.ro_rt != NULL) ?
2660 inp->inp_route.ro_rt->rt_ifp : NULL);
2661 oifp = inp->inp_last_outifp;
2677 struct inpcb *inp = NULL;
2680 inp = sotoinpcb(so);
2681 if (inp) {
2682 inp->inp_flags &= ~INP_INADDR_ANY;
2688 inp_get_soprocinfo(struct inpcb *inp, struct so_procinfo *soprocinfo)
2690 struct socket *so = inp->inp_socket;
2706 struct inpcb *inp = NULL;
2715 LIST_FOREACH(inp, pcbinfo->ipi_listhead, inp_list) {
2716 if (inp->inp_state != INPCB_STATE_DEAD &&
2717 inp->inp_socket != NULL &&
2718 inp->inp_flowhash == flowhash) {
2720 inp_get_soprocinfo(inp, soprocinfo);
2731 inp_update_cellular_policy(struct inpcb *inp, boolean_t set)
2733 struct socket *so = inp->inp_socket;
2737 VERIFY(inp->inp_state != INPCB_STATE_DEAD);
2739 before = (inp->inp_flags & INP_NO_IFT_CELLULAR);
2741 inp_set_nocellular(inp);
2743 inp_clear_nocellular(inp);
2745 after = (inp->inp_flags & INP_NO_IFT_CELLULAR);
2776 inp_update_flow_divert_policy(struct inpcb *inp, boolean_t set)
2778 struct socket *so = inp->inp_socket;
2782 VERIFY(inp->inp_state != INPCB_STATE_DEAD);
2784 if (set && !(inp->inp_flags2 & INP2_WANT_FLOW_DIVERT)) {
2788 before = (inp->inp_flags2 & INP2_WANT_FLOW_DIVERT);
2790 inp_set_flow_divert(inp);
2792 inp_clear_flow_divert(inp);
2794 after = (inp->inp_flags2 & INP2_WANT_FLOW_DIVERT);
2823 inp_update_policy(struct inpcb *inp)
2826 struct socket *so = inp->inp_socket;
2832 so == NULL || inp->inp_state == INPCB_STATE_DEAD)
2862 inp_update_cellular_policy(inp, TRUE);
2864 inp_update_cellular_policy(inp, FALSE);
2869 inp_update_flow_divert_policy(inp, TRUE);
2871 inp_update_flow_divert_policy(inp, FALSE);
2878 #pragma unused(inp)
2884 inp_restricted(struct inpcb *inp, struct ifnet *ifp)
2886 VERIFY(inp != NULL);
2894 if (inp->inp_flags & INP_RECV_ANYIF)
2897 if ((inp->inp_flags & INP_BOUND_IF) && inp->inp_boundifp == ifp)