lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 10 Dec 2018 12:43:09 -0800
From:   Stanislav Fomichev <sdf@...gle.com>
To:     netdev@...r.kernel.org
Cc:     davem@...emloft.net, ast@...nel.org, daniel@...earbox.net,
        jakub.kicinski@...ronome.com, Stanislav Fomichev <sdf@...gle.com>
Subject: [PATCH bpf-next v2 1/2] selftests/bpf: skip maps sockmap tests on
 kernels without support

Include "autoconf.h" header in the test_maps.c and selectively
disable test_sockmap if CONFIG_BPF_STREAM_PARSER is not specified
in the kernel config.
When building out of tree/without autoconf.h, fall back to 'enabled'.

v2 changes:
* add SKIP indication on the stdout

Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
---
 tools/testing/selftests/bpf/test_maps.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index 9c79ee017df3..4b2cd6300153 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -21,6 +21,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <linux/bpf.h>
+#include <tools/config.h>
 
 #include <bpf/bpf.h>
 #include <bpf/libbpf.h>
@@ -32,7 +33,15 @@
 #define ENOTSUPP 524
 #endif
 
+#ifdef HAVE_GENHDR
+# include "autoconf.h"
+#else
+/* fallback to all features enabled */
+# define CONFIG_BPF_STREAM_PARSER 1
+#endif
+
 static int map_flags;
+static int skips = 0;
 
 #define CHECK(condition, tag, format...) ({				\
 	int __ret = !!(condition);					\
@@ -43,6 +52,16 @@ static int map_flags;
 	}								\
 })
 
+#define CHECK_CONFIG(opt) ({						\
+	if (!IS_BUILTIN(opt)) {						\
+		printf("%s SKIP "					\
+		       "(missing required config)\n",			\
+		       __func__);					\
+		skips++;						\
+		return;							\
+	}								\
+})
+
 static void test_hashmap(int task, void *data)
 {
 	long long key, next_key, first_key, value;
@@ -657,6 +676,8 @@ static void test_sockmap(int tasks, void *data)
 	pid_t pid[tasks];
 	fd_set w;
 
+	CHECK_CONFIG(CONFIG_BPF_STREAM_PARSER);
+
 	/* Create some sockets to use with sockmap */
 	for (i = 0; i < 2; i++) {
 		sfd[i] = socket(AF_INET, SOCK_STREAM, 0);
@@ -1702,6 +1723,6 @@ int main(void)
 	map_flags = BPF_F_NO_PREALLOC;
 	run_all_tests();
 
-	printf("test_maps: OK\n");
+	printf("test_maps: OK, %d SKIPPED\n", skips);
 	return 0;
 }
-- 
2.20.0.rc2.403.gdbc3b29805-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ