Commit 137cc92f authored by Mykyta Yatsenko's avatar Mykyta Yatsenko Committed by Alexei Starovoitov
Browse files

bpf: add _impl suffix for bpf_stream_vprintk() kfunc



Rename bpf_stream_vprintk() to bpf_stream_vprintk_impl().

This makes bpf_stream_vprintk() follow the already established "_impl"
suffix-based naming convention for kfuncs with the bpf_prog_aux
argument provided by the verifier implicitly. This convention will be
taken advantage of with the upcoming KF_IMPLICIT_ARGS feature to
preserve backwards compatibility to BPF programs.

Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarMykyta Yatsenko <yatsenko@meta.com>
Link: https://lore.kernel.org/r/20251104-implv2-v3-2-4772b9ae0e06@meta.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarIhor Solodrai <ihor.solodrai@linux.dev>
parent ea0714d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4380,7 +4380,7 @@ BTF_ID_FLAGS(func, bpf_strnstr);
#if defined(CONFIG_BPF_LSM) && defined(CONFIG_CGROUPS)
BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
#endif
BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_stream_vprintk_impl, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal_impl, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume_impl, KF_TRUSTED_ARGS)
BTF_KFUNCS_END(common_btf_ids)
+2 −1
Original line number Diff line number Diff line
@@ -355,7 +355,8 @@ __bpf_kfunc_start_defs();
 * Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the
 * enum in headers.
 */
__bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz, void *aux__prog)
__bpf_kfunc int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args,
					u32 len__sz, void *aux__prog)
{
	struct bpf_bprintf_data data = {
		.get_bin_args	= true,
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ bpftool prog tracelog

bpftool prog tracelog { stdout | stderr } *PROG*
    Dump the BPF stream of the program. BPF programs can write to these streams
    at runtime with the **bpf_stream_vprintk**\ () kfunc. The kernel may write
    at runtime with the **bpf_stream_vprintk_impl**\ () kfunc. The kernel may write
    error messages to the standard error stream. This facility should be used
    only for debugging purposes.

+14 −14
Original line number Diff line number Diff line
@@ -315,7 +315,7 @@ enum libbpf_tristate {
			  ___param, sizeof(___param));		\
})

extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args,
extern int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args,
				   __u32 len__sz, void *aux__prog) __weak __ksym;

#define bpf_stream_printk(stream_id, fmt, args...)					\
@@ -328,7 +328,7 @@ extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *a
	___bpf_fill(___param, args);							\
	_Pragma("GCC diagnostic pop")							\
											\
	bpf_stream_vprintk(stream_id, ___fmt, ___param, sizeof(___param), NULL);\
	bpf_stream_vprintk_impl(stream_id, ___fmt, ___param, sizeof(___param), NULL);	\
})

/* Use __bpf_printk when bpf_printk call has 3 or fewer fmt args
+3 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ SEC("syscall")
__failure __msg("Possibly NULL pointer passed")
int stream_vprintk_null_arg(void *ctx)
{
	bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0, NULL);
	bpf_stream_vprintk_impl(BPF_STDOUT, "", NULL, 0, NULL);
	return 0;
}

@@ -18,7 +18,7 @@ SEC("syscall")
__failure __msg("R3 type=scalar expected=")
int stream_vprintk_scalar_arg(void *ctx)
{
	bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0, NULL);
	bpf_stream_vprintk_impl(BPF_STDOUT, "", (void *)46, 0, NULL);
	return 0;
}

@@ -26,7 +26,7 @@ SEC("syscall")
__failure __msg("arg#1 doesn't point to a const string")
int stream_vprintk_string_arg(void *ctx)
{
	bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0, NULL);
	bpf_stream_vprintk_impl(BPF_STDOUT, ctx, NULL, 0, NULL);
	return 0;
}