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]
Message-ID: <tencent_FB1D31D70047E82DCBF3D257C5ED75653405@qq.com>
Date: Thu,  5 Jun 2025 15:51:02 +0800
From: Rong Tao <rtoax@...mail.com>
To: Quentin Monnet <qmo@...nel.org>,
	Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>,
	Martin KaFai Lau <martin.lau@...ux.dev>,
	Eduard Zingerman <eddyz87@...il.com>,
	Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>,
	Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>,
	Jiri Olsa <jolsa@...nel.org>,
	bpf@...r.kernel.org (open list:BPF [TOOLING] (bpftool)),
	linux-kernel@...r.kernel.org (open list)
Cc: rongtao@...tc.cn,
	rtoax@...mail.com
Subject: [PATCH bpf-next 1/2] bpftool: skel: Introduce NAME__open_and_load_opts()

From: Rong Tao <rongtao@...tc.cn>

Introduce functions that support opts input parameters, Obviously, it is
more convenient to use. for example, skel with name=tc will include the
following functions:

    static inline struct tc_bpf *
    tc_bpf__open_and_load_opts(const struct bpf_object_open_opts *opts)

Signed-off-by: Rong Tao <rongtao@...tc.cn>
---
 tools/bpf/bpftool/gen.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 67a60114368f..1487e61c6970 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -1371,6 +1371,7 @@ static int do_skeleton(int argc, char **argv)
 		#ifdef __cplusplus					    \n\
 			static inline struct %1$s *open(const struct bpf_object_open_opts *opts = nullptr);\n\
 			static inline struct %1$s *open_and_load();	    \n\
+			static inline struct %1$s *open_and_load_opts(const struct bpf_object_open_opts *opts = nullptr);    \n\
 			static inline int load(struct %1$s *skel);	    \n\
 			static inline int attach(struct %1$s *skel);	    \n\
 			static inline void detach(struct %1$s *skel);	    \n\
@@ -1438,12 +1439,12 @@ static int do_skeleton(int argc, char **argv)
 		}							    \n\
 									    \n\
 		static inline struct %1$s *				    \n\
-		%1$s__open_and_load(void)				    \n\
+		%1$s__open_and_load_opts(const struct bpf_object_open_opts *opts)\n\
 		{							    \n\
 			struct %1$s *obj;				    \n\
 			int err;					    \n\
 									    \n\
-			obj = %1$s__open();				    \n\
+			obj = %1$s__open_opts(opts);			    \n\
 			if (!obj)					    \n\
 				return NULL;				    \n\
 			err = %1$s__load(obj);				    \n\
@@ -1455,6 +1456,12 @@ static int do_skeleton(int argc, char **argv)
 			return obj;					    \n\
 		}							    \n\
 									    \n\
+		static inline struct %1$s *				    \n\
+		%1$s__open_and_load(void)				    \n\
+		{							    \n\
+			return %1$s__open_and_load_opts(NULL);		    \n\
+		}							    \n\
+									    \n\
 		static inline int					    \n\
 		%1$s__attach(struct %1$s *obj)				    \n\
 		{							    \n\
@@ -1530,7 +1537,11 @@ static int do_skeleton(int argc, char **argv)
 									    \n\
 		#ifdef __cplusplus					    \n\
 		struct %1$s *%1$s::open(const struct bpf_object_open_opts *opts) { return %1$s__open_opts(opts); }\n\
-		struct %1$s *%1$s::open_and_load() { return %1$s__open_and_load(); }	\n\
+		struct %1$s *%1$s::open_and_load() { return %1$s__open_and_load(); }\n\
+		struct %1$s *%1$s::open_and_load_opts(const struct bpf_object_open_opts *opts)\n\
+		{							    \n\
+			return %1$s__open_and_load_opts(opts);		    \n\
+		}							    \n\
 		int %1$s::load(struct %1$s *skel) { return %1$s__load(skel); }		\n\
 		int %1$s::attach(struct %1$s *skel) { return %1$s__attach(skel); }	\n\
 		void %1$s::detach(struct %1$s *skel) { %1$s__detach(skel); }		\n\
-- 
2.49.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ