[PATCH 10/18] bpf-preload: Generate bpf_preload_ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Generate a bpf_preload_ops structure, to specify the kernel module and the
preload method.

Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
---
 kernel/bpf/preload/bpf_preload_kern.c          |  5 -----
 kernel/bpf/preload/iterators/iterators.lskel.h |  5 +++++
 tools/bpf/bpftool/gen.c                        | 13 +++++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/kernel/bpf/preload/bpf_preload_kern.c b/kernel/bpf/preload/bpf_preload_kern.c
index 35e9abd1a668..3839af367200 100644
--- a/kernel/bpf/preload/bpf_preload_kern.c
+++ b/kernel/bpf/preload/bpf_preload_kern.c
@@ -5,11 +5,6 @@
 #include <linux/bpf_preload.h>
 #include "iterators/iterators.lskel.h"
 
-static struct bpf_preload_ops ops = {
-	.preload = preload,
-	.owner = THIS_MODULE,
-};
-
 static int __init load(void)
 {
 	int err;
diff --git a/kernel/bpf/preload/iterators/iterators.lskel.h b/kernel/bpf/preload/iterators/iterators.lskel.h
index 6faf3708be01..7595fc283a65 100644
--- a/kernel/bpf/preload/iterators/iterators.lskel.h
+++ b/kernel/bpf/preload/iterators/iterators.lskel.h
@@ -474,6 +474,11 @@ static int preload(struct dentry *parent)
 	return err;
 }
 
+static struct bpf_preload_ops ops = {
+	.preload = preload,
+	.owner = THIS_MODULE,
+};
+
 static int load_skel(void)
 {
 	int err;
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 28b1fe718248..5593cbee1846 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -841,6 +841,18 @@ static void codegen_preload(struct bpf_object *obj, const char *obj_name)
 		");
 }
 
+static void codegen_preload_ops(void)
+{
+	codegen("\
+		\n\
+		\n\
+		static struct bpf_preload_ops ops = {			    \n\
+			.preload = preload,				    \n\
+			.owner = THIS_MODULE,				    \n\
+		};							    \n\
+		");
+}
+
 static void codegen_preload_load(struct bpf_object *obj, const char *obj_name)
 {
 	struct bpf_program *prog;
@@ -1076,6 +1088,7 @@ static int gen_trace(struct bpf_object *obj, const char *obj_name, const char *h
 		codegen_preload_vars(obj, obj_name);
 		codegen_preload_free(obj, obj_name);
 		codegen_preload(obj, obj_name);
+		codegen_preload_ops();
 		codegen_preload_load(obj, obj_name);
 	}
 
-- 
2.32.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux