From 609b6256fd7fb3249b6cc4b33e9dc37416dc9a99 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Thu, 4 Feb 1999 03:02:56 +0000 Subject: [PATCH] Fix power-of-2 check for the TCB hash size. Submitted by: Brian Feldman --- sys/netinet/tcp_subr.c | 4 ++-- sys/netinet/tcp_timewait.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 9063c86634a..49c17094c2b 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.49 1998/12/07 21:58:42 archie Exp $ + * $Id: tcp_subr.c,v 1.50 1999/02/03 08:59:30 msmith Exp $ */ #include "opt_compat.h" @@ -136,7 +136,7 @@ tcp_init() tcbinfo.listhead = &tcb; if (!(getenv_int("net.inet.tcp.tcbhashsize", &hashsize))) hashsize = TCBHASHSIZE; - if ((1 << ffs(hashsize)) != hashsize) { + if ((1 << (ffs(hashsize) - 1)) != hashsize) { printf("WARNING: TCB hash size not a power of 2\n"); hashsize = 512; /* safe default */ } diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 9063c86634a..49c17094c2b 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 - * $Id: tcp_subr.c,v 1.49 1998/12/07 21:58:42 archie Exp $ + * $Id: tcp_subr.c,v 1.50 1999/02/03 08:59:30 msmith Exp $ */ #include "opt_compat.h" @@ -136,7 +136,7 @@ tcp_init() tcbinfo.listhead = &tcb; if (!(getenv_int("net.inet.tcp.tcbhashsize", &hashsize))) hashsize = TCBHASHSIZE; - if ((1 << ffs(hashsize)) != hashsize) { + if ((1 << (ffs(hashsize) - 1)) != hashsize) { printf("WARNING: TCB hash size not a power of 2\n"); hashsize = 512; /* safe default */ }