Thread (28 messages) flat view 28 messages, 5 authors, 2016-01-14
STALE3871d

[PATCH 1/9] bpf: prepare for moving map common stuff into one place

From: Ming Lei <tom.leiming@gmail.com>
Date: 2016-01-11 15:57:19
Also in: lkml
Subsystem: bpf [general] (safe dynamic programs and tools), the rest · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, Linus Torvalds

This patch introduces some nop functions of map callback
for use in all map implementation.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 kernel/bpf/Makefile  |  2 +-
 kernel/bpf/bpf_map.h |  9 +++++++++
 kernel/bpf/map.c     | 26 ++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 kernel/bpf/bpf_map.h
 create mode 100644 kernel/bpf/map.c
diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 13272582..191d54b 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -1,4 +1,4 @@
 obj-y := core.o
 
 obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o
-obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o
+obj-$(CONFIG_BPF_SYSCALL) += map.o hashtab.o arraymap.o
diff --git a/kernel/bpf/bpf_map.h b/kernel/bpf/bpf_map.h
new file mode 100644
index 0000000..7e596c1
--- /dev/null
+++ b/kernel/bpf/bpf_map.h
@@ -0,0 +1,9 @@
+#ifndef INT_BPF_MAP_COMMON_H
+#define INT_BPF_MAP_COMMON_H
+
+#include <linux/bpf.h>
+
+extern void *map_lookup_elem_nop(struct bpf_map *map, void *key);
+extern int map_delete_elem_nop(struct bpf_map *map, void *key);
+
+#endif
diff --git a/kernel/bpf/map.c b/kernel/bpf/map.c
new file mode 100644
index 0000000..bf113fb
--- /dev/null
+++ b/kernel/bpf/map.c
@@ -0,0 +1,26 @@
+/*
+ * bpf map common stuff
+ *
+ *	Copyright (c) 2016 Ming Lei
+ *
+ * Authors:
+ *	Ming Lei <tom.leiming@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/bpf.h>
+
+void *map_lookup_elem_nop(struct bpf_map *map, void *key)
+{
+	return NULL;
+}
+
+int map_delete_elem_nop(struct bpf_map *map, void *key)
+{
+	return -EINVAL;
+}
+
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help