summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1997-03-03 09:24:40 +0000
committerDavid Greenman <dg@FreeBSD.org>1997-03-03 09:24:40 +0000
commitab8e448055401d11ec6435cb4f928cc79d55b07c (patch)
treeed07abf1f4bd8db40a3130a875ac4f8fe9851edf
parent216a0aac2327c47bf13299211d2360ee60eb14b9 (diff)
Notes
-rw-r--r--sys/netinet/in_pcb.c14
-rw-r--r--sys/netinet/in_pcb.h7
-rw-r--r--sys/netinet/ip_divert.c4
-rw-r--r--sys/netinet/raw_ip.c4
-rw-r--r--sys/netinet/tcp_subr.c4
-rw-r--r--sys/netinet/udp_usrreq.c4
6 files changed, 20 insertions, 17 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index e5da5fc54c297..93241a71f222f 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
- * $Id: in_pcb.c,v 1.22 1996/10/07 19:06:07 davidg Exp $
+ * $Id: in_pcb.c,v 1.23 1996/10/30 06:13:09 peter Exp $
*/
#include <sys/param.h>
@@ -672,7 +672,7 @@ in_pcblookuphash(pcbinfo, faddr, fport_arg, laddr, lport_arg, wildcard)
/*
* First look for an exact match.
*/
- head = &pcbinfo->hashbase[(faddr.s_addr + lport + fport) % pcbinfo->hashsize];
+ head = &pcbinfo->hashbase[INP_PCBHASH(faddr.s_addr, lport, fport, pcbinfo->hashmask)];
for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
if (inp->inp_faddr.s_addr == faddr.s_addr &&
inp->inp_fport == fport && inp->inp_lport == lport &&
@@ -682,7 +682,7 @@ in_pcblookuphash(pcbinfo, faddr, fport_arg, laddr, lport_arg, wildcard)
if (wildcard) {
struct inpcb *local_wild = NULL;
- head = &pcbinfo->hashbase[(INADDR_ANY + lport) % pcbinfo->hashsize];
+ head = &pcbinfo->hashbase[INP_PCBHASH(INADDR_ANY, lport, 0, pcbinfo->hashmask)];
for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
if (inp->inp_faddr.s_addr == INADDR_ANY &&
inp->inp_fport == 0 && inp->inp_lport == lport) {
@@ -724,8 +724,8 @@ in_pcbinshash(inp)
{
struct inpcbhead *head;
- head = &inp->inp_pcbinfo->hashbase[(inp->inp_faddr.s_addr +
- inp->inp_lport + inp->inp_fport) % inp->inp_pcbinfo->hashsize];
+ head = &inp->inp_pcbinfo->hashbase[INP_PCBHASH(inp->inp_faddr.s_addr,
+ inp->inp_lport, inp->inp_fport, inp->inp_pcbinfo->hashmask)];
LIST_INSERT_HEAD(head, inp, inp_hash);
}
@@ -740,8 +740,8 @@ in_pcbrehash(inp)
s = splnet();
LIST_REMOVE(inp, inp_hash);
- head = &inp->inp_pcbinfo->hashbase[(inp->inp_faddr.s_addr +
- inp->inp_lport + inp->inp_fport) % inp->inp_pcbinfo->hashsize];
+ head = &inp->inp_pcbinfo->hashbase[INP_PCBHASH(inp->inp_faddr.s_addr,
+ inp->inp_lport, inp->inp_fport, inp->inp_pcbinfo->hashmask)];
LIST_INSERT_HEAD(head, inp, inp_hash);
splx(s);
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 67be783407967..770c666f028f3 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
- * $Id: in_pcb.h,v 1.14 1996/10/30 06:13:10 peter Exp $
+ * $Id: in_pcb.h,v 1.14.2.1 1996/11/11 23:40:40 phk Exp $
*/
#ifndef _NETINET_IN_PCB_H_
@@ -68,12 +68,15 @@ struct inpcb {
struct inpcbinfo {
struct inpcbhead *listhead;
struct inpcbhead *hashbase;
- unsigned long hashsize;
+ unsigned long hashmask;
unsigned short lastport;
unsigned short lastlow;
unsigned short lasthi;
};
+#define INP_PCBHASH(faddr, lport, fport, mask) \
+ (((faddr) ^ ((faddr) >> 16) ^ (lport) ^ (fport)) & (mask))
+
/* flags in inp_flags: */
#define INP_RECVOPTS 0x01 /* receive incoming IP options */
#define INP_RECVRETOPTS 0x02 /* receive IP options for reply */
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 8807b4cc60f04..90c8a1b418402 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ip_divert.c,v 1.1 1996/07/10 19:44:22 julian Exp $
+ * $Id: ip_divert.c,v 1.1.2.1 1997/02/02 18:55:33 joerg Exp $
*/
#include <sys/param.h>
@@ -109,7 +109,7 @@ div_init(void)
* to allocate a one entry hash list than it is to check all
* over the place for hashbase == NULL.
*/
- divcbinfo.hashbase = phashinit(1, M_PCB, &divcbinfo.hashsize);
+ divcbinfo.hashbase = hashinit(1, M_PCB, &divcbinfo.hashmask);
}
/*
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index b7c8af94d7be4..764d41837568e 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
- * $Id: raw_ip.c,v 1.37 1996/10/25 17:57:48 fenner Exp $
+ * $Id: raw_ip.c,v 1.37.2.1 1996/11/11 23:40:55 phk Exp $
*/
#include <sys/param.h>
@@ -91,7 +91,7 @@ rip_init()
* to allocate a one entry hash list than it is to check all
* over the place for hashbase == NULL.
*/
- ripcbinfo.hashbase = phashinit(1, M_PCB, &ripcbinfo.hashsize);
+ ripcbinfo.hashbase = hashinit(1, M_PCB, &ripcbinfo.hashmask);
}
static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index d8bde27b8967a..93bfddd7c42d8 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
- * $Id: tcp_subr.c,v 1.30 1996/06/14 17:17:32 wollman Exp $
+ * $Id: tcp_subr.c,v 1.31 1996/07/24 18:46:19 wollman Exp $
*/
#include <sys/param.h>
@@ -107,7 +107,7 @@ tcp_init()
tcp_cleartaocache();
LIST_INIT(&tcb);
tcbinfo.listhead = &tcb;
- tcbinfo.hashbase = phashinit(TCBHASHSIZE, M_PCB, &tcbinfo.hashsize);
+ tcbinfo.hashbase = hashinit(TCBHASHSIZE, M_PCB, &tcbinfo.hashmask);
if (max_protohdr < sizeof(struct tcpiphdr))
max_protohdr = sizeof(struct tcpiphdr);
if (max_linkhdr + sizeof(struct tcpiphdr) > MHLEN)
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 1d7c3f5b21111..cc6b61dc3e6c5 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
- * $Id: udp_usrreq.c,v 1.30 1996/10/25 17:57:53 fenner Exp $
+ * $Id: udp_usrreq.c,v 1.30.2.1 1996/11/11 23:41:00 phk Exp $
*/
#include <sys/param.h>
@@ -100,7 +100,7 @@ udp_init()
{
LIST_INIT(&udb);
udbinfo.listhead = &udb;
- udbinfo.hashbase = phashinit(UDBHASHSIZE, M_PCB, &udbinfo.hashsize);
+ udbinfo.hashbase = hashinit(UDBHASHSIZE, M_PCB, &udbinfo.hashmask);
}
void