From owner-svn-src-head@FreeBSD.ORG Wed Sep 10 12:35:43 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 55E6FF3A; Wed, 10 Sep 2014 12:35:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 353ACBE9; Wed, 10 Sep 2014 12:35:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8ACZhVc031310; Wed, 10 Sep 2014 12:35:43 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8ACZgMl031306; Wed, 10 Sep 2014 12:35:42 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201409101235.s8ACZgMl031306@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 10 Sep 2014 12:35:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271386 - in head/sys: netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Sep 2014 12:35:43 -0000 Author: ae Date: Wed Sep 10 12:35:42 2014 New Revision: 271386 URL: http://svnweb.freebsd.org/changeset/base/271386 Log: Introduce INP6_PCBHASHKEY macro. Replace usage of hardcoded part of IPv6 address as hash key in all places. Obtained from: Yandex LLC Modified: head/sys/netinet/in_pcb.c head/sys/netinet/in_pcb.h head/sys/netinet/in_pcbgroup.c head/sys/netinet6/in6_pcb.c Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Wed Sep 10 11:48:13 2014 (r271385) +++ head/sys/netinet/in_pcb.c Wed Sep 10 12:35:42 2014 (r271386) @@ -2046,7 +2046,7 @@ in_pcbinshash_internal(struct inpcb *inp #ifdef INET6 if (inp->inp_vflag & INP_IPV6) - hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */; + hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr); else #endif hashkey_faddr = inp->inp_faddr.s_addr; @@ -2133,7 +2133,7 @@ in_pcbrehash_mbuf(struct inpcb *inp, str #ifdef INET6 if (inp->inp_vflag & INP_IPV6) - hashkey_faddr = inp->in6p_faddr.s6_addr32[3] /* XXX */; + hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr); else #endif hashkey_faddr = inp->inp_faddr.s_addr; Modified: head/sys/netinet/in_pcb.h ============================================================================== --- head/sys/netinet/in_pcb.h Wed Sep 10 11:48:13 2014 (r271385) +++ head/sys/netinet/in_pcb.h Wed Sep 10 12:35:42 2014 (r271386) @@ -487,6 +487,7 @@ short inp_so_options(const struct inpcb (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) #define INP_PCBPORTHASH(lport, mask) \ (ntohs((lport)) & (mask)) +#define INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3]) /* * Flags for inp_vflags -- historically version flags only Modified: head/sys/netinet/in_pcbgroup.c ============================================================================== --- head/sys/netinet/in_pcbgroup.c Wed Sep 10 11:48:13 2014 (r271385) +++ head/sys/netinet/in_pcbgroup.c Wed Sep 10 12:35:42 2014 (r271386) @@ -416,7 +416,7 @@ in_pcbgroup_update_internal(struct inpcb if (newpcbgroup != NULL && oldpcbgroup != newpcbgroup) { #ifdef INET6 if (inp->inp_vflag & INP_IPV6) - hashkey_faddr = inp->in6p_faddr.s6_addr32[3]; /* XXX */ + hashkey_faddr = INP6_PCBHASHKEY(&inp->in6p_faddr); else #endif hashkey_faddr = inp->inp_faddr.s_addr; Modified: head/sys/netinet6/in6_pcb.c ============================================================================== --- head/sys/netinet6/in6_pcb.c Wed Sep 10 11:48:13 2014 (r271385) +++ head/sys/netinet6/in6_pcb.c Wed Sep 10 12:35:42 2014 (r271386) @@ -709,8 +709,9 @@ in6_pcblookup_local(struct inpcbinfo *pc * Look for an unconnected (wildcard foreign addr) PCB that * matches the local address and port we're looking for. */ - head = &pcbinfo->ipi_hashbase[INP_PCBHASH(INADDR_ANY, lport, - 0, pcbinfo->ipi_hashmask)]; + head = &pcbinfo->ipi_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(&in6addr_any), lport, 0, + pcbinfo->ipi_hashmask)]; LIST_FOREACH(inp, head, inp_hash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -878,9 +879,8 @@ in6_pcblookup_group(struct inpcbinfo *pc */ tmpinp = NULL; INP_GROUP_LOCK(pcbgroup); - head = &pcbgroup->ipg_hashbase[ - INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport, - pcbgroup->ipg_hashmask)]; + head = &pcbgroup->ipg_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(faddr), lport, fport, pcbgroup->ipg_hashmask)]; LIST_FOREACH(inp, head, inp_pcbgrouphash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -985,8 +985,9 @@ in6_pcblookup_group(struct inpcbinfo *pc * 3. non-jailed, non-wild. * 4. non-jailed, wild. */ - head = &pcbinfo->ipi_wildbase[INP_PCBHASH(INADDR_ANY, lport, - 0, pcbinfo->ipi_wildmask)]; + head = &pcbinfo->ipi_wildbase[INP_PCBHASH( + INP6_PCBHASHKEY(&in6addr_any), lport, 0, + pcbinfo->ipi_wildmask)]; LIST_FOREACH(inp, head, inp_pcbgroup_wild) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -1081,9 +1082,8 @@ in6_pcblookup_hash_locked(struct inpcbin * First look for an exact match. */ tmpinp = NULL; - head = &pcbinfo->ipi_hashbase[ - INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport, - pcbinfo->ipi_hashmask)]; + head = &pcbinfo->ipi_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(faddr), lport, fport, pcbinfo->ipi_hashmask)]; LIST_FOREACH(inp, head, inp_hash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) @@ -1121,8 +1121,9 @@ in6_pcblookup_hash_locked(struct inpcbin * 3. non-jailed, non-wild. * 4. non-jailed, wild. */ - head = &pcbinfo->ipi_hashbase[INP_PCBHASH(INADDR_ANY, lport, - 0, pcbinfo->ipi_hashmask)]; + head = &pcbinfo->ipi_hashbase[INP_PCBHASH( + INP6_PCBHASHKEY(&in6addr_any), lport, 0, + pcbinfo->ipi_hashmask)]; LIST_FOREACH(inp, head, inp_hash) { /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0)