Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Dec 2012 00:31:52 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r243924 - in projects/bpfjit/tools/regression/bpf/bpf_filter: . tests
Message-ID:  <201212060031.qB60Vqfg019106@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Dec  6 00:31:51 2012
New Revision: 243924
URL: http://svnweb.freebsd.org/changeset/base/243924

Log:
  Convert bpf regression tests to the bpfjit APIs.

Modified:
  projects/bpfjit/tools/regression/bpf/bpf_filter/Makefile
  projects/bpfjit/tools/regression/bpf/bpf_filter/bpf_test.c
  projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0001.h
  projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0075.h
  projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0076.h
  projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0077.h
  projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0078.h

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/Makefile
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/Makefile	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/Makefile	Thu Dec  6 00:31:51 2012	(r243924)
@@ -24,7 +24,7 @@ TEST_CASES?=	test0001 test0002 test0003 
 
 SYSDIR?=	${.CURDIR}/../../../../sys
 
-SRCS=		${.CURDIR}/bpf_test.c
+SRCS=		${.CURDIR}/bpf_test.c ${SYSDIR}/net/bpf_filter.c
 
 CFLAGS+=	-g -I${SYSDIR} -I${.CURDIR}/tests
 
@@ -38,17 +38,17 @@ CFLAGS+=	-DLOG_LEVEL="${LOG_LEVEL}"
 CFLAGS+=	-DBPF_VALIDATE
 .endif
 
-.if defined(BPF_JIT) &&	\
-    (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386")
-SRCS+=		${SYSDIR}/net/bpf_jitter.c	\
-		${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c
-CFLAGS+=	-DBPF_JIT_COMPILER
-LIBS+=		-lutil
-WARNS?=		6
+.if defined(BPF_JIT)
+SRCS+=		${SYSDIR}/net/bpfjit.c ${SYSDIR}/contrib/sljit/sljitLir.c
+CFLAGS+=	-DBPF_JIT_COMPILER -I${SYSDIR}/contrib/sljit
+CFLAGS+=	-DBPFJIT_USE_UDIV -DSLJIT_CONFIG_AUTO=1 -DSLJIT_DEBUG=0
+.if !defined(BPF_BENCHMARK) && defined(LOG_LEVEL) && (${LOG_LEVEL} > 2)
+CFLAGS+=	-DSLJIT_VERBOSE=1
 .else
-SRCS+=		${SYSDIR}/net/bpf_filter.c
-WARNS?=		2
+CFLAGS+=	-DSLJIT_VERBOSE=0
+.endif
 .endif
+WARNS?=		2
 
 .for TEST in ${TEST_CASES}
 ${TEST}:	${.CURDIR}/tests/${TEST}.h ${SRCS}

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/bpf_test.c
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/bpf_test.c	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/bpf_test.c	Thu Dec  6 00:31:51 2012	(r243924)
@@ -59,31 +59,28 @@ static int	verbose = LOG_LEVEL;
 
 #include <libutil.h>
 
-#include <net/bpf_jitter.h>
+#include <net/bpfjit.h>
 
 static u_int
 bpf_compile_and_filter(void)
 {
-	bpf_jit_filter	*filter;
+	bpfjit_function_t filter;
 	u_int		i, ret;
 
 	/* Compile the BPF filter program and generate native code. */
-	if ((filter = bpf_jitter(pc, nins)) == NULL) {
+	filter = bpfjit_generate_code(pc, nins);
+	if (filter == NULL && invalid == 0) {
 		if (verbose > 1)
 			printf("Failed to allocate memory:\t");
 		if (verbose > 0)
 			printf("FATAL\n");
 		exit(FATAL);
 	}
-	if (verbose > 2) {
-		printf("\n");
-		hexdump(filter->func, filter->size, NULL, HD_OMIT_CHARS);
-	}
 
 	for (i = 0; i < BPF_NRUNS; i++)
-		ret = (*(filter->func))(pkt, wirelen, buflen);
+		ret = filter(pkt, wirelen, buflen);
 
-	bpf_destroy_jit_filter(filter);
+	bpfjit_free_code(filter);
 
 	return (ret);
 }

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0001.h
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0001.h	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0001.h	Thu Dec  6 00:31:51 2012	(r243924)
@@ -28,4 +28,8 @@ int	invalid =	1;
 u_int	expect =	0;
 
 /* Expected signal */
+#ifdef BPF_JIT_COMPILER
+int	expect_signal =	SIGSEGV;
+#else
 int	expect_signal =	SIGABRT;
+#endif

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0075.h
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0075.h	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0075.h	Thu Dec  6 00:31:51 2012	(r243924)
@@ -29,8 +29,8 @@ int	invalid =	1;
 u_int	expect =	0xdeadc0de;
 
 /* Expected signal */
-#ifdef __amd64__
-int	expect_signal =	SIGBUS;
-#else
+#ifdef BPF_JIT_COMPILER
 int	expect_signal =	SIGSEGV;
+#else
+int	expect_signal =	SIGBUS;
 #endif

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0076.h
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0076.h	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0076.h	Thu Dec  6 00:31:51 2012	(r243924)
@@ -30,8 +30,8 @@ int	invalid =	1;
 u_int	expect =	0xdeadc0de;
 
 /* Expected signal */
-#ifdef __amd64__
-int	expect_signal =	SIGBUS;
-#else
+#ifdef BPF_JIT_COMPILER
 int	expect_signal =	SIGSEGV;
+#else
+int	expect_signal =	SIGBUS;
 #endif

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0077.h
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0077.h	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0077.h	Thu Dec  6 00:31:51 2012	(r243924)
@@ -29,8 +29,8 @@ int	invalid =	1;
 u_int	expect =	0xdeadc0de;
 
 /* Expected signal */
-#ifdef __amd64__
-int	expect_signal =	SIGBUS;
-#else
+#ifdef BPF_JIT_COMPILER
 int	expect_signal =	SIGSEGV;
+#else
+int	expect_signal =	SIGBUS;
 #endif

Modified: projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0078.h
==============================================================================
--- projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0078.h	Thu Dec  6 00:25:42 2012	(r243923)
+++ projects/bpfjit/tools/regression/bpf/bpf_filter/tests/test0078.h	Thu Dec  6 00:31:51 2012	(r243924)
@@ -30,8 +30,8 @@ int	invalid =	1;
 u_int	expect =	0xdeadc0de;
 
 /* Expected signal */
-#ifdef __amd64__
-int	expect_signal =	SIGBUS;
-#else
+#ifdef BPF_JIT_COMPILER
 int	expect_signal =	SIGSEGV;
+#else
+int	expect_signal =	SIGBUS;
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212060031.qB60Vqfg019106>