View | Details | Raw Unified | Return to bug 209475 | Differences between
and this patch

Collapse All | Expand All

(-)../plan3/pf.c.vm3 (-3 / +26 lines)
Lines 59-64 Link Here
59
#include <sys/sysctl.h>
59
#include <sys/sysctl.h>
60
#include <sys/taskqueue.h>
60
#include <sys/taskqueue.h>
61
#include <sys/ucred.h>
61
#include <sys/ucred.h>
62
#include <sys/proc.h>
62
63
63
#include <net/if.h>
64
#include <net/if.h>
64
#include <net/if_var.h>
65
#include <net/if_var.h>
Lines 777-788 Link Here
777
	struct pf_keyhash	*kh;
778
	struct pf_keyhash	*kh;
778
	struct pf_idhash	*ih;
779
	struct pf_idhash	*ih;
779
	struct pf_srchash	*sh;
780
	struct pf_srchash	*sh;
781
        u_long hw_physmem;
780
	u_int i;
782
	u_int i;
781
783
        size_t size;
782
	if (pf_hashsize == 0 || !powerof2(pf_hashsize))
784
        
785
	/* Get the available hardware memory */
786
        size=sizeof(hw_physmem);
787
        if (kernel_sysctlbyname(&thread0, "hw.physmem", &hw_physmem,	\
788
	&size, 0, 0, 0, 0) != 0)
789
	/* make the check against hw.physmem irrelevant */
790
		hw_physmem = ULONG_MAX; 
791
792
	if (pf_hashsize == 0 || !powerof2(pf_hashsize) || 		\
793
	(pf_hashsize * sizeof(struct pf_keyhash)) > hw_physmem || 	\
794
	(pf_hashsize * sizeof(struct pf_idhash)) > hw_physmem){
795
		printf("pf: Invalid states hash table size : %lu. "
796
			"Using the default value %lu.\n", 
797
			(unsigned long)pf_hashsize,
798
			(unsigned long)PF_HASHSIZ);
783
		pf_hashsize = PF_HASHSIZ;
799
		pf_hashsize = PF_HASHSIZ;
784
	if (pf_srchashsize == 0 || !powerof2(pf_srchashsize))
800
	}
801
	if (pf_srchashsize == 0 || !powerof2(pf_srchashsize) || 	\
802
	(pf_srchashsize * sizeof(struct pf_srchash)) > hw_physmem ){
803
		printf("pf: Invalid source node hash table size : %lu. "
804
			"Using the default value %lu.\n", 
805
			(unsigned long)pf_srchashsize,
806
			(unsigned long)(PF_HASHSIZ/4));
785
		pf_srchashsize = PF_HASHSIZ / 4;
807
		pf_srchashsize = PF_HASHSIZ / 4;
808
	}
786
809
787
	V_pf_hashseed = arc4random();
810
	V_pf_hashseed = arc4random();
788
811

Return to bug 209475