From bb1fedd189ce240eeda31e2eb7a5cd23b26fc6b2 Mon Sep 17 00:00:00 2001 From: rmind Date: Wed, 5 Feb 2014 03:30:13 +0000 Subject: [PATCH] npftest: fix the failure of NAT test -- adjust for RUMP's conversion to the in-kernel CPRNG (hi pooka!). --- usr.sbin/npf/npftest/libnpftest/npf_nat_test.c | 12 +++++++----- usr.sbin/npf/npftest/libnpftest/npf_test_subr.c | 12 +++++++++++- usr.sbin/npf/npftest/npftest.c | 11 +---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c b/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c index 779b6dce869c..428eb415ce53 100644 --- a/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c +++ b/usr.sbin/npf/npftest/libnpftest/npf_nat_test.c @@ -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 }, diff --git a/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c b/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c index b04c844f5bb9..dab3b0830b84 100644 --- a/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c +++ b/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c @@ -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 +#include #include #include @@ -114,3 +115,12 @@ npf_test_statetrack(const void *data, size_t len, ifnet_t *ifp, return 0; } + +/* + * Need to override for cprng_fast32() -- we need deterministic PRNG. + */ +uint32_t +_arc4random(void) +{ + return random(); +} diff --git a/usr.sbin/npf/npftest/npftest.c b/usr.sbin/npf/npftest/npftest.c index 6c1ddd6bbcf3..ff03f5125d3b 100644 --- a/usr.sbin/npf/npftest/npftest.c +++ b/usr.sbin/npf/npftest/npftest.c @@ -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) {