[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220328175033.2437312-11-roberto.sassu@huawei.com>
Date: Mon, 28 Mar 2022 19:50:25 +0200
From: Roberto Sassu <roberto.sassu@...wei.com>
To: <corbet@....net>, <viro@...iv.linux.org.uk>, <ast@...nel.org>,
<daniel@...earbox.net>, <andrii@...nel.org>, <kpsingh@...nel.org>,
<shuah@...nel.org>, <mcoquelin.stm32@...il.com>,
<alexandre.torgue@...s.st.com>, <zohar@...ux.ibm.com>
CC: <linux-doc@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
<netdev@...r.kernel.org>, <bpf@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-integrity@...r.kernel.org>,
<linux-security-module@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Roberto Sassu <roberto.sassu@...wei.com>
Subject: [PATCH 10/18] bpf-preload: Generate bpf_preload_ops
Generate a bpf_preload_ops structure, to specify the kernel module and the
preload method.
Signed-off-by: Roberto Sassu <roberto.sassu@...wei.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(-)
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
Powered by blists - more mailing lists