bpf: Introduce KF_ARG_PTR_TO_CONST_STR
Similar to ARG_PTR_TO_CONST_STR for BPF helpers, KF_ARG_PTR_TO_CONST_STR specifies kfunc args that point to const strings. Annotation "__str" is used to specify kfunc arg of type KF_ARG_PTR_TO_CONST_STR. Also, add documentation for the "__str" annotation. bpf_get_file_xattr() will be the first kfunc that uses this type. Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://lore.kernel.org/bpf/20231107045725.2278852-4-song@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
0b51940729
commit
045edee19d
@@ -135,6 +135,30 @@ Either way, the returned buffer is either NULL, or of size buffer_szk. Without t
|
||||
annotation, the verifier will reject the program if a null pointer is passed in with
|
||||
a nonzero size.
|
||||
|
||||
2.2.5 __str Annotation
|
||||
----------------------------
|
||||
This annotation is used to indicate that the argument is a constant string.
|
||||
|
||||
An example is given below::
|
||||
|
||||
__bpf_kfunc bpf_get_file_xattr(..., const char *name__str, ...)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
In this case, ``bpf_get_file_xattr()`` can be called as::
|
||||
|
||||
bpf_get_file_xattr(..., "xattr_name", ...);
|
||||
|
||||
Or::
|
||||
|
||||
const char name[] = "xattr_name"; /* This need to be global */
|
||||
int BPF_PROG(...)
|
||||
{
|
||||
...
|
||||
bpf_get_file_xattr(..., name, ...);
|
||||
...
|
||||
}
|
||||
|
||||
.. _BPF_kfunc_nodef:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user