Index: sys/conf/options =================================================================== RCS file: /usr/local/cvsup/src/sys/conf/options,v retrieving revision 1.191.2.23 diff -w -c -r1.191.2.23 options *** sys/conf/options 2001/04/26 00:25:18 1.191.2.23 --- sys/conf/options 2001/06/05 19:39:30 *************** *** 297,302 **** --- 297,304 ---- NETGRAPH_UI opt_netgraph.h NETGRAPH_VJC opt_netgraph.h + IF_ADDR_HASH opt_ipaddrhash.h + # ATM (HARP version) ATM_CORE opt_atm.h ATM_IP opt_atm.h Index: sys/conf/param.c =================================================================== RCS file: /usr/local/cvsup/src/sys/conf/param.c,v retrieving revision 1.36.2.2 diff -w -c -r1.36.2.2 param.c *** sys/conf/param.c 2000/08/04 22:31:06 1.36.2.2 --- sys/conf/param.c 2001/06/05 19:39:31 *************** *** 56,69 **** */ #ifndef HZ ! #define HZ 100 #endif int hz = HZ; int tick = 1000000 / HZ; int tickadj = howmany(30000, 60 * HZ); /* can adjust 30ms in 60s */ #define NPROC (20 + 16 * MAXUSERS) #ifndef MAXFILES ! #define MAXFILES (NPROC*2) #endif int maxproc = NPROC; /* maximum # of processes */ int maxprocperuid = NPROC-1; /* maximum # of processes per user */ --- 56,69 ---- */ #ifndef HZ ! #define HZ 1000 #endif int hz = HZ; int tick = 1000000 / HZ; int tickadj = howmany(30000, 60 * HZ); /* can adjust 30ms in 60s */ #define NPROC (20 + 16 * MAXUSERS) #ifndef MAXFILES ! #define MAXFILES 16384 #endif int maxproc = NPROC; /* maximum # of processes */ int maxprocperuid = NPROC-1; /* maximum # of processes per user */ Index: sys/kern/uipc_mbuf.c =================================================================== RCS file: /usr/local/cvsup/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.51.2.3 diff -w -c -r1.51.2.3 uipc_mbuf.c *** sys/kern/uipc_mbuf.c 2000/08/25 23:23:32 1.51.2.3 --- sys/kern/uipc_mbuf.c 2001/06/05 19:39:39 *************** *** 88,94 **** SYSCTL_INT(_kern_ipc, OID_AUTO, nmbufs, CTLFLAG_RD, &nmbufs, 0, "Maximum number of mbufs available"); #ifndef NMBCLUSTERS ! #define NMBCLUSTERS (512 + MAXUSERS * 16) #endif TUNABLE_INT_DECL("kern.ipc.nmbclusters", NMBCLUSTERS, nmbclusters); TUNABLE_INT_DECL("kern.ipc.nmbufs", NMBCLUSTERS * 4, nmbufs); --- 88,94 ---- SYSCTL_INT(_kern_ipc, OID_AUTO, nmbufs, CTLFLAG_RD, &nmbufs, 0, "Maximum number of mbufs available"); #ifndef NMBCLUSTERS ! #define NMBCLUSTERS 32768 #endif TUNABLE_INT_DECL("kern.ipc.nmbclusters", NMBCLUSTERS, nmbclusters); TUNABLE_INT_DECL("kern.ipc.nmbufs", NMBCLUSTERS * 4, nmbufs); Index: sys/netinet/in.c =================================================================== RCS file: /usr/local/cvsup/src/sys/netinet/in.c,v retrieving revision 1.44.2.2 diff -w -c -r1.44.2.2 in.c *** sys/netinet/in.c 2000/08/19 22:14:05 1.44.2.2 --- sys/netinet/in.c 2001/06/05 19:39:43 *************** *** 34,39 **** --- 34,41 ---- * $FreeBSD: src/sys/netinet/in.c,v 1.44.2.1 2000/07/15 07:14:30 kris Exp $ */ + #include "opt_ipaddrhash.h" + #include #include #include *************** *** 52,57 **** --- 54,63 ---- #include + #ifdef IF_ADDR_HASH + extern int ip_addr_hash_status; /* see ip_input.c */ + #endif + #include "gif.h" #if NGIF > 0 #include *************** *** 298,303 **** --- 304,313 ---- ifa = &ia->ia_ifa; TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); + #ifdef IF_ADDR_HASH + ip_addr_hash_status = 0; /* mark hash as stale */ + #endif + ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr; ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr; ifa->ifa_netmask = (struct sockaddr *)&ia->ia_sockmask; *************** *** 428,433 **** --- 438,446 ---- oia = ia; TAILQ_REMOVE(&in_ifaddrhead, oia, ia_link); IFAFREE(&oia->ia_ifa); + #ifdef IF_ADDR_HASH + ip_addr_hash_status = 0; /* mark hash as stale */ + #endif splx(s); break; Index: sys/netinet/in.h =================================================================== RCS file: /usr/local/cvsup/src/sys/netinet/in.h,v retrieving revision 1.48.2.2 diff -w -c -r1.48.2.2 in.h *** sys/netinet/in.h 2001/04/21 14:53:06 1.48.2.2 --- sys/netinet/in.h 2001/06/05 19:39:43 *************** *** 210,216 **** * for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) */ #define IPPORT_RESERVED 1024 ! #define IPPORT_USERRESERVED 5000 /* * Default local port range to use by setting IP_PORTRANGE_HIGH --- 210,216 ---- * for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) */ #define IPPORT_RESERVED 1024 ! #define IPPORT_USERRESERVED 40000 /* * Default local port range to use by setting IP_PORTRANGE_HIGH Index: sys/netinet/ip_input.c =================================================================== RCS file: /usr/local/cvsup/src/sys/netinet/ip_input.c,v retrieving revision 1.130.2.21 diff -w -c -r1.130.2.21 ip_input.c *** sys/netinet/ip_input.c 2001/03/08 23:14:54 1.130.2.21 --- sys/netinet/ip_input.c 2001/06/05 19:39:43 *************** *** 43,48 **** --- 43,49 ---- #include "opt_ipfilter.h" #include "opt_ipstealth.h" #include "opt_ipsec.h" + #include "opt_ipaddrhash.h" #include #include *************** *** 157,162 **** --- 158,184 ---- SYSCTL_STRUCT(_net_inet_ip, IPCTL_STATS, stats, CTLFLAG_RD, &ipstat, ipstat, "IP statistics (struct ipstat, netinet/ip_var.h)"); + + #ifdef IF_ADDR_HASH + /* global variable to indicate that ip address hash is in sync + * with in_ifaddrhead queue + */ + int ip_addr_hash_status = 0; /* -1: disabled; 0: needs sync; 1: in sync */ + /* a wrapper to avoid if_addr modifications */ + struct ip_addr_hash_entry { + struct in_ifaddr *ia; + struct ip_addr_hash_entry *next; + }; + typedef struct ip_addr_hash_entry **ip_addr_hash_pos; + static struct ip_addr_hash_entry **ip_addr_hash = 0; + static struct ip_addr_hash_entry *ip_addr_hash_entry_cache = 0; + static int ip_addr_hash_cap = 0; /* slots in a hash */ + static void ip_addr_hash_reset(void); + static void ip_addr_hash_clean(void); + static int ip_addr_hash_find(struct in_addr addr, ip_addr_hash_pos *pos); + static struct in_ifaddr *ip_addr_hash_has(struct in_addr addr); + #endif /* IF_ADDR_HASH */ + /* Packet reassembly stuff */ #define IPREASS_NHASH_LOG2 6 #define IPREASS_NHASH (1 << IPREASS_NHASH_LOG2) *************** *** 493,498 **** --- 515,535 ---- * we receive might be for us (and let the upper layers deal * with it). */ + #ifdef IF_ADDR_HASH + if (ip_addr_hash_status == 0) + ip_addr_hash_reset(); + if (ip_addr_hash_status > 0) { + #ifdef IPFIREWALL_FORWARD + if (ip_addr_hash_has(ip_fw_fwd_addr ? + ip_fw_fwd_addr->sin_addr : ip->ip_dst)) + goto ours; + #else + if (ip_addr_hash_has(ip->ip_dst)) + goto ours; + #endif + } else /* XXX: error prone */ + #endif + if (TAILQ_EMPTY(&in_ifaddrhead) && (m->m_flags & (M_MCAST|M_BCAST)) == 0) goto ours; *************** *** 1842,1844 **** --- 1879,1974 ---- } return 0; } + + #ifdef IF_ADDR_HASH + + /* destroys old address hash if any and computes new hash if possible */ + static void + ip_addr_hash_reset(void) { + int new_cap = 0; + int hash_count, add_count; + struct in_ifaddr *ia; + + if (ip_addr_hash_status < 0) + panic("ip_addr_hash_reset -- called for a disabled hash"); + + printf("ip_addr_hash_reset: starting (capacity: %d, version: 2)\n", + ip_addr_hash_cap); + + /* calculate new hash capacity */ + hash_count = 0; + for (ia = TAILQ_FIRST(&in_ifaddrhead); ia; ia = TAILQ_NEXT(ia, ia_link)) + hash_count++; + new_cap = 2*hash_count + 1; /* XXX: ideally, this should be a prime number */ + + /* do we need to allocate a new hash? */ + if (ip_addr_hash_cap != new_cap) { + if (ip_addr_hash) + ip_addr_hash_clean(); + ip_addr_hash = malloc(sizeof(*ip_addr_hash)*new_cap, M_TEMP, M_WAITOK); + ip_addr_hash_entry_cache = malloc(sizeof(*ip_addr_hash_entry_cache)*hash_count, M_TEMP, M_WAITOK); + if (!ip_addr_hash || !ip_addr_hash_entry_cache) + panic("ip_addr_hash_reset -- cannot allocate hash"); + ip_addr_hash_cap = new_cap; + } + + /* initialize the hash with new values */ + bzero(ip_addr_hash, sizeof(*ip_addr_hash)*ip_addr_hash_cap); + bzero(ip_addr_hash_entry_cache, sizeof(*ip_addr_hash_entry_cache)*hash_count); + add_count = 0; + for (ia = TAILQ_FIRST(&in_ifaddrhead); ia; ia = TAILQ_NEXT(ia, ia_link)) { + const struct in_addr addr = IA_SIN(ia)->sin_addr; + struct ip_addr_hash_entry *e; + ip_addr_hash_pos pos; + + if (ip_addr_hash_find(addr, &pos)) { + printf("ip_addr_hash_reset: %s conflicts with ", inet_ntoa(IA_SIN(*pos)->sin_addr)); + printf("%s, disabling hash optimization due to internal error\n", inet_ntoa(addr)); + ip_addr_hash_clean(); + ip_addr_hash_status = -1; + return; + } + if (add_count >= hash_count) + panic("ip_addr_hash_reset -- ia list grew?!"); + e = ip_addr_hash_entry_cache + add_count; + e->ia = ia; + e->next = 0; + *pos = e; + add_count++; + } + + ip_addr_hash_status = 1; + /* XXX: remove this message? */ + printf("ip_addr_hash_reset: done (%d entries, %d bytes)\n", + hash_count, sizeof(*ip_addr_hash)*ip_addr_hash_cap + + sizeof(*ip_addr_hash_entry_cache)*hash_count); + } + + static void + ip_addr_hash_clean(void) { + FREE(ip_addr_hash_entry_cache, M_TEMP); + FREE(ip_addr_hash, M_TEMP); + ip_addr_hash = 0; + ip_addr_hash_entry_cache = 0; + ip_addr_hash_cap = 0; + } + + static int + ip_addr_hash_find(struct in_addr addr, ip_addr_hash_pos *posp) { + *posp = &ip_addr_hash[addr.s_addr % ip_addr_hash_cap]; + /* scan collision chain */ + while (**posp && IA_SIN((**posp)->ia)->sin_addr.s_addr != addr.s_addr) + *posp = &(**posp)->next; + return **posp != 0; + } + + static struct in_ifaddr * + ip_addr_hash_has(struct in_addr addr) { + ip_addr_hash_pos pos; + if (ip_addr_hash_find(addr, &pos)) + return (*pos)->ia; + else + return 0; + } + + #endif /* IF_ADDR_HASH */ Index: sys/netinet/tcp_input.c =================================================================== RCS file: /usr/local/cvsup/src/sys/netinet/tcp_input.c,v retrieving revision 1.107.2.8 diff -w -c -r1.107.2.8 tcp_input.c *** sys/netinet/tcp_input.c 2001/04/18 17:55:23 1.107.2.8 --- sys/netinet/tcp_input.c 2001/06/05 19:39:44 *************** *** 116,122 **** SYSCTL_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW, &blackhole, 0, "Do not send RST when dropping refused connections"); ! int tcp_delack_enabled = 1; SYSCTL_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_RW, &tcp_delack_enabled, 0, "Delay ACK to try and piggyback it onto a data packet"); --- 116,122 ---- SYSCTL_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW, &blackhole, 0, "Do not send RST when dropping refused connections"); ! int tcp_delack_enabled = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_RW, &tcp_delack_enabled, 0, "Delay ACK to try and piggyback it onto a data packet"); Index: sys/netinet/tcp_timer.h =================================================================== RCS file: /usr/local/cvsup/src/sys/netinet/tcp_timer.h,v retrieving revision 1.18 diff -w -c -r1.18 tcp_timer.h *** sys/netinet/tcp_timer.h 1999/12/29 04:41:03 1.18 --- sys/netinet/tcp_timer.h 2001/06/05 19:39:44 *************** *** 76,82 **** /* * Time constants. */ ! #define TCPTV_MSL ( 30*hz) /* max seg lifetime (hah!) */ #define TCPTV_SRTTBASE 0 /* base roundtrip time; if 0, no idea yet */ #define TCPTV_RTOBASE ( 3*hz) /* assumed RTO if no info */ --- 76,82 ---- /* * Time constants. */ ! #define TCPTV_MSL ( 3*hz) /* max seg lifetime (hah!) */ #define TCPTV_SRTTBASE 0 /* base roundtrip time; if 0, no idea yet */ #define TCPTV_RTOBASE ( 3*hz) /* assumed RTO if no info */ Index: sys/sys/socket.h =================================================================== RCS file: /usr/local/cvsup/src/sys/sys/socket.h,v retrieving revision 1.39.2.6 diff -w -c -r1.39.2.6 socket.h *** sys/sys/socket.h 2001/02/26 07:24:22 1.39.2.6 --- sys/sys/socket.h 2001/06/05 19:39:49 *************** *** 301,307 **** /* * Maximum queue length specifiable by listen. */ ! #define SOMAXCONN 128 /* * Message header for recvmsg and sendmsg calls. --- 301,307 ---- /* * Maximum queue length specifiable by listen. */ ! #define SOMAXCONN 1024 /* * Message header for recvmsg and sendmsg calls.