- Add bpf_args_t and convert bpf_filter_ext() to use it. This allows the trunk
authorrmind <rmind@NetBSD.org>
Fri, 15 Nov 2013 00:12:44 +0000
branchtrunk
changeset 222486 4a1de0d01679
parent 222485 80a352ea6e28
child 222487 28a6d74695fa
- Add bpf_args_t and convert bpf_filter_ext() to use it. This allows the caller to initialise (and re-use) the memory store. - Add bpf_jit_generate() and bpf_jit_freecode() wrappers.
sys/net/bpf.c
sys/net/bpf.h
sys/net/bpf_filter.c
sys/net/bpfdesc.h
sys/net/bpfjit.c
sys/net/bpfjit.h
sys/net/npf/npf_bpf.c
sys/net/npf/npf_impl.h
sys/net/npf/npf_ruleset.c
tests/lib/libbpfjit/t_bpfjit.c
--- a/sys/net/bpf.c	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/bpf.c	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.177 2013/09/18 23:34:55 rmind Exp $	*/
+/*	$NetBSD: bpf.c,v 1.178 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.177 2013/09/18 23:34:55 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.178 2013/11/15 00:12:44 rmind Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -185,6 +185,23 @@
 	nostop, notty, nopoll, nommap, nokqfilter, D_OTHER
 };
 
+bpfjit_func_t
+bpf_jit_generate(bpf_ctx_t *bc, void *code, size_t size)
+{
+	membar_consumer();
+	if (bpfjit_module_ops.bj_generate_code != NULL) {
+		return bpfjit_module_ops.bj_generate_code(bc, code, size);
+	}
+	return NULL;
+}
+
+void
+bpf_jit_freecode(bpfjit_func_t jcode)
+{
+	KASSERT(bpfjit_module_ops.bj_free_code != NULL);
+	bpfjit_module_ops.bj_free_code(jcode);
+}
+
 static int
 bpf_movein(struct uio *uio, int linktype, uint64_t mtu, struct mbuf **mp,
 	   struct sockaddr *sockp)
@@ -1062,7 +1079,7 @@
 bpf_setf(struct bpf_d *d, struct bpf_program *fp)
 {
 	struct bpf_insn *fcode, *old;
-	bpfjit_function_t jcode, oldj;
+	bpfjit_func_t jcode, oldj;
 	size_t flen, size;
 	int s;
 
@@ -1086,8 +1103,9 @@
 			return EINVAL;
 		}
 		membar_consumer();
-		if (bpf_jit && bpfjit_module_ops.bj_generate_code != NULL) {
-			jcode = bpfjit_module_ops.bj_generate_code(fcode, flen);
+		if (bpf_jit) {
+			bpf_ctx_t *bc = bpf_default_ctx();
+			jcode = bpf_jit_generate(bc, fcode, flen);
 		}
 	} else {
 		fcode = NULL;
@@ -1104,10 +1122,8 @@
 	if (old) {
 		free(old, M_DEVBUF);
 	}
-
-	if (oldj != NULL) {
-		KASSERT(bpfjit_module_ops.bj_free_code != NULL);
-		bpfjit_module_ops.bj_free_code(oldj);
+	if (oldj) {
+		bpf_jit_freecode(oldj);
 	}
 
 	return 0;
@@ -1719,8 +1735,7 @@
 		free(d->bd_filter, M_DEVBUF);
 
 	if (d->bd_jitcode != NULL) {
-		KASSERT(bpfjit_module_ops.bj_free_code != NULL);
-		bpfjit_module_ops.bj_free_code(d->bd_jitcode);
+		bpf_jit_freecode(d->bd_jitcode);
 	}
 }
 
--- a/sys/net/bpf.h	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/bpf.h	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.h,v 1.62 2013/09/18 23:34:55 rmind Exp $	*/
+/*	$NetBSD: bpf.h,v 1.63 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -275,6 +275,11 @@
 #define BPF_JUMP(code, k, jt, jf) { (uint16_t)(code), jt, jf, k }
 
 /*
+ * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
+ */
+#define	BPF_MEMWORDS	16
+
+/*
  * Structure to retrieve available DLTs for the interface.
  */
 struct bpf_dltlist {
@@ -282,8 +287,33 @@
 	u_int	*bfl_list;	/* array of DLTs */
 };
 
+struct bpf_ctx;
+typedef struct bpf_ctx bpf_ctx_t;
+
+struct bpf_args;
+typedef struct bpf_args bpf_args_t;
+
+#if defined(_KERNEL) || defined(__BPF_PRIVATE)
+typedef uint32_t (*bpf_copfunc_t)(bpf_ctx_t *, bpf_args_t *, uint32_t);
+
+struct bpf_args {
+	const struct mbuf *	pkt;
+	size_t			wirelen;
+	size_t			buflen;
+	uint32_t		mem[BPF_MEMWORDS];
+	void *			arg;
+};
+
+struct bpf_ctx {
+	const bpf_copfunc_t *	copfuncs;
+	size_t			nfuncs;
+};
+#endif
+
 #ifdef _KERNEL
+#include <net/bpfjit.h>
 #include <net/if.h>
+
 struct bpf_if;
 
 struct bpf_ops {
@@ -380,19 +410,17 @@
 
 void	 bpfilterattach(int);
 
-struct bpf_ctx;
-typedef struct bpf_ctx bpf_ctx_t;
-typedef uint32_t (*bpf_copfunc_t)(const struct mbuf *, void *,
-    uint32_t, uint32_t *);
-
 bpf_ctx_t *bpf_create(void);
+bpf_ctx_t *bpf_default_ctx(void);
 void	bpf_destroy(bpf_ctx_t *);
 
 int	bpf_set_cop(bpf_ctx_t *, const bpf_copfunc_t *, size_t);
-u_int	bpf_filter_ext(bpf_ctx_t *, void *, const struct bpf_insn *,
-	    const u_char *, u_int, u_int);
+u_int	bpf_filter_ext(bpf_ctx_t *, const struct bpf_insn *, bpf_args_t *);
 int	bpf_validate_ext(bpf_ctx_t *, const struct bpf_insn *, int);
 
+bpfjit_func_t bpf_jit_generate(bpf_ctx_t *, void *, size_t);
+void	bpf_jit_freecode(bpfjit_func_t);
+
 #endif
 
 int	bpf_validate(const struct bpf_insn *, int);
@@ -400,9 +428,4 @@
 
 __END_DECLS
 
-/*
- * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
- */
-#define BPF_MEMWORDS 16
-
 #endif /* !_NET_BPF_H_ */
--- a/sys/net/bpf_filter.c	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/bpf_filter.c	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf_filter.c,v 1.60 2013/10/05 22:38:52 rmind Exp $	*/
+/*	$NetBSD: bpf_filter.c,v 1.61 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf_filter.c,v 1.60 2013/10/05 22:38:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf_filter.c,v 1.61 2013/11/15 00:12:44 rmind Exp $");
 
 #if 0
 #if !(defined(lint) || defined(KERNEL))
@@ -51,15 +51,11 @@
 #include <sys/kmem.h>
 #include <sys/endian.h>
 
+#define	__BPF_PRIVATE
 #include <net/bpf.h>
 
 #ifdef _KERNEL
 
-struct bpf_ctx {
-	const bpf_copfunc_t *	copfuncs;
-	size_t			nfuncs;
-};
-
 /* Default BPF context (zeroed). */
 static bpf_ctx_t		bpf_def_ctx;
 
@@ -83,6 +79,12 @@
 	return 0;
 }
 
+bpf_ctx_t *
+bpf_default_ctx(void)
+{
+	return &bpf_def_ctx;
+}
+
 #endif
 
 #define EXTRACT_SHORT(p)	be16dec(p)
@@ -183,12 +185,17 @@
 bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
     u_int buflen)
 {
-	return bpf_filter_ext(&bpf_def_ctx, NULL, pc, p, wirelen, buflen);
+	bpf_args_t args = {
+		.pkt = (const struct mbuf *)p,
+		.wirelen = wirelen,
+		.buflen = buflen,
+		.arg = NULL
+	};
+	return bpf_filter_ext(&bpf_def_ctx, pc, &args);
 }
 
 u_int
-bpf_filter_ext(bpf_ctx_t *bc, void *arg, const struct bpf_insn *pc,
-    const u_char *p, u_int wirelen, u_int buflen)
+bpf_filter_ext(bpf_ctx_t *bc, const struct bpf_insn *pc, bpf_args_t *args)
 #else
 u_int
 bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen,
@@ -196,13 +203,17 @@
 #endif
 {
 	uint32_t A, X, k;
-	uint32_t mem[BPF_MEMWORDS];
-#ifdef _KERNEL
-	const struct mbuf * const m0 = (const struct mbuf *)p;
-
-	KASSERT(bc != NULL);
+#ifndef _KERNEL
+	bpf_args_t args_store = {
+		.pkt = (const struct mbuf *)p,
+		.wirelen = wirelen,
+		.buflen = buflen,
+		.arg = NULL
+	};
+	bpf_args_t * const args = &args_store;
+#else
+	const uint8_t * const p = (const uint8_t *)args->pkt;
 #endif
-
 	if (pc == 0) {
 		/*
 		 * No filter means accept all.
@@ -237,13 +248,14 @@
 
 		case BPF_LD|BPF_W|BPF_ABS:
 			k = pc->k;
-			if (k > buflen || sizeof(int32_t) > buflen - k) {
+			if (k > args->buflen ||
+			    sizeof(int32_t) > args->buflen - k) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				A = m_xword(m0, k, &merr);
+				A = m_xword(args->pkt, k, &merr);
 				if (merr != 0)
 					return 0;
 				continue;
@@ -256,13 +268,14 @@
 
 		case BPF_LD|BPF_H|BPF_ABS:
 			k = pc->k;
-			if (k > buflen || sizeof(int16_t) > buflen - k) {
+			if (k > args->buflen ||
+			    sizeof(int16_t) > args->buflen - k) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				A = m_xhalf(m0, k, &merr);
+				A = m_xhalf(args->pkt, k, &merr);
 				if (merr != 0)
 					return 0;
 				continue;
@@ -275,13 +288,13 @@
 
 		case BPF_LD|BPF_B|BPF_ABS:
 			k = pc->k;
-			if (k >= buflen) {
+			if (k >= args->buflen) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				A = m_xbyte(m0, k, &merr);
+				A = m_xbyte(args->pkt, k, &merr);
 				continue;
 #else
 				return 0;
@@ -291,23 +304,24 @@
 			continue;
 
 		case BPF_LD|BPF_W|BPF_LEN:
-			A = wirelen;
+			A = args->wirelen;
 			continue;
 
 		case BPF_LDX|BPF_W|BPF_LEN:
-			X = wirelen;
+			X = args->wirelen;
 			continue;
 
 		case BPF_LD|BPF_W|BPF_IND:
 			k = X + pc->k;
-			if (pc->k > buflen || X > buflen - pc->k ||
-			    sizeof(int32_t) > buflen - k) {
+			if (pc->k > args->buflen ||
+			    X > args->buflen - pc->k ||
+			    sizeof(int32_t) > args->buflen - k) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				A = m_xword(m0, k, &merr);
+				A = m_xword(args->pkt, k, &merr);
 				if (merr != 0)
 					return 0;
 				continue;
@@ -320,14 +334,15 @@
 
 		case BPF_LD|BPF_H|BPF_IND:
 			k = X + pc->k;
-			if (pc->k > buflen || X > buflen - pc->k ||
-			    sizeof(int16_t) > buflen - k) {
+			if (pc->k > args->buflen ||
+			    X > args->buflen - pc->k ||
+			    sizeof(int16_t) > args->buflen - k) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				A = m_xhalf(m0, k, &merr);
+				A = m_xhalf(args->pkt, k, &merr);
 				if (merr != 0)
 					return 0;
 				continue;
@@ -340,13 +355,14 @@
 
 		case BPF_LD|BPF_B|BPF_IND:
 			k = X + pc->k;
-			if (pc->k >= buflen || X >= buflen - pc->k) {
+			if (pc->k >= args->buflen ||
+			    X >= args->buflen - pc->k) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				A = m_xbyte(m0, k, &merr);
+				A = m_xbyte(args->pkt, k, &merr);
 				continue;
 #else
 				return 0;
@@ -357,13 +373,13 @@
 
 		case BPF_LDX|BPF_MSH|BPF_B:
 			k = pc->k;
-			if (k >= buflen) {
+			if (k >= args->buflen) {
 #ifdef _KERNEL
 				int merr;
 
-				if (buflen != 0)
+				if (args->buflen != 0)
 					return 0;
-				X = (m_xbyte(m0, k, &merr) & 0xf) << 2;
+				X = (m_xbyte(args->pkt, k, &merr) & 0xf) << 2;
 				continue;
 #else
 				return 0;
@@ -381,19 +397,19 @@
 			continue;
 
 		case BPF_LD|BPF_MEM:
-			A = mem[pc->k];
+			A = args->mem[pc->k];
 			continue;
 
 		case BPF_LDX|BPF_MEM:
-			X = mem[pc->k];
+			X = args->mem[pc->k];
 			continue;
 
 		case BPF_ST:
-			mem[pc->k] = A;
+			args->mem[pc->k] = A;
 			continue;
 
 		case BPF_STX:
-			mem[pc->k] = X;
+			args->mem[pc->k] = X;
 			continue;
 
 		case BPF_JMP|BPF_JA:
@@ -514,7 +530,7 @@
 #ifdef _KERNEL
 			if (pc->k < bc->nfuncs) {
 				const bpf_copfunc_t fn = bc->copfuncs[pc->k];
-				A = fn((const struct mbuf *)p, arg, A, mem);
+				A = fn(bc, args, A);
 				continue;
 			}
 #endif
@@ -524,7 +540,7 @@
 #ifdef _KERNEL
 			if (X < bc->nfuncs) {
 				const bpf_copfunc_t fn = bc->copfuncs[X];
-				A = fn((const struct mbuf *)p, arg, A, mem);
+				A = fn(bc, args, A);
 				continue;
 			}
 #endif
--- a/sys/net/bpfdesc.h	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/bpfdesc.h	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfdesc.h,v 1.37 2012/10/28 21:12:44 alnsn Exp $	*/
+/*	$NetBSD: bpfdesc.h,v 1.38 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -101,7 +101,7 @@
 #ifdef _LP64
 	int		bd_compat32;	/* 32-bit stream on LP64 system */
 #endif
-	bpfjit_function_t	bd_jitcode; /* compiled filter program */
+	bpfjit_func_t	bd_jitcode;	/* compiled filter program */
 };
 
 
--- a/sys/net/bpfjit.c	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/bpfjit.c	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.3 2013/09/20 23:19:52 rmind Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.4 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2011-2012 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include <sys/cdefs.h>
 #ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.3 2013/09/20 23:19:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.4 2013/11/15 00:12:44 rmind Exp $");
 #else
-__RCSID("$NetBSD: bpfjit.c,v 1.3 2013/09/20 23:19:52 rmind Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.4 2013/11/15 00:12:44 rmind Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1186,8 +1186,8 @@
 	}
 }
 
-bpfjit_function_t
-bpfjit_generate_code(struct bpf_insn *insns, size_t insn_count)
+bpfjit_func_t
+bpfjit_generate_code(bpf_ctx_t *bc, struct bpf_insn *insns, size_t insn_count)
 {
 	void *rv;
 	size_t i;
@@ -1727,12 +1727,11 @@
 	if (ret0 != NULL)
 		BPFJIT_FREE(ret0, ret0_maxsize * sizeof(ret0[0]));
 
-	return (bpfjit_function_t)rv;
+	return (bpfjit_func_t)rv;
 }
 
 void
-bpfjit_free_code(bpfjit_function_t code)
+bpfjit_free_code(bpfjit_func_t code)
 {
-
 	sljit_free_code((void *)code);
 }
--- a/sys/net/bpfjit.h	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/bpfjit.h	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.h,v 1.1 2012/10/27 22:36:14 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.h,v 1.2 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2011-2012 Alexander Nasonov.
@@ -53,17 +53,16 @@
  * SLJIT_MOV_UI is passed to sljit_emit_return() to make sure that the
  * return value is truncated to unsigned int.
  */
-typedef unsigned int (*bpfjit_function_t)(const uint8_t *,
+typedef unsigned int (*bpfjit_func_t)(const uint8_t *,
     unsigned int, unsigned int);
 
-bpfjit_function_t bpfjit_generate_code(struct bpf_insn *, size_t);
-void bpfjit_free_code(bpfjit_function_t);
+bpfjit_func_t bpfjit_generate_code(bpf_ctx_t *, struct bpf_insn *, size_t);
+void bpfjit_free_code(bpfjit_func_t);
 
 #ifdef _KERNEL
-struct bpfjit_ops
-{
-	bpfjit_function_t (*bj_generate_code)(struct bpf_insn *, size_t);
-	void (*bj_free_code)(bpfjit_function_t);
+struct bpfjit_ops {
+	bpfjit_func_t (*bj_generate_code)(bpf_ctx_t *, struct bpf_insn *, size_t);
+	void (*bj_free_code)(bpfjit_func_t);
 };
 
 extern struct bpfjit_ops bpfjit_module_ops;
--- a/sys/net/npf/npf_bpf.c	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/npf/npf_bpf.c	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_bpf.c,v 1.2 2013/11/12 00:46:34 rmind Exp $	*/
+/*	$NetBSD: npf_bpf.c,v 1.3 2013/11/15 00:12:44 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2009-2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_bpf.c,v 1.2 2013/11/12 00:46:34 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_bpf.c,v 1.3 2013/11/15 00:12:44 rmind Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -50,8 +50,8 @@
 
 static bpf_ctx_t *npf_bpfctx __read_mostly;
 
-static uint32_t npf_cop_l3(const struct mbuf *, void *, uint32_t, uint32_t *);
-static uint32_t npf_cop_table(const struct mbuf *, void *, uint32_t, uint32_t *);
+static uint32_t	npf_cop_l3(bpf_ctx_t *, bpf_args_t *, uint32_t);
+static uint32_t	npf_cop_table(bpf_ctx_t *, bpf_args_t *, uint32_t);
 
 static const bpf_copfunc_t npf_bpfcop[] = {
 	[NPF_COP_L3]	= npf_cop_l3,
@@ -74,19 +74,26 @@
 
 int
 npf_bpf_filter(npf_cache_t *npc, nbuf_t *nbuf,
-    const void *code, bpfjit_function_t jcode)
+    const void *code, bpfjit_func_t jcode)
 {
 	const struct mbuf *m = nbuf_head_mbuf(nbuf);
-	const unsigned char *p = (const unsigned char *)m;
 	const size_t pktlen = m_length(m);
+	bpf_args_t args = {
+		.pkt = m,
+		.wirelen = pktlen,
+		.buflen = 0,
+		.arg = npc
+	};
+
+	memset(args.mem, 0, sizeof(uint32_t) * BPF_MEMWORDS);
 
 	/* Execute JIT code. */
 	if (__predict_true(jcode)) {
-		return jcode(p, pktlen, 0);
+		return jcode((const unsigned char *)m, pktlen, 0);
 	}
 
 	/* Execute BPF byte-code. */
-	return bpf_filter_ext(npf_bpfctx, (void *)npc, code, p, pktlen, 0);
+	return bpf_filter_ext(npf_bpfctx, code, &args);
 }
 
 bool
@@ -105,12 +112,10 @@
  *	BPF_MW_L4PROTO	L4 protocol.
  */
 static uint32_t
-npf_cop_l3(const struct mbuf *pkt, void *arg, uint32_t A, uint32_t *M)
+npf_cop_l3(bpf_ctx_t *bc, bpf_args_t *args, uint32_t A)
 {
-	const npf_cache_t *npc = (const npf_cache_t *)arg;
-
-	KASSERT(npc != NULL);
-	memset(M, 0, sizeof(uint32_t) * BPF_MEMWORDS);
+	const npf_cache_t * const npc = (const npf_cache_t *)args->arg;
+	uint32_t * const M = args->mem;
 
 	/*
 	 * Convert address length to IP version.  Just mask out
@@ -139,17 +144,15 @@
  *	A <- non-zero (true) if found and zero (false) otherwise
  */
 static uint32_t
-npf_cop_table(const struct mbuf *pkt, void *arg, uint32_t A, uint32_t *M)
+npf_cop_table(bpf_ctx_t *bc, bpf_args_t *args, uint32_t A)
 {
-	const npf_cache_t *npc = (const npf_cache_t *)arg;
+	const npf_cache_t * const npc = (const npf_cache_t *)args->arg;
 	npf_tableset_t *tblset = npf_config_tableset();
 	const uint32_t tid = A & (SRC_FLAG_BIT - 1);
 	const npf_addr_t *addr;
 	npf_table_t *t;
 
-	KASSERT(npc != NULL);
 	KASSERT(npf_iscached(npc, NPC_IP46));
-	memset(M, 0, sizeof(uint32_t) * BPF_MEMWORDS);
 
 	if ((t = npf_tableset_getbyid(tblset, tid)) == NULL) {
 		return 0;
--- a/sys/net/npf/npf_impl.h	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/npf/npf_impl.h	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_impl.h,v 1.38 2013/11/12 00:46:34 rmind Exp $	*/
+/*	$NetBSD: npf_impl.h,v 1.39 2013/11/15 00:12:45 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2009-2013 The NetBSD Foundation, Inc.
@@ -208,7 +208,7 @@
 void		npf_bpf_sysinit(void);
 void		npf_bpf_sysfini(void);
 int		npf_bpf_filter(npf_cache_t *, nbuf_t *,
-		    const void *, bpfjit_function_t);
+		    const void *, bpfjit_func_t);
 bool		npf_bpf_validate(const void *, size_t);
 
 /* Tableset interface. */
--- a/sys/net/npf/npf_ruleset.c	Thu Nov 14 18:54:40 2013 +0000
+++ b/sys/net/npf/npf_ruleset.c	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_ruleset.c,v 1.26 2013/11/08 00:38:26 rmind Exp $	*/
+/*	$NetBSD: npf_ruleset.c,v 1.27 2013/11/15 00:12:45 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2009-2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.26 2013/11/08 00:38:26 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.27 2013/11/15 00:12:45 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -81,7 +81,7 @@
 
 	/* Code to process, if any. */
 	int			r_type;
-	bpfjit_function_t	r_jcode;
+	bpfjit_func_t		r_jcode;
 	void *			r_code;
 	size_t			r_clen;
 
--- a/tests/lib/libbpfjit/t_bpfjit.c	Thu Nov 14 18:54:40 2013 +0000
+++ b/tests/lib/libbpfjit/t_bpfjit.c	Fri Nov 15 00:12:44 2013 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.1 2012/11/11 17:37:34 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.2 2013/11/15 00:12:45 rmind Exp $ */
 
 /*-
  * Copyright (c) 2011-2012 Alexander Nasonov.
@@ -30,18 +30,23 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_bpfjit.c,v 1.1 2012/11/11 17:37:34 alnsn Exp $");
-
-#include <net/bpfjit.h>
+__RCSID("$NetBSD: t_bpfjit.c,v 1.2 2013/11/15 00:12:45 rmind Exp $");
 
 #include <atf-c.h>
 #include <stdint.h>
 #include <string.h>
 
+#define	__BPF_PRIVATE
+#include <net/bpf.h>
+#include <net/bpfjit.h>
+
 static uint8_t deadbeef_at_5[16] = {
 	0, 0xf1, 2, 0xf3, 4, 0xde, 0xad, 0xbe, 0xef, 0xff
 };
 
+static bpf_ctx_t bc_zeroed;
+static bpf_ctx_t *bc = &bc_zeroed;
+
 ATF_TC(bpfjit_empty);
 ATF_TC_HEAD(bpfjit_empty, tc)
 {
@@ -53,7 +58,7 @@
 {
 	struct bpf_insn dummy;
 
-	ATF_CHECK(bpfjit_generate_code(&dummy, 0) == NULL);
+	ATF_CHECK(bpfjit_generate_code(bc, &dummy, 0) == NULL);
 }
 
 ATF_TC(bpfjit_alu_add_k);
@@ -71,14 +76,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 5);
@@ -101,14 +106,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -131,14 +136,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(0xfffffffd));
@@ -160,14 +165,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	//ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0);
@@ -190,14 +195,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 7);
@@ -220,14 +225,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 3);
@@ -250,14 +255,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(0x3fffffff));
@@ -280,14 +285,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(429484384));
@@ -310,14 +315,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(429484));
@@ -340,14 +345,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 564);
@@ -370,14 +375,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -400,14 +405,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == (0xdead&0xbeef));
@@ -430,14 +435,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xdeadbeef);
@@ -460,14 +465,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xbeef0000);
@@ -490,14 +495,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xdeadbeef);
@@ -520,14 +525,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0x0000dead);
@@ -550,14 +555,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xdeadbeef);
@@ -612,14 +617,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) != UINT32_C(0x71cbbbc3));
@@ -645,14 +650,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 5);
@@ -676,14 +681,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -707,14 +712,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(0xfffffffd));
@@ -737,14 +742,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0);
@@ -768,14 +773,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 7);
@@ -799,14 +804,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 3);
@@ -830,14 +835,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(0x3fffffff));
@@ -861,14 +866,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(429484384));
@@ -892,14 +897,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_C(429484));
@@ -923,14 +928,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 564);
@@ -954,14 +959,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -985,14 +990,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == (0xdead&0xbeef));
@@ -1016,14 +1021,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xdeadbeef);
@@ -1047,14 +1052,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xbeef0000);
@@ -1078,14 +1083,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xdeadbeef);
@@ -1109,14 +1114,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0x0000dead);
@@ -1140,14 +1145,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0xdeadbeef);
@@ -1211,14 +1216,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) != UINT32_C(0x71cbbbc3));
@@ -1243,14 +1248,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0u-777u);
@@ -1276,14 +1281,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 3),
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -1320,14 +1325,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -1371,14 +1376,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -1422,14 +1427,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 7);
@@ -1473,14 +1478,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -1535,14 +1540,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 7)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -1586,14 +1591,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -1644,14 +1649,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -1701,14 +1706,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 7);
@@ -1758,14 +1763,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 8)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -1830,14 +1835,14 @@
 		BPF_STMT(BPF_RET+BPF_K, 7)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -1879,11 +1884,11 @@
 	size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]);
 
 	for (i = 0; i < 3; i++) {
-		bpfjit_function_t code;
+		bpfjit_func_t code;
 
 		ATF_CHECK(bpf_validate(insns[i], insn_count));
 
-		code = bpfjit_generate_code(insns[i], insn_count);
+		code = bpfjit_generate_code(bc, insns[i], insn_count);
 		ATF_REQUIRE(code != NULL);
 
 		for (l = 0; l < 5 + lengths[i]; l++) {
@@ -1980,11 +1985,11 @@
 	size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]);
 
 	for (i = 0; i < 3; i++) {
-		bpfjit_function_t code;
+		bpfjit_func_t code;
 
 		ATF_CHECK(bpf_validate(insns[i], insn_count));
 
-		code = bpfjit_generate_code(insns[i], insn_count);
+		code = bpfjit_generate_code(bc, insns[i], insn_count);
 		ATF_REQUIRE(code != NULL);
 
 		ATF_CHECK(code(pkt, 8, 8) == 0);
@@ -2049,11 +2054,11 @@
 	size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]);
 
 	for (i = 0; i < 3; i++) {
-		bpfjit_function_t code;
+		bpfjit_func_t code;
 
 		ATF_CHECK(bpf_validate(insns[i], insn_count));
 
-		code = bpfjit_generate_code(insns[i], insn_count);
+		code = bpfjit_generate_code(bc, insns[i], insn_count);
 		ATF_REQUIRE(code != NULL);
 
 		for (l = 0; l < 5 + lengths[i]; l++) {
@@ -2150,11 +2155,11 @@
 	size_t insn_count = sizeof(insns[0]) / sizeof(insns[0][0]);
 
 	for (i = 0; i < 3; i++) {
-		bpfjit_function_t code;
+		bpfjit_func_t code;
 
 		ATF_CHECK(bpf_validate(insns[i], insn_count));
 
-		code = bpfjit_generate_code(insns[i], insn_count);
+		code = bpfjit_generate_code(bc, insns[i], insn_count);
 		ATF_REQUIRE(code != NULL);
 
 		ATF_CHECK(code(pkt, 8, 8) == 0);
@@ -2181,14 +2186,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8] = { 10, 20, 30, 40, 50, 60, 70, 80 };
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 1; i <= sizeof(pkt); i++) {
@@ -2218,14 +2223,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[8] = { 10, 20, 30, 40, 50, 60, 70, 80 };
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 1; i <= sizeof(pkt); i++) {
@@ -2251,14 +2256,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[32]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < sizeof(pkt); i++)
@@ -2281,14 +2286,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -2311,14 +2316,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX - 5);
@@ -2343,14 +2348,14 @@
 		BPF_STMT(BPF_RET+BPF_K, UINT32_MAX)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == UINT32_MAX);
@@ -2374,14 +2379,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[5]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 1; i < sizeof(pkt); i++) {
@@ -2409,14 +2414,14 @@
 		BPF_STMT(BPF_RET+BPF_K, UINT32_MAX)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[5]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 5, 1) == UINT32_MAX);
@@ -2440,14 +2445,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2] = { 0, 0x7a };
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 2, 2) == 40);
@@ -2471,14 +2476,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[] = { 0, 11, 22, 33, 44, 55 };
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, sizeof(pkt), sizeof(pkt)) == 55);
@@ -2501,14 +2506,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 391);
@@ -2533,14 +2538,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[16]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 1; i <= sizeof(pkt); i++)
@@ -2565,14 +2570,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0);
@@ -2602,7 +2607,7 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
@@ -2611,7 +2616,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -2642,7 +2647,7 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
@@ -2651,7 +2656,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 1);
@@ -2673,7 +2678,7 @@
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	size_t k;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[BPF_MEMWORDS]; /* the program doesn't read any data */
 
 	memset(insns, 0, sizeof(insns));
@@ -2706,7 +2711,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (k = 1; k <= sizeof(pkt); k++)
@@ -2733,14 +2738,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[16]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 1; i <= sizeof(pkt); i++)
@@ -2766,14 +2771,14 @@
 		BPF_STMT(BPF_RET+BPF_A, 0)
 	};
 
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[1]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	ATF_CHECK(code(pkt, 1, 1) == 0);
@@ -2809,14 +2814,14 @@
 	};
 
 	size_t i;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[16]; /* the program doesn't read any data */
 
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 1; i <= sizeof(pkt); i++)
@@ -2838,7 +2843,7 @@
 	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
 
 	size_t k;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[BPF_MEMWORDS]; /* the program doesn't read any data */
 
 	memset(insns, 0, sizeof(insns));
@@ -2871,7 +2876,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (k = 1; k <= sizeof(pkt); k++)
@@ -2905,7 +2910,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -2925,7 +2930,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {
@@ -2962,7 +2967,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -2982,7 +2987,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {
@@ -3019,7 +3024,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -3039,7 +3044,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {
@@ -3077,7 +3082,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -3097,7 +3102,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {
@@ -3135,7 +3140,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -3155,7 +3160,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {
@@ -3194,7 +3199,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -3214,7 +3219,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {
@@ -3253,7 +3258,7 @@
 	};
 
 	size_t i, j;
-	bpfjit_function_t code;
+	bpfjit_func_t code;
 	uint8_t pkt[2][34] = {
 		{
 			0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0x08, 0x00,
@@ -3273,7 +3278,7 @@
 
 	ATF_CHECK(bpf_validate(insns, insn_count));
 
-	code = bpfjit_generate_code(insns, insn_count);
+	code = bpfjit_generate_code(bc, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
 	for (i = 0; i < 2; i++) {