Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in_pcb.h
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
CK_LIST_HEAD(inpcbhead, inpcb); | CK_LIST_HEAD(inpcbhead, inpcb); | ||||
CK_LIST_HEAD(inpcbporthead, inpcbport); | CK_LIST_HEAD(inpcbporthead, inpcbport); | ||||
CK_LIST_HEAD(inpcblbgrouphead, inpcblbgroup); | CK_LIST_HEAD(inpcblbgrouphead, inpcblbgroup); | ||||
typedef uint64_t inp_gen_t; | typedef uint64_t inp_gen_t; | ||||
/* | /* | ||||
* PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. | * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. | ||||
* So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing | * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing | ||||
* the following structure. | * the following structure. This requires padding always be zeroed out, | ||||
* which is done right after inpcb allocation and stays through its lifetime. | |||||
*/ | */ | ||||
struct in_addr_4in6 { | struct in_addr_4in6 { | ||||
u_int32_t ia46_pad32[3]; | u_int32_t ia46_pad32[3]; | ||||
struct in_addr ia46_addr4; | struct in_addr ia46_addr4; | ||||
}; | }; | ||||
union in_dependaddr { | union in_dependaddr { | ||||
struct in_addr_4in6 id46_addr; | struct in_addr_4in6 id46_addr; | ||||
▲ Show 20 Lines • Show All 440 Lines • ▼ Show 20 Lines | |||||
#define INP_HASH_WLOCK(ipi) mtx_lock(&(ipi)->ipi_hash_lock) | #define INP_HASH_WLOCK(ipi) mtx_lock(&(ipi)->ipi_hash_lock) | ||||
#define INP_HASH_WUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_hash_lock) | #define INP_HASH_WUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_hash_lock) | ||||
#define INP_HASH_LOCK_ASSERT(ipi) MPASS(SMR_ENTERED((ipi)->ipi_smr) || \ | #define INP_HASH_LOCK_ASSERT(ipi) MPASS(SMR_ENTERED((ipi)->ipi_smr) || \ | ||||
mtx_owned(&(ipi)->ipi_hash_lock)) | mtx_owned(&(ipi)->ipi_hash_lock)) | ||||
#define INP_HASH_WLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_hash_lock, \ | #define INP_HASH_WLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_hash_lock, \ | ||||
MA_OWNED) | MA_OWNED) | ||||
/* | |||||
* Wildcard matching hash is not just a microoptimisation! The hash for | |||||
* wildcard IPv4 and wildcard IPv6 must be the same, otherwise AF_INET6 | |||||
* wildcard bound pcb won't be able to receive AF_INET connections, while: | |||||
* jenkins_hash(&zeroes, 1, s) != jenkins_hash(&zeroes, 4, s) | |||||
* See also comment above struct in_addr_4in6. | |||||
*/ | |||||
#define IN_ADDR_JHASH32(addr) \ | |||||
((addr)->s_addr == INADDR_ANY ? V_in_pcbhashseed : \ | |||||
jenkins_hash32((&(addr)->s_addr), 1, V_in_pcbhashseed)) | |||||
#define IN6_ADDR_JHASH32(addr) \ | |||||
(memcmp((addr), &in6addr_any, sizeof(in6addr_any)) == 0 ? \ | |||||
V_in_pcbhashseed : \ | |||||
jenkins_hash32((addr)->__u6_addr.__u6_addr32, \ | |||||
nitems((addr)->__u6_addr.__u6_addr32), V_in_pcbhashseed)) | |||||
#define INP_PCBHASH(faddr, lport, fport, mask) \ | #define INP_PCBHASH(faddr, lport, fport, mask) \ | ||||
(((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) | ((IN_ADDR_JHASH32(faddr) ^ ntohs((lport) ^ (fport))) & (mask)) | ||||
#define INP_PCBPORTHASH(lport, mask) \ | #define INP6_PCBHASH(faddr, lport, fport, mask) \ | ||||
(ntohs((lport)) & (mask)) | ((IN6_ADDR_JHASH32(faddr) ^ ntohs((lport) ^ (fport))) & (mask)) | ||||
#define INP_PCBHASH_WILD(lport, mask) \ | |||||
((V_in_pcbhashseed ^ ntohs(lport)) & (mask)) | |||||
#define INP_PCBLBGROUP_PKTHASH(faddr, lport, fport) \ | #define INP_PCBLBGROUP_PKTHASH(faddr, lport, fport) \ | ||||
((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) | (IN_ADDR_JHASH32(faddr) ^ ntohs((lport) ^ (fport))) | ||||
#define INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3]) | #define INP6_PCBLBGROUP_PKTHASH(faddr, lport, fport) \ | ||||
(IN6_ADDR_JHASH32(faddr) ^ ntohs((lport) ^ (fport))) | |||||
#define INP_PCBPORTHASH(lport, mask) (ntohs((lport)) & (mask)) | |||||
/* | /* | ||||
* Flags for inp_vflags -- historically version flags only | * Flags for inp_vflags -- historically version flags only | ||||
*/ | */ | ||||
#define INP_IPV4 0x1 | #define INP_IPV4 0x1 | ||||
#define INP_IPV6 0x2 | #define INP_IPV6 0x2 | ||||
#define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */ | #define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */ | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |