Introduce INP6_PCBHASHKEY macro. Replace usage of hardcoded part of
IPv6 address as hash key in all places. Obtained from: Yandex LLC
This commit is contained in:
parent
f7f6c6024d
commit
1b44e5ffe3
@ -2046,7 +2046,7 @@ in_pcbinshash_internal(struct inpcb *inp, int do_pcbgroup_update)
|
|||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
if (inp->inp_vflag & INP_IPV6)
|
if (inp->inp_vflag & INP_IPV6)
|
||||||
hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */;
|
hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
hashkey_faddr = inp->inp_faddr.s_addr;
|
hashkey_faddr = inp->inp_faddr.s_addr;
|
||||||
@ -2133,7 +2133,7 @@ in_pcbrehash_mbuf(struct inpcb *inp, struct mbuf *m)
|
|||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
if (inp->inp_vflag & INP_IPV6)
|
if (inp->inp_vflag & INP_IPV6)
|
||||||
hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */;
|
hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
hashkey_faddr = inp->inp_faddr.s_addr;
|
hashkey_faddr = inp->inp_faddr.s_addr;
|
||||||
|
@ -487,6 +487,7 @@ short inp_so_options(const struct inpcb *inp);
|
|||||||
(((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 INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flags for inp_vflags -- historically version flags only
|
* Flags for inp_vflags -- historically version flags only
|
||||||
|
@ -416,7 +416,7 @@ in_pcbgroup_update_internal(struct inpcbinfo *pcbinfo,
|
|||||||
if (newpcbgroup != NULL && oldpcbgroup != newpcbgroup) {
|
if (newpcbgroup != NULL && oldpcbgroup != newpcbgroup) {
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
if (inp->inp_vflag & INP_IPV6)
|
if (inp->inp_vflag & INP_IPV6)
|
||||||
hashkey_faddr = inp->in6p_faddr.s6_addr32[3]; /* XXX */
|
hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
hashkey_faddr = inp->inp_faddr.s_addr;
|
hashkey_faddr = inp->inp_faddr.s_addr;
|
||||||
|
@ -709,8 +709,9 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr,
|
|||||||
* Look for an unconnected (wildcard foreign addr) PCB that
|
* Look for an unconnected (wildcard foreign addr) PCB that
|
||||||
* matches the local address and port we're looking for.
|
* matches the local address and port we're looking for.
|
||||||
*/
|
*/
|
||||||
head = &pcbinfo->ipi_hashbase[INP_PCBHASH(INADDR_ANY, lport,
|
head = &pcbinfo->ipi_hashbase[INP_PCBHASH(
|
||||||
0, pcbinfo->ipi_hashmask)];
|
INP6_PCBHASHKEY(&in6addr_any), lport, 0,
|
||||||
|
pcbinfo->ipi_hashmask)];
|
||||||
LIST_FOREACH(inp, head, inp_hash) {
|
LIST_FOREACH(inp, head, inp_hash) {
|
||||||
/* XXX inp locking */
|
/* XXX inp locking */
|
||||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||||
@ -878,9 +879,8 @@ in6_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup,
|
|||||||
*/
|
*/
|
||||||
tmpinp = NULL;
|
tmpinp = NULL;
|
||||||
INP_GROUP_LOCK(pcbgroup);
|
INP_GROUP_LOCK(pcbgroup);
|
||||||
head = &pcbgroup->ipg_hashbase[
|
head = &pcbgroup->ipg_hashbase[INP_PCBHASH(
|
||||||
INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport,
|
INP6_PCBHASHKEY(faddr), lport, fport, pcbgroup->ipg_hashmask)];
|
||||||
pcbgroup->ipg_hashmask)];
|
|
||||||
LIST_FOREACH(inp, head, inp_pcbgrouphash) {
|
LIST_FOREACH(inp, head, inp_pcbgrouphash) {
|
||||||
/* XXX inp locking */
|
/* XXX inp locking */
|
||||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||||
@ -985,8 +985,9 @@ in6_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup,
|
|||||||
* 3. non-jailed, non-wild.
|
* 3. non-jailed, non-wild.
|
||||||
* 4. non-jailed, wild.
|
* 4. non-jailed, wild.
|
||||||
*/
|
*/
|
||||||
head = &pcbinfo->ipi_wildbase[INP_PCBHASH(INADDR_ANY, lport,
|
head = &pcbinfo->ipi_wildbase[INP_PCBHASH(
|
||||||
0, pcbinfo->ipi_wildmask)];
|
INP6_PCBHASHKEY(&in6addr_any), lport, 0,
|
||||||
|
pcbinfo->ipi_wildmask)];
|
||||||
LIST_FOREACH(inp, head, inp_pcbgroup_wild) {
|
LIST_FOREACH(inp, head, inp_pcbgroup_wild) {
|
||||||
/* XXX inp locking */
|
/* XXX inp locking */
|
||||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||||
@ -1081,9 +1082,8 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr,
|
|||||||
* First look for an exact match.
|
* First look for an exact match.
|
||||||
*/
|
*/
|
||||||
tmpinp = NULL;
|
tmpinp = NULL;
|
||||||
head = &pcbinfo->ipi_hashbase[
|
head = &pcbinfo->ipi_hashbase[INP_PCBHASH(
|
||||||
INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport,
|
INP6_PCBHASHKEY(faddr), lport, fport, pcbinfo->ipi_hashmask)];
|
||||||
pcbinfo->ipi_hashmask)];
|
|
||||||
LIST_FOREACH(inp, head, inp_hash) {
|
LIST_FOREACH(inp, head, inp_hash) {
|
||||||
/* XXX inp locking */
|
/* XXX inp locking */
|
||||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||||
@ -1121,8 +1121,9 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr,
|
|||||||
* 3. non-jailed, non-wild.
|
* 3. non-jailed, non-wild.
|
||||||
* 4. non-jailed, wild.
|
* 4. non-jailed, wild.
|
||||||
*/
|
*/
|
||||||
head = &pcbinfo->ipi_hashbase[INP_PCBHASH(INADDR_ANY, lport,
|
head = &pcbinfo->ipi_hashbase[INP_PCBHASH(
|
||||||
0, pcbinfo->ipi_hashmask)];
|
INP6_PCBHASHKEY(&in6addr_any), lport, 0,
|
||||||
|
pcbinfo->ipi_hashmask)];
|
||||||
LIST_FOREACH(inp, head, inp_hash) {
|
LIST_FOREACH(inp, head, inp_hash) {
|
||||||
/* XXX inp locking */
|
/* XXX inp locking */
|
||||||
if ((inp->inp_vflag & INP_IPV6) == 0)
|
if ((inp->inp_vflag & INP_IPV6) == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user