diff options
| author | Yonghong Song <yonghong.song@linux.dev> | 2026-08-28 23:15:44 -0700 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-08-29 18:16:32 -0700 |
| commit | 282d07dc6c74a5b4eea19743dd8c487c4b8814da (patch) | |
| tree | d9e63884287ca2d9e46dce1b736d7e602d34efd9 /tools/lib/python | |
| parent | 9e0195cd1d312ed99c3107d82f418e97baa45289 (diff) | |
bpf: Report which member makes a kfunc return type unsupported
A kfunc that returns a struct by value may only return scalars, and the
message that rejects one names the type but not the member at fault:
kernel function bpf_kfunc_call_test_ret_ptr returns STRUCT
prog_test_ret_ptr that is not composed of scalars
Record the member that made the walk fail and name it. What is recorded
is a path, not a single member, because the walk descends up to 4 levels.
For
struct outer { struct inner { void *p; } in; __u64 tag; };
naming 'p' alone would send the reader looking for a member struct outer
does not have, so the actual message reads "member 'in.p' has type PTR".
For
struct s { void *p[2]; };
naming 'p' alone would blame the member, when it is the element type that
was rejected, so the actual message reads "member 'p[]' has type PTR". A
zero-length array has no element type to name and is rejected for its
length instead, so it reports "member 'p' is a zero-length array".
The detailed diagnostics for this failure:
Verification failed: Program Structure: Unsupported kernel function
return type
Reason:
bpf_kfunc_call_test_ret_ptr() returns STRUCT prog_test_ret_ptr by
value. Its member 'p' is PTR, not a scalar. Only kfuncs returning
scalar values, or structures composed of scalar values are
supported.
...
Suggestion:
Call a kernel function that returns only scalars by value.
A type nested deeper than the walk descends has no single member to
blame, so that case reports the depth instead:
Reason:
bpf_kfunc_call_test_ret_deep() returns STRUCT prog_test_ret_deep by
value. It nests structs more than 4 levels deep. ...
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20260829061545.1695736-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
