10f617ae4SGleb Smirnoff /*- 20f617ae4SGleb Smirnoff * SPDX-License-Identifier: BSD-3-Clause 30f617ae4SGleb Smirnoff * 40f617ae4SGleb Smirnoff * Copyright (c) 1982, 1986, 1990, 1993 50f617ae4SGleb Smirnoff * The Regents of the University of California. 60f617ae4SGleb Smirnoff * Copyright (c) 2010-2011 Juniper Networks, Inc. 70f617ae4SGleb Smirnoff * All rights reserved. 80f617ae4SGleb Smirnoff * 90f617ae4SGleb Smirnoff * Portions of this software were developed by Robert N. M. Watson under 100f617ae4SGleb Smirnoff * contract to Juniper Networks, Inc. 110f617ae4SGleb Smirnoff * 120f617ae4SGleb Smirnoff * Redistribution and use in source and binary forms, with or without 130f617ae4SGleb Smirnoff * modification, are permitted provided that the following conditions 140f617ae4SGleb Smirnoff * are met: 150f617ae4SGleb Smirnoff * 1. Redistributions of source code must retain the above copyright 160f617ae4SGleb Smirnoff * notice, this list of conditions and the following disclaimer. 170f617ae4SGleb Smirnoff * 2. Redistributions in binary form must reproduce the above copyright 180f617ae4SGleb Smirnoff * notice, this list of conditions and the following disclaimer in the 190f617ae4SGleb Smirnoff * documentation and/or other materials provided with the distribution. 200f617ae4SGleb Smirnoff * 3. Neither the name of the University nor the names of its contributors 210f617ae4SGleb Smirnoff * may be used to endorse or promote products derived from this software 220f617ae4SGleb Smirnoff * without specific prior written permission. 230f617ae4SGleb Smirnoff * 240f617ae4SGleb Smirnoff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 250f617ae4SGleb Smirnoff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 260f617ae4SGleb Smirnoff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 270f617ae4SGleb Smirnoff * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 280f617ae4SGleb Smirnoff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 290f617ae4SGleb Smirnoff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 300f617ae4SGleb Smirnoff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 310f617ae4SGleb Smirnoff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 320f617ae4SGleb Smirnoff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 330f617ae4SGleb Smirnoff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 340f617ae4SGleb Smirnoff * SUCH DAMAGE. 350f617ae4SGleb Smirnoff */ 360f617ae4SGleb Smirnoff 370f617ae4SGleb Smirnoff #ifndef _NETINET_IN_PCB_VAR_H_ 380f617ae4SGleb Smirnoff #define _NETINET_IN_PCB_VAR_H_ 390f617ae4SGleb Smirnoff 400f617ae4SGleb Smirnoff /* 410f617ae4SGleb Smirnoff * Definitions shared between netinet/in_pcb.c and netinet6/in6_pcb.c 420f617ae4SGleb Smirnoff */ 430f617ae4SGleb Smirnoff 44a0577692SGleb Smirnoff VNET_DECLARE(uint32_t, in_pcbhashseed); 45a0577692SGleb Smirnoff #define V_in_pcbhashseed VNET(in_pcbhashseed) 46a0577692SGleb Smirnoff 477b92493aSMark Johnston void inp_lock(struct inpcb *inp, const inp_lookup_t lock); 487b92493aSMark Johnston void inp_unlock(struct inpcb *inp, const inp_lookup_t lock); 497b92493aSMark Johnston int inp_trylock(struct inpcb *inp, const inp_lookup_t lock); 50db0ac6deSCy Schubert bool inp_smr_lock(struct inpcb *, const inp_lookup_t); 510f617ae4SGleb Smirnoff int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *, 520f617ae4SGleb Smirnoff struct ucred *, int); 53bafe022bSGleb Smirnoff int in_pcb_lport_dest(const struct inpcb *inp, struct sockaddr *lsa, 540f617ae4SGleb Smirnoff u_short *lportp, struct sockaddr *fsa, u_short fport, 550f617ae4SGleb Smirnoff struct ucred *cred, int lookupflags); 560f617ae4SGleb Smirnoff struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short, 579a413162SMark Johnston int, int, struct ucred *); 58*79fb0d24SGleb Smirnoff int in_pcbinshash(struct inpcb *); 59*79fb0d24SGleb Smirnoff void in_pcbrehash(struct inpcb *); 60*79fb0d24SGleb Smirnoff void in_pcbremhash_locked(struct inpcb *); 610f617ae4SGleb Smirnoff 62ca94f92cSMark Johnston /* 63ca94f92cSMark Johnston * Load balance groups used for the SO_REUSEPORT_LB socket option. Each group 64ca94f92cSMark Johnston * (or unique address:port combination) can be re-used at most 65ca94f92cSMark Johnston * INPCBLBGROUP_SIZMAX (256) times. The inpcbs are stored in il_inp which 66ca94f92cSMark Johnston * is dynamically resized as processes bind/unbind to that specific group. 67ca94f92cSMark Johnston */ 68ca94f92cSMark Johnston struct inpcblbgroup { 69ca94f92cSMark Johnston CK_LIST_ENTRY(inpcblbgroup) il_list; 70ca94f92cSMark Johnston LIST_HEAD(, inpcb) il_pending; /* PCBs waiting for listen() */ 71ca94f92cSMark Johnston struct epoch_context il_epoch_ctx; 72ca94f92cSMark Johnston struct ucred *il_cred; 73ca94f92cSMark Johnston uint16_t il_lport; /* (c) */ 74ca94f92cSMark Johnston u_char il_vflag; /* (c) */ 75ca94f92cSMark Johnston uint8_t il_numa_domain; 76ca94f92cSMark Johnston int il_fibnum; 77ca94f92cSMark Johnston union in_dependaddr il_dependladdr; /* (c) */ 78ca94f92cSMark Johnston #define il_laddr il_dependladdr.id46_addr.ia46_addr4 79ca94f92cSMark Johnston #define il6_laddr il_dependladdr.id6_addr 80ca94f92cSMark Johnston uint32_t il_inpsiz; /* max count in il_inp[] (h) */ 81ca94f92cSMark Johnston uint32_t il_inpcnt; /* cur count in il_inp[] (h) */ 828b3d2c19SMark Johnston uint32_t il_pendcnt; /* cur count in il_pending (h) */ 83ca94f92cSMark Johnston struct inpcb *il_inp[]; /* (h) */ 84ca94f92cSMark Johnston }; 85ca94f92cSMark Johnston 860f617ae4SGleb Smirnoff #endif /* !_NETINET_IN_PCB_VAR_H_ */ 87