Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in_pcb.h
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
* 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. | ||||
*/ | */ | ||||
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 { | |||||
struct in_addr_4in6 id46_addr; | |||||
struct in6_addr id6_addr; | |||||
}; | |||||
/* | /* | ||||
* NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. in_conninfo has | * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. in_conninfo has | ||||
* some extra padding to accomplish this. | * some extra padding to accomplish this. | ||||
* NOTE 2: tcp_syncache.c uses first 5 32-bit words, which identify fport, | * NOTE 2: tcp_syncache.c uses first 5 32-bit words, which identify fport, | ||||
* lport, faddr to generate hash, so these fields shouldn't be moved. | * lport, faddr to generate hash, so these fields shouldn't be moved. | ||||
*/ | */ | ||||
struct in_endpoints { | struct in_endpoints { | ||||
u_int16_t ie_fport; /* foreign port */ | u_int16_t ie_fport; /* foreign port */ | ||||
u_int16_t ie_lport; /* local port */ | u_int16_t ie_lport; /* local port */ | ||||
/* protocol dependent part, local and foreign addr */ | /* protocol dependent part, local and foreign addr */ | ||||
union { | union in_dependaddr ie_dependfaddr; /* foreign host table entry */ | ||||
/* foreign host table entry */ | union in_dependaddr ie_dependladdr; /* local host table entry */ | ||||
struct in_addr_4in6 ie46_foreign; | #define ie_faddr ie_dependfaddr.id46_addr.ia46_addr4 | ||||
struct in6_addr ie6_foreign; | #define ie_laddr ie_dependladdr.id46_addr.ia46_addr4 | ||||
} ie_dependfaddr; | #define ie6_faddr ie_dependfaddr.id6_addr | ||||
union { | #define ie6_laddr ie_dependladdr.id6_addr | ||||
/* local host table entry */ | |||||
struct in_addr_4in6 ie46_local; | |||||
struct in6_addr ie6_local; | |||||
} ie_dependladdr; | |||||
u_int32_t ie6_zoneid; /* scope zone id */ | u_int32_t ie6_zoneid; /* scope zone id */ | ||||
}; | }; | ||||
#define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4 | |||||
#define ie_laddr ie_dependladdr.ie46_local.ia46_addr4 | |||||
#define ie6_faddr ie_dependfaddr.ie6_foreign | |||||
#define ie6_laddr ie_dependladdr.ie6_local | |||||
/* | /* | ||||
* XXX The defines for inc_* are hacks and should be changed to direct | * XXX The defines for inc_* are hacks and should be changed to direct | ||||
* references. | * references. | ||||
*/ | */ | ||||
struct in_conninfo { | struct in_conninfo { | ||||
u_int8_t inc_flags; | u_int8_t inc_flags; | ||||
u_int8_t inc_len; | u_int8_t inc_len; | ||||
▲ Show 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | struct inpcbinfo { | ||||
* List of wildcard inpcbs for use with pcbgroups. In the past, was | * List of wildcard inpcbs for use with pcbgroups. In the past, was | ||||
* per-pcbgroup but is now global. All pcbgroup locks must be held | * per-pcbgroup but is now global. All pcbgroup locks must be held | ||||
* to modify the list, so any is sufficient to read it. | * to modify the list, so any is sufficient to read it. | ||||
*/ | */ | ||||
struct inpcbhead *ipi_wildbase; /* (p) */ | struct inpcbhead *ipi_wildbase; /* (p) */ | ||||
u_long ipi_wildmask; /* (p) */ | u_long ipi_wildmask; /* (p) */ | ||||
/* | /* | ||||
* Load balance groups used by the SO_REUSEPORT_LB option, | |||||
* hashed by local port. | |||||
*/ | |||||
struct inpcblbgrouphead *ipi_lbgrouphashbase; /* (h) */ | |||||
u_long ipi_lbgrouphashmask; /* (h) */ | |||||
/* | |||||
* Pointer to network stack instance | * Pointer to network stack instance | ||||
*/ | */ | ||||
struct vnet *ipi_vnet; /* (c) */ | struct vnet *ipi_vnet; /* (c) */ | ||||
/* | /* | ||||
* general use 2 | * general use 2 | ||||
*/ | */ | ||||
void *ipi_pspare[2]; | void *ipi_pspare[2]; | ||||
Show All 25 Lines | struct inpcbgroup { | ||||
/* | /* | ||||
* Per-connection group lock, not to be confused with ipi_lock. | * Per-connection group lock, not to be confused with ipi_lock. | ||||
* Protects the hash table hung off the group, but also the global | * Protects the hash table hung off the group, but also the global | ||||
* wildcard list in inpcbinfo. | * wildcard list in inpcbinfo. | ||||
*/ | */ | ||||
struct mtx ipg_lock; | struct mtx ipg_lock; | ||||
} __aligned(CACHE_LINE_SIZE); | } __aligned(CACHE_LINE_SIZE); | ||||
/* | |||||
* Load balance groups used by the SO_REUSEPORT_LB socket option. Each group | |||||
* (or port) can be re-used at most INPCBLBGROUP_SIZMAX (256) times. | |||||
rwatson: It might be useful for this comment to mention something about il_inp[] behaviour? | |||||
*/ | |||||
struct inpcblbgroup { | |||||
LIST_ENTRY(inpcblbgroup) il_list; | |||||
uint16_t il_lport; /* (c) */ | |||||
u_char il_vflag; /* (c) */ | |||||
u_char il_pad; | |||||
uint32_t il_pad2; | |||||
union in_dependaddr il_dependladdr; /* (c) */ | |||||
#define il_laddr il_dependladdr.id46_addr.ia46_addr4 | |||||
#define il6_laddr il_dependladdr.id6_addr | |||||
uint32_t il_inpsiz; /* max count in il_inp[] */ | |||||
uint32_t il_inpcnt; /* cur count in il_inp[] */ | |||||
struct inpcb *il_inp[]; | |||||
Done Inline ActionsWhat are the locking properties of il_inpsiz, il_inpcnt, and il_inp? rwatson: What are the locking properties of il_inpsiz, il_inpcnt, and il_inp? | |||||
}; | |||||
LIST_HEAD(inpcblbgrouphead, inpcblbgroup); | |||||
#define INP_LOCK_INIT(inp, d, t) \ | #define INP_LOCK_INIT(inp, d, t) \ | ||||
rw_init_flags(&(inp)->inp_lock, (t), RW_RECURSE | RW_DUPOK) | rw_init_flags(&(inp)->inp_lock, (t), RW_RECURSE | RW_DUPOK) | ||||
#define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock) | #define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock) | ||||
#define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock) | #define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock) | ||||
#define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock) | #define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock) | ||||
#define INP_TRY_RLOCK(inp) rw_try_rlock(&(inp)->inp_lock) | #define INP_TRY_RLOCK(inp) rw_try_rlock(&(inp)->inp_lock) | ||||
#define INP_TRY_WLOCK(inp) rw_try_wlock(&(inp)->inp_lock) | #define INP_TRY_WLOCK(inp) rw_try_wlock(&(inp)->inp_lock) | ||||
#define INP_RUNLOCK(inp) rw_runlock(&(inp)->inp_lock) | #define INP_RUNLOCK(inp) rw_runlock(&(inp)->inp_lock) | ||||
Show All 28 Lines | |||||
int inp_ip_tos_get(const struct inpcb *inp); | int inp_ip_tos_get(const struct inpcb *inp); | ||||
void inp_ip_tos_set(struct inpcb *inp, int val); | void inp_ip_tos_set(struct inpcb *inp, int val); | ||||
struct socket * | struct socket * | ||||
inp_inpcbtosocket(struct inpcb *inp); | inp_inpcbtosocket(struct inpcb *inp); | ||||
struct tcpcb * | struct tcpcb * | ||||
inp_inpcbtotcpcb(struct inpcb *inp); | inp_inpcbtotcpcb(struct inpcb *inp); | ||||
void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, | void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, | ||||
uint32_t *faddr, uint16_t *fp); | uint32_t *faddr, uint16_t *fp); | ||||
short inp_so_options(const struct inpcb *inp); | int inp_so_options(const struct inpcb *inp); | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#define INP_INFO_LOCK_INIT(ipi, d) \ | #define INP_INFO_LOCK_INIT(ipi, d) \ | ||||
rw_init_flags(&(ipi)->ipi_lock, (d), RW_RECURSE) | rw_init_flags(&(ipi)->ipi_lock, (d), RW_RECURSE) | ||||
#define INP_INFO_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_lock) | #define INP_INFO_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_lock) | ||||
#define INP_INFO_RLOCK(ipi) rw_rlock(&(ipi)->ipi_lock) | #define INP_INFO_RLOCK(ipi) rw_rlock(&(ipi)->ipi_lock) | ||||
#define INP_INFO_WLOCK(ipi) rw_wlock(&(ipi)->ipi_lock) | #define INP_INFO_WLOCK(ipi) rw_wlock(&(ipi)->ipi_lock) | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
#define INP_GROUP_LOCK(ipg) mtx_lock(&(ipg)->ipg_lock) | #define INP_GROUP_LOCK(ipg) mtx_lock(&(ipg)->ipg_lock) | ||||
#define INP_GROUP_LOCK_ASSERT(ipg) mtx_assert(&(ipg)->ipg_lock, MA_OWNED) | #define INP_GROUP_LOCK_ASSERT(ipg) mtx_assert(&(ipg)->ipg_lock, MA_OWNED) | ||||
#define INP_GROUP_UNLOCK(ipg) mtx_unlock(&(ipg)->ipg_lock) | #define INP_GROUP_UNLOCK(ipg) mtx_unlock(&(ipg)->ipg_lock) | ||||
#define INP_PCBHASH(faddr, lport, fport, mask) \ | #define INP_PCBHASH(faddr, lport, fport, mask) \ | ||||
(((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) | (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) | ||||
#define INP_PCBPORTHASH(lport, mask) \ | #define INP_PCBPORTHASH(lport, mask) \ | ||||
(ntohs((lport)) & (mask)) | (ntohs((lport)) & (mask)) | ||||
#define INP_PCBLBGROUP_PORTHASH(lport, mask) \ | |||||
(ntohs((lport)) & (mask)) | |||||
#define INP_PCBLBGROUP_PKTHASH(faddr, lport, fport) \ | |||||
((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) | |||||
Done Inline ActionsI have no personal objection to this design choice, which is consistent with other hashes here, but someday we should think about something better for all of these hashes! rwatson: I have no personal objection to this design choice, which is consistent with other hashes here… | |||||
#define INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3]) | #define INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3]) | ||||
/* | /* | ||||
* 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 52 Lines • ▼ Show 20 Lines | |||||
#define INP_REUSEADDR 0x00000020 /* SO_REUSEADDR option is set */ | #define INP_REUSEADDR 0x00000020 /* SO_REUSEADDR option is set */ | ||||
#define INP_BINDMULTI 0x00000040 /* IP_BINDMULTI option is set */ | #define INP_BINDMULTI 0x00000040 /* IP_BINDMULTI option is set */ | ||||
#define INP_RSS_BUCKET_SET 0x00000080 /* IP_RSS_LISTEN_BUCKET is set */ | #define INP_RSS_BUCKET_SET 0x00000080 /* IP_RSS_LISTEN_BUCKET is set */ | ||||
#define INP_RECVFLOWID 0x00000100 /* populate recv datagram with flow info */ | #define INP_RECVFLOWID 0x00000100 /* populate recv datagram with flow info */ | ||||
#define INP_RECVRSSBUCKETID 0x00000200 /* populate recv datagram with bucket id */ | #define INP_RECVRSSBUCKETID 0x00000200 /* populate recv datagram with bucket id */ | ||||
#define INP_RATE_LIMIT_CHANGED 0x00000400 /* rate limit needs attention */ | #define INP_RATE_LIMIT_CHANGED 0x00000400 /* rate limit needs attention */ | ||||
#define INP_ORIGDSTADDR 0x00000800 /* receive IP dst address/port */ | #define INP_ORIGDSTADDR 0x00000800 /* receive IP dst address/port */ | ||||
#define INP_CANNOT_DO_ECN 0x00001000 /* The stack does not do ECN */ | #define INP_CANNOT_DO_ECN 0x00001000 /* The stack does not do ECN */ | ||||
#define INP_REUSEPORT_LB 0x00002000 /* SO_REUSEPORT_LB option is set */ | |||||
/* | /* | ||||
* Flags passed to in_pcblookup*() functions. | * Flags passed to in_pcblookup*() functions. | ||||
*/ | */ | ||||
#define INPLOOKUP_WILDCARD 0x00000001 /* Allow wildcard sockets. */ | #define INPLOOKUP_WILDCARD 0x00000001 /* Allow wildcard sockets. */ | ||||
#define INPLOOKUP_RLOCKPCB 0x00000002 /* Return inpcb read-locked. */ | #define INPLOOKUP_RLOCKPCB 0x00000002 /* Return inpcb read-locked. */ | ||||
#define INPLOOKUP_WLOCKPCB 0x00000004 /* Return inpcb write-locked. */ | #define INPLOOKUP_WLOCKPCB 0x00000004 /* Return inpcb write-locked. */ | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *, | int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *, | ||||
struct ucred *); | struct ucred *); | ||||
struct inpcb * | struct inpcb * | ||||
in_pcblookup_local(struct inpcbinfo *, | in_pcblookup_local(struct inpcbinfo *, | ||||
struct in_addr, u_short, int, struct ucred *); | struct in_addr, u_short, int, struct ucred *); | ||||
struct inpcb * | struct inpcb * | ||||
in_pcblookup(struct inpcbinfo *, struct in_addr, u_int, | in_pcblookup(struct inpcbinfo *, struct in_addr, u_int, | ||||
struct in_addr, u_int, int, struct ifnet *); | struct in_addr, u_int, int, struct ifnet *); | ||||
struct inpcb * | |||||
in_pcblookup_lbgroup_last(struct inpcb *inp); | |||||
struct inpcb * | struct inpcb * | ||||
in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int, | in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int, | ||||
struct in_addr, u_int, int, struct ifnet *, struct mbuf *); | struct in_addr, u_int, int, struct ifnet *, struct mbuf *); | ||||
void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, | void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, | ||||
int, struct inpcb *(*)(struct inpcb *, int)); | int, struct inpcb *(*)(struct inpcb *, int)); | ||||
void in_pcbref(struct inpcb *); | void in_pcbref(struct inpcb *); | ||||
void in_pcbrehash(struct inpcb *); | void in_pcbrehash(struct inpcb *); | ||||
void in_pcbrehash_mbuf(struct inpcb *, struct mbuf *); | void in_pcbrehash_mbuf(struct inpcb *, struct mbuf *); | ||||
Show All 22 Lines |
It might be useful for this comment to mention something about il_inp[] behaviour?