Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/in_pcb.c
Show First 20 Lines • Show All 1,944 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
return (match); | return (match); | ||||
} | } | ||||
} | } | ||||
#undef INP_LOOKUP_MAPPED_PCB_COST | #undef INP_LOOKUP_MAPPED_PCB_COST | ||||
static struct inpcb * | static struct inpcb * | ||||
in_pcblookup_lbgroup(const struct inpcbinfo *pcbinfo, | in_pcblookup_lbgroup(const struct inpcbinfo *pcbinfo, | ||||
const struct in_addr *laddr, uint16_t lport, const struct in_addr *faddr, | const struct in_addr *laddr, uint16_t lport, const struct in_addr *faddr, | ||||
uint16_t fport, int lookupflags) | uint16_t fport, int lookupflags) | ||||
{ | { | ||||
struct inpcb *local_wild = NULL; | struct inpcb *local_wild; | ||||
const struct inpcblbgrouphead *hdr; | const struct inpcblbgrouphead *hdr; | ||||
struct inpcblbgroup *grp; | struct inpcblbgroup *grp; | ||||
struct inpcblbgroup *grp_local_wild; | uint32_t idx; | ||||
INP_HASH_LOCK_ASSERT(pcbinfo); | INP_HASH_LOCK_ASSERT(pcbinfo); | ||||
hdr = &pcbinfo->ipi_lbgrouphashbase[ | hdr = &pcbinfo->ipi_lbgrouphashbase[INP_PCBLBGROUP_PORTHASH(lport, | ||||
INP_PCBLBGROUP_PORTHASH(lport, pcbinfo->ipi_lbgrouphashmask)]; | pcbinfo->ipi_lbgrouphashmask)]; | ||||
/* | /* | ||||
* Order of socket selection: | * Order of socket selection: | ||||
* 1. non-wild. | * 1. non-wild. | ||||
* 2. wild (if lookupflags contains INPLOOKUP_WILDCARD). | * 2. wild (if lookupflags contains INPLOOKUP_WILDCARD). | ||||
* | * | ||||
* NOTE: | * NOTE: | ||||
* - Load balanced group does not contain jailed sockets | * - Load balanced group does not contain jailed sockets | ||||
* - Load balanced group does not contain IPv4 mapped INET6 wild sockets | * - Load balanced group does not contain IPv4 mapped INET6 wild sockets | ||||
*/ | */ | ||||
local_wild = NULL; | |||||
LIST_FOREACH(grp, hdr, il_list) { | LIST_FOREACH(grp, hdr, il_list) { | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (!(grp->il_vflag & INP_IPV4)) | if (!(grp->il_vflag & INP_IPV4)) | ||||
continue; | continue; | ||||
#endif | #endif | ||||
if (grp->il_lport != lport) | |||||
continue; | |||||
if (grp->il_lport == lport) { | idx = INP_PCBLBGROUP_PKTHASH(faddr->s_addr, lport, fport) % | ||||
grp->il_inpcnt; | |||||
uint32_t idx = 0; | if (grp->il_laddr.s_addr == laddr->s_addr) | ||||
int pkt_hash = INP_PCBLBGROUP_PKTHASH(faddr->s_addr, | |||||
lport, fport); | |||||
idx = pkt_hash % grp->il_inpcnt; | |||||
if (grp->il_laddr.s_addr == laddr->s_addr) { | |||||
return (grp->il_inp[idx]); | return (grp->il_inp[idx]); | ||||
} else { | |||||
if (grp->il_laddr.s_addr == INADDR_ANY && | if (grp->il_laddr.s_addr == INADDR_ANY && | ||||
(lookupflags & INPLOOKUP_WILDCARD)) { | (lookupflags & INPLOOKUP_WILDCARD) != 0) | ||||
local_wild = grp->il_inp[idx]; | local_wild = grp->il_inp[idx]; | ||||
grp_local_wild = grp; | |||||
} | } | ||||
} | |||||
} | |||||
} | |||||
if (local_wild != NULL) { | |||||
return (local_wild); | return (local_wild); | ||||
} | |||||
return (NULL); | |||||
} | } | ||||
#ifdef PCBGROUP | #ifdef PCBGROUP | ||||
/* | /* | ||||
* Lookup PCB in hash list, using pcbgroup tables. | * Lookup PCB in hash list, using pcbgroup tables. | ||||
*/ | */ | ||||
static struct inpcb * | static struct inpcb * | ||||
in_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, | in_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, | ||||
▲ Show 20 Lines • Show All 1,449 Lines • Show Last 20 Lines |