Skip to content

Commit 51b79c3

Browse files
mykyta5Kernel Patches Daemon
authored andcommitted
bpf:add _impl suffix for bpf_stream_vprintk() kfunc
Rename bpf_stream_vprintk() to bpf_stream_vprintk_impl(). This aligns this recently added kfunc with the naming scheme required by the implicit-argument feature. In future BTF type for bpf_stream_vprintk() will be generated and aux__prog argument filled by the valid struct implicitly. Signed-off-by: Mykyta Yatsenko <[email protected]>
1 parent 5ce8ee5 commit 51b79c3

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

kernel/bpf/helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4380,7 +4380,7 @@ BTF_ID_FLAGS(func, bpf_strnstr);
43804380
#if defined(CONFIG_BPF_LSM) && defined(CONFIG_CGROUPS)
43814381
BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
43824382
#endif
4383-
BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS)
4383+
BTF_ID_FLAGS(func, bpf_stream_vprintk_impl, KF_TRUSTED_ARGS)
43844384
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal_impl, KF_TRUSTED_ARGS)
43854385
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume_impl, KF_TRUSTED_ARGS)
43864386
BTF_KFUNCS_END(common_btf_ids)

kernel/bpf/stream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ __bpf_kfunc_start_defs();
355355
* Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the
356356
* enum in headers.
357357
*/
358-
__bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz, void *aux__prog)
358+
__bpf_kfunc int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args,
359+
u32 len__sz, void *aux__prog)
359360
{
360361
struct bpf_bprintf_data data = {
361362
.get_bin_args = true,

tools/bpf/bpftool/Documentation/bpftool-prog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ bpftool prog tracelog
182182

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

tools/lib/bpf/bpf_helpers.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,20 @@ enum libbpf_tristate {
315315
___param, sizeof(___param)); \
316316
})
317317

318-
extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args,
319-
__u32 len__sz, void *aux__prog) __weak __ksym;
320-
321-
#define bpf_stream_printk(stream_id, fmt, args...) \
322-
({ \
323-
static const char ___fmt[] = fmt; \
324-
unsigned long long ___param[___bpf_narg(args)]; \
325-
\
326-
_Pragma("GCC diagnostic push") \
327-
_Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \
328-
___bpf_fill(___param, args); \
329-
_Pragma("GCC diagnostic pop") \
330-
\
331-
bpf_stream_vprintk(stream_id, ___fmt, ___param, sizeof(___param), NULL);\
318+
extern int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args,
319+
__u32 len__sz, void *aux__prog) __weak __ksym;
320+
321+
#define bpf_stream_printk(stream_id, fmt, args...) \
322+
({ \
323+
static const char ___fmt[] = fmt; \
324+
unsigned long long ___param[___bpf_narg(args)]; \
325+
\
326+
_Pragma("GCC diagnostic push") \
327+
_Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \
328+
___bpf_fill(___param, args); \
329+
_Pragma("GCC diagnostic pop") \
330+
\
331+
bpf_stream_vprintk_impl(stream_id, ___fmt, ___param, sizeof(___param), NULL); \
332332
})
333333

334334
/* Use __bpf_printk when bpf_printk call has 3 or fewer fmt args

tools/testing/selftests/bpf/progs/stream_fail.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ SEC("syscall")
1010
__failure __msg("Possibly NULL pointer passed")
1111
int stream_vprintk_null_arg(void *ctx)
1212
{
13-
bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0, NULL);
13+
bpf_stream_vprintk_impl(BPF_STDOUT, "", NULL, 0, NULL);
1414
return 0;
1515
}
1616

1717
SEC("syscall")
1818
__failure __msg("R3 type=scalar expected=")
1919
int stream_vprintk_scalar_arg(void *ctx)
2020
{
21-
bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0, NULL);
21+
bpf_stream_vprintk_impl(BPF_STDOUT, "", (void *)46, 0, NULL);
2222
return 0;
2323
}
2424

2525
SEC("syscall")
2626
__failure __msg("arg#1 doesn't point to a const string")
2727
int stream_vprintk_string_arg(void *ctx)
2828
{
29-
bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0, NULL);
29+
bpf_stream_vprintk_impl(BPF_STDOUT, ctx, NULL, 0, NULL);
3030
return 0;
3131
}
3232

0 commit comments

Comments
 (0)