@@ -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;
@@ -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;
@@ -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);
}
Generate a bpf_preload_ops structure, to specify the kernel module and the preload method. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> --- 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(-)