CVS commit: src/usr.sbin/npf/npftest/libnpftest

2020-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 27 18:51:20 UTC 2020

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

Log Message:
npftest: Wait at least one tick in each gc busy wait iteration.

Otherwise the busy wait loop runs a little too fast for the gc about
half the times I run the test.

XXX We should really arrange mstohz to round up!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.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/libnpftest/npf_gc_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c:1.1 src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c:1.2
--- src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c:1.1	Sat May 30 14:16:57 2020
+++ src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c	Thu Aug 27 18:51:20 2020
@@ -222,7 +222,7 @@ run_worker_tests(npf_t *npf)
 		/* Wait for the task to be done. */
 		while (!atomic_load_acquire(_done) && retry--) {
 			npf_worker_signal(test_npf);
-			kpause("gctest", false, mstohz(1), NULL);
+			kpause("gctest", false, MAX(1, mstohz(1)), NULL);
 		}
 
 		CHECK_TRUE(atomic_load_acquire(_done));



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2020-08-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 27 18:51:20 UTC 2020

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

Log Message:
npftest: Wait at least one tick in each gc busy wait iteration.

Otherwise the busy wait loop runs a little too fast for the gc about
half the times I run the test.

XXX We should really arrange mstohz to round up!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/npf/npftest/libnpftest/npf_gc_test.c

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



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2020-05-30 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 30 21:00:31 UTC 2020

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

Log Message:
npftest -- npf_test_init(): add a workaround for NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
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.



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2020-05-30 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat May 30 21:00:31 UTC 2020

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

Log Message:
npftest -- npf_test_init(): add a workaround for NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
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/libnpftest/npf_test_subr.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.17 src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.18
--- src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.17	Sat May 30 14:16:57 2020
+++ src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c	Sat May 30 21:00:31 2020
@@ -64,6 +64,13 @@ npf_test_init(int (*pton_func)(int, cons
 {
 	npf_t *npf;
 
+#ifdef __NetBSD__
+	// XXX: Workaround for npf_init()
+	if ((npf = npf_getkernctx()) != NULL) {
+		npf_worker_discharge(npf);
+		npf_worker_sysfini();
+	}
+#endif
 	npfk_sysinit(0);
 	npf = npfk_create(0, _mbufops, _ifops, NULL);
 	npfk_thread_register(npf);



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2020-04-22 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr 23 00:27:45 UTC 2020

Modified Files:
src/usr.sbin/npf/npftest/libnpftest: npf_test.h

Log Message:
npftest_mbufops and npftest_ifops are owned by npf_mbuf_subr.c


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/npf/npftest/libnpftest/npf_test.h

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



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2020-04-22 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr 23 00:27:45 UTC 2020

Modified Files:
src/usr.sbin/npf/npftest/libnpftest: npf_test.h

Log Message:
npftest_mbufops and npftest_ifops are owned by npf_mbuf_subr.c


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/npf/npftest/libnpftest/npf_test.h

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/libnpftest/npf_test.h
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_test.h:1.19 src/usr.sbin/npf/npftest/libnpftest/npf_test.h:1.20
--- src/usr.sbin/npf/npftest/libnpftest/npf_test.h:1.19	Tue Jul 23 00:52:02 2019
+++ src/usr.sbin/npf/npftest/libnpftest/npf_test.h	Thu Apr 23 00:27:45 2020
@@ -84,8 +84,8 @@ struct mbuf {
 #define	CHECK_TRUE(x)	\
 if (!(x)) { printf("FAIL: %s line %d\n", __func__, __LINE__); return 0; }
 
-const npf_mbufops_t	npftest_mbufops;
-const npf_ifops_t	npftest_ifops;
+extern const npf_mbufops_t	npftest_mbufops;
+extern const npf_ifops_t	npftest_ifops;
 
 struct mbuf *	npfkern_m_get(int, int);
 size_t		npfkern_m_length(const struct mbuf *);



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2019-07-24 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Jul 25 01:18:06 UTC 2019

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

Log Message:
npftest: fix double-free in npf_nbuf_test().


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.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/libnpftest/npf_nbuf_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c:1.8 src/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c:1.9
--- src/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c:1.8	Tue Jul 23 00:52:02 2019
+++ src/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c	Thu Jul 25 01:18:05 2019
@@ -201,7 +201,6 @@ npf_nbuf_test(bool verbose)
 		bufb = parse_nbuf_chain(m1);
 		ok = validate_mbuf_data(bufa, bufb);
 		CHECK_TRUE(ok);
-		m_freem(m1);
 	}
 
 	m2 = mbuf_bytesize(MBUF_CHAIN_LEN);
@@ -209,7 +208,6 @@ npf_nbuf_test(bool verbose)
 	bufb = parse_nbuf_chain(m2);
 	ok = validate_mbuf_data(bufa, bufb);
 	CHECK_TRUE(ok);
-	m_freem(m2);
 
 	(void)verbose;
 	return true;



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2019-07-24 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Jul 25 01:18:06 UTC 2019

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

Log Message:
npftest: fix double-free in npf_nbuf_test().


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c

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



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2017-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 29 04:12:52 UTC 2017

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

Log Message:
fix function argument.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.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/libnpftest/npf_rule_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.13 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.14
--- src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.13	Mon Dec 26 18:05:05 2016
+++ src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c	Sat Jan 28 23:12:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_rule_test.c,v 1.13 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npf_rule_test.c,v 1.14 2017/01/29 04:12:52 christos Exp $	*/
 
 /*
  * NPF ruleset test.
@@ -80,7 +80,8 @@ npf_rule_raw_test(bool verbose, struct m
 	npf_cache_t npc = { .npc_info = 0, .npc_ctx = npf };
 	nbuf_t nbuf;
 	npf_rule_t *rl;
-	int retfl, error;
+	npf_match_info_t mi;
+	int error;
 
 	nbuf_init(npf, , m, ifp);
 	npc.npc_nbuf = 
@@ -90,7 +91,7 @@ npf_rule_raw_test(bool verbose, struct m
 	rl = npf_ruleset_inspect(, npf_config_ruleset(npf),
 	di, NPF_LAYER_3);
 	if (rl) {
-		error = npf_rule_conclude(rl, );
+		error = npf_rule_conclude(rl, );
 	} else {
 		error = ENOENT;
 	}



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-11-23 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Nov 23 19:40:11 UTC 2013

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

Log Message:
npftest: adjust for the npf_bpf_filter() change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/npf/npftest/libnpftest/npf_bpf_test.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/libnpftest/npf_bpf_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_bpf_test.c:1.3 src/usr.sbin/npf/npftest/libnpftest/npf_bpf_test.c:1.4
--- src/usr.sbin/npf/npftest/libnpftest/npf_bpf_test.c:1.3	Sat Nov 16 01:41:43 2013
+++ src/usr.sbin/npf/npftest/libnpftest/npf_bpf_test.c	Sat Nov 23 19:40:11 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_bpf_test.c,v 1.3 2013/11/16 01:41:43 rmind Exp $	*/
+/*	$NetBSD: npf_bpf_test.c,v 1.4 2013/11/23 19:40:11 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -63,6 +63,7 @@ test_bpf_code(void *code, size_t size)
 {
 	ifnet_t *dummy_ifp = npf_test_addif(IFNAME_TEST, false, false);
 	npf_cache_t npc = { .npc_info = 0 };
+	bpf_args_t bc_args;
 	struct mbuf *m;
 	nbuf_t nbuf;
 	int ret, jret;
@@ -73,12 +74,17 @@ test_bpf_code(void *code, size_t size)
 	nbuf_init(nbuf, m, dummy_ifp);
 	npf_cache_all(npc, nbuf);
 
-	ret = npf_bpf_filter(npc, nbuf, code, NULL);
+	memset(bc_args, 0, sizeof(bpf_args_t));
+	bc_args.pkt = m;
+	bc_args.wirelen = m_length(m);
+	bc_args.arg = npc;
+
+	ret = npf_bpf_filter(bc_args, code, NULL);
 
 	/* JIT-compiled code. */
 	jcode = npf_bpf_compile(code, size);
 	if (jcode) {
-		jret = npf_bpf_filter(npc, nbuf, NULL, jcode);
+		jret = npf_bpf_filter(bc_args, NULL, jcode);
 		assert(ret == jret);
 		bpf_jit_freecode(jcode);
 	} else if (lverbose) {



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-11-23 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Nov 23 19:40:11 UTC 2013

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

Log Message:
npftest: adjust for the npf_bpf_filter() change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/npf/npftest/libnpftest/npf_bpf_test.c

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



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-09-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Sep 24 22:52:14 UTC 2013

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

Log Message:
Add missing dead.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/npf/npftest/libnpftest/npf_perf_test.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/libnpftest/npf_perf_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_perf_test.c:1.2 src/usr.sbin/npf/npftest/libnpftest/npf_perf_test.c:1.3
--- src/usr.sbin/npf/npftest/libnpftest/npf_perf_test.c:1.2	Tue Sep 24 02:44:20 2013
+++ src/usr.sbin/npf/npftest/libnpftest/npf_perf_test.c	Tue Sep 24 22:52:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_perf_test.c,v 1.2 2013/09/24 02:44:20 rmind Exp $	*/
+/*	$NetBSD: npf_perf_test.c,v 1.3 2013/09/24 22:52:14 joerg Exp $	*/
 
 /*
  * NPF benchmarking.
@@ -43,7 +43,7 @@ fill_packet(unsigned i)
 	return m;
 }
 
-static void
+__dead static void
 worker(void *arg)
 {
 	ifnet_t *ifp = ifunit(IFNAME_INT);



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-09-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Sep 24 22:52:14 UTC 2013

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

Log Message:
Add missing dead.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/npf/npftest/libnpftest/npf_perf_test.c

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



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-02-18 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Mon Feb 18 23:09:20 UTC 2013

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

Log Message:
npftest/npf_blockall_rule: set NPF_RULE_DYNAMIC flag for the test rule.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.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/libnpftest/npf_rule_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.6 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.7
--- src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.6	Sat Feb 16 21:11:16 2013
+++ src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c	Mon Feb 18 23:09:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_rule_test.c,v 1.6 2013/02/16 21:11:16 rmind Exp $	*/
+/*	$NetBSD: npf_rule_test.c,v 1.7 2013/02/18 23:09:20 rmind Exp $	*/
 
 /*
  * NPF ruleset test.
@@ -120,7 +120,7 @@ npf_blockall_rule(void)
 
 	rldict = prop_dictionary_create();
 	prop_dictionary_set_uint32(rldict, attributes,
-	NPF_RULE_IN | NPF_RULE_OUT);
+	NPF_RULE_IN | NPF_RULE_OUT | NPF_RULE_DYNAMIC);
 	return npf_rule_alloc(rldict);
 }
 



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-02-18 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Mon Feb 18 23:09:20 UTC 2013

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

Log Message:
npftest/npf_blockall_rule: set NPF_RULE_DYNAMIC flag for the test rule.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c

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



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-02-10 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Mon Feb 11 02:52:32 UTC 2013

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

Log Message:
npftest: adjust for recent change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.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/libnpftest/npf_rule_test.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.4 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.5
--- src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c:1.4	Sat Feb  9 03:35:33 2013
+++ src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c	Mon Feb 11 02:52:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_rule_test.c,v 1.4 2013/02/09 03:35:33 rmind Exp $	*/
+/*	$NetBSD: npf_rule_test.c,v 1.5 2013/02/11 02:52:32 rmind Exp $	*/
 
 /*
  * NPF ruleset test.
@@ -171,8 +171,8 @@ npf_rule_test(bool verbose)
 	error = npf_test_first(verbose);
 	fail |= (error != RESULT_BLOCK);
 
-	rl = npf_ruleset_remove(rlset, test-rules, (uintptr_t)rl);
-	fail |= (rl == NULL);
+	error = npf_ruleset_remove(rlset, test-rules, (uintptr_t)rl);
+	fail |= error != 0;
 
 	npf_config_exit();
 



CVS commit: src/usr.sbin/npf/npftest/libnpftest

2013-02-10 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Mon Feb 11 02:52:32 UTC 2013

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

Log Message:
npftest: adjust for recent change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/npf/npftest/libnpftest/npf_rule_test.c

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