Module Name:    src
Committed By:   rmind
Date:           Wed Feb  5 03:30:13 UTC 2014

Modified Files:
        src/usr.sbin/npf/npftest: npftest.c
        src/usr.sbin/npf/npftest/libnpftest: npf_nat_test.c npf_test_subr.c

Log Message:
npftest: fix the failure of NAT test -- adjust for RUMP's conversion to
the in-kernel CPRNG (hi pooka!).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/npf/npftest/npftest.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/npf/npftest/npftest.c
diff -u src/usr.sbin/npf/npftest/npftest.c:1.13 src/usr.sbin/npf/npftest/npftest.c:1.14
--- src/usr.sbin/npf/npftest/npftest.c:1.13	Fri Nov  8 00:38:26 2013
+++ src/usr.sbin/npf/npftest/npftest.c	Wed Feb  5 03:30:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: npftest.c,v 1.13 2013/11/08 00:38:26 rmind Exp $	*/
+/*	$NetBSD: npftest.c,v 1.14 2014/02/05 03:30:13 rmind Exp $	*/
 
 /*
  * NPF testing framework.
@@ -121,15 +121,6 @@ load_npf_config(const char *config)
 	}
 }
 
-/*
- * Need to override for cprng_fast32(), since RUMP uses arc4random() for it.
- */
-uint32_t
-arc4random(void)
-{
-	return random();
-}
-
 int
 main(int argc, char **argv)
 {

Index: src/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c:1.4 src/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c:1.5
--- src/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c:1.4	Tue Sep 24 02:04:21 2013
+++ src/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c	Wed Feb  5 03:30:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_nat_test.c,v 1.4 2013/09/24 02:04:21 rmind Exp $	*/
+/*	$NetBSD: npf_nat_test.c,v 1.5 2014/02/05 03:30:13 rmind Exp $	*/
 
 /*
  * NPF NAT test.
@@ -16,6 +16,8 @@
 
 #define	NPF_BINAT	(NPF_NATIN | NPF_NATOUT)
 
+#define	RANDOM_PORT	45600
+
 static const struct test_case {
 	const char *	src;
 	in_port_t	sport;
@@ -36,12 +38,12 @@ static const struct test_case {
 	{
 		LOCAL_IP1,	15000,		REMOTE_IP1,	7000,
 		NPF_NATOUT,	IFNAME_EXT,	PFIL_OUT,
-		RESULT_PASS,	PUB_IP1,	53472
+		RESULT_PASS,	PUB_IP1,	RANDOM_PORT
 	},
 	{
 		LOCAL_IP1,	15000,		REMOTE_IP1,	7000,
 		NPF_NATOUT,	IFNAME_EXT,	PFIL_OUT,
-		RESULT_PASS,	PUB_IP1,	53472
+		RESULT_PASS,	PUB_IP1,	RANDOM_PORT
 	},
 	{
 		LOCAL_IP1,	15000,		REMOTE_IP1,	7000,
@@ -54,12 +56,12 @@ static const struct test_case {
 		RESULT_BLOCK,	NULL,		0
 	},
 	{
-		REMOTE_IP1,	7000,		PUB_IP1,	53472,
+		REMOTE_IP1,	7000,		PUB_IP1,	RANDOM_PORT,
 		NPF_NATOUT,	IFNAME_INT,	PFIL_IN,
 		RESULT_BLOCK,	NULL,		0
 	},
 	{
-		REMOTE_IP1,	7000,		PUB_IP1,	53472,
+		REMOTE_IP1,	7000,		PUB_IP1,	RANDOM_PORT,
 		NPF_NATOUT,	IFNAME_EXT,	PFIL_IN,
 		RESULT_PASS,	LOCAL_IP1,	15000
 	},

Index: src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.6 src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.7
--- src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.6	Fri Nov  8 00:38:27 2013
+++ src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c	Wed Feb  5 03:30:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_test_subr.c,v 1.6 2013/11/08 00:38:27 rmind Exp $	*/
+/*	$NetBSD: npf_test_subr.c,v 1.7 2014/02/05 03:30:13 rmind Exp $	*/
 
 /*
  * NPF initialisation and handler routines.
@@ -7,6 +7,7 @@
  */
 
 #include <sys/types.h>
+#include <sys/cprng.h>
 #include <net/if.h>
 #include <net/if_types.h>
 
@@ -114,3 +115,12 @@ npf_test_statetrack(const void *data, si
 
 	return 0;
 }
+
+/*
+ * Need to override for cprng_fast32() -- we need deterministic PRNG.
+ */
+uint32_t
+_arc4random(void)
+{
+	return random();
+}

Reply via email to