* Lookup PCB in hash list, using pcbinfo tables. This variation locks the * hash list lock, and will return the inpcb locked (i.e., requires * INPLOOKUP_LOCKPCB). */
| 2614 | * INPLOOKUP_LOCKPCB). |
| 2615 | */ |
| 2616 | static struct inpcb * |
| 2617 | in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, |
| 2618 | u_int fport, struct in_addr laddr, u_int lport, int lookupflags, |
| 2619 | struct ifnet *ifp, uint8_t numa_domain) |
| 2620 | { |
| 2621 | struct inpcb *inp; |
| 2622 | |
| 2623 | inp = in_pcblookup_hash_locked(pcbinfo, faddr, fport, laddr, lport, |
| 2624 | (lookupflags & ~(INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)), ifp, |
| 2625 | numa_domain); |
| 2626 | if (inp != NULL) { |
| 2627 | if (lookupflags & INPLOOKUP_WLOCKPCB) { |
| 2628 | INP_WLOCK(inp); |
| 2629 | if (__predict_false(inp->inp_flags2 & INP_FREED)) { |
| 2630 | INP_WUNLOCK(inp); |
| 2631 | inp = NULL; |
| 2632 | } |
| 2633 | } else if (lookupflags & INPLOOKUP_RLOCKPCB) { |
| 2634 | INP_RLOCK(inp); |
| 2635 | if (__predict_false(inp->inp_flags2 & INP_FREED)) { |
| 2636 | INP_RUNLOCK(inp); |
| 2637 | inp = NULL; |
| 2638 | } |
| 2639 | } else |
| 2640 | panic("%s: locking bug", __func__); |
| 2641 | #ifdef INVARIANTS |
| 2642 | if (inp != NULL) { |
| 2643 | if (lookupflags & INPLOOKUP_WLOCKPCB) |
| 2644 | INP_WLOCK_ASSERT(inp); |
| 2645 | else |
| 2646 | INP_RLOCK_ASSERT(inp); |
| 2647 | } |
| 2648 | #endif |
| 2649 | } |
| 2650 | |
| 2651 | return (inp); |
| 2652 | } |
| 2653 | |
| 2654 | /* |
| 2655 | * Public inpcb lookup routines, accepting a 4-tuple, and optionally, an mbuf |
no test coverage detected