* [PATCH bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd()
@ 2023-02-20 23:49 Ilya Leoshkevich
2023-02-27 21:32 ` Andrii Nakryiko
2023-02-27 21:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2023-02-20 23:49 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Ilya Leoshkevich
Replace the short informal description with the proper doc comments.
Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
tools/lib/bpf/bpf.h | 67 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 63 insertions(+), 4 deletions(-)
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 9ed9bceb4111..e8c5c5832359 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -386,14 +386,73 @@ LIBBPF_API int bpf_link_get_fd_by_id(__u32 id);
LIBBPF_API int bpf_link_get_fd_by_id_opts(__u32 id,
const struct bpf_get_fd_by_id_opts *opts);
LIBBPF_API int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len);
-/* Type-safe variants of bpf_obj_get_info_by_fd(). The callers still needs to
- * pass info_len, which should normally be
- * sizeof(struct bpf_{prog,map,btf,link}_info), in order to be compatible with
- * different libbpf and kernel versions.
+
+/**
+ * @brief **bpf_prog_get_info_by_fd()** obtains information about the eBPF
+ * program corresponding to *bpf_fd*.
+ *
+ * Populates up to *info_len* bytes of *info* and updates *info_len* with the
+ * actual number of bytes written to *info*.
+ *
+ * @param bpf_fd eBPF program file descriptor
+ * @param info pointer to **struct bpf_prog_info** that will be populated with
+ * eBPF program information
+ * @param info_len pointer to the size of *info*; on success updated with the
+ * number of bytes written to *info*
+ * @return 0, on success; negative error code, otherwise (errno is also set to
+ * the error code)
*/
LIBBPF_API int bpf_prog_get_info_by_fd(int prog_fd, struct bpf_prog_info *info, __u32 *info_len);
+
+/**
+ * @brief **bpf_map_get_info_by_fd()** obtains information about the eBPF
+ * map corresponding to *bpf_fd*.
+ *
+ * Populates up to *info_len* bytes of *info* and updates *info_len* with the
+ * actual number of bytes written to *info*.
+ *
+ * @param bpf_fd eBPF map file descriptor
+ * @param info pointer to **struct bpf_map_info** that will be populated with
+ * eBPF map information
+ * @param info_len pointer to the size of *info*; on success updated with the
+ * number of bytes written to *info*
+ * @return 0, on success; negative error code, otherwise (errno is also set to
+ * the error code)
+ */
LIBBPF_API int bpf_map_get_info_by_fd(int map_fd, struct bpf_map_info *info, __u32 *info_len);
+
+/**
+ * @brief **bpf_btf_get_info_by_fd()** obtains information about the eBPF
+ * BTF corresponding to *bpf_fd*.
+ *
+ * Populates up to *info_len* bytes of *info* and updates *info_len* with the
+ * actual number of bytes written to *info*.
+ *
+ * @param bpf_fd eBPF BTF file descriptor
+ * @param info pointer to **struct bpf_btf_info** that will be populated with
+ * eBPF BTF information
+ * @param info_len pointer to the size of *info*; on success updated with the
+ * number of bytes written to *info*
+ * @return 0, on success; negative error code, otherwise (errno is also set to
+ * the error code)
+ */
LIBBPF_API int bpf_btf_get_info_by_fd(int btf_fd, struct bpf_btf_info *info, __u32 *info_len);
+
+/**
+ * @brief **bpf_btf_get_info_by_fd()** obtains information about the eBPF
+ * link corresponding to *bpf_fd*.
+ *
+ * Populates up to *info_len* bytes of *info* and updates *info_len* with the
+ * actual number of bytes written to *info*.
+ *
+ * @param bpf_fd eBPF link file descriptor
+ * @param info pointer to **struct bpf_link_info** that will be populated with
+ * eBPF link information
+ * @param info_len pointer to the size of *info*; on success updated with the
+ * number of bytes written to *info*
+ * @return 0, on success; negative error code, otherwise (errno is also set to
+ * the error code)
+ */
LIBBPF_API int bpf_link_get_info_by_fd(int link_fd, struct bpf_link_info *info, __u32 *info_len);
struct bpf_prog_query_opts {
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd()
2023-02-20 23:49 [PATCH bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd() Ilya Leoshkevich
@ 2023-02-27 21:32 ` Andrii Nakryiko
2023-02-27 21:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2023-02-27 21:32 UTC (permalink / raw)
To: Ilya Leoshkevich
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, bpf,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev
On Mon, Feb 20, 2023 at 3:50 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> Replace the short informal description with the proper doc comments.
>
> Suggested-by: Andrii Nakryiko <andrii@kernel.org>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
Thanks for the follow up! I diff few small adjustments for consistency
(eBPF -> BPF), also updated invalid generic bpf_fd to
{prog,map,btf,link}_fd. Also "BPF BTF" read very awkwardly, so I
called it just "BTF object".
Let me know if you disagree with updates, but otherwise I've pushed
this to bpf-next, thanks.
> tools/lib/bpf/bpf.h | 67 ++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 63 insertions(+), 4 deletions(-)
>
> diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
> index 9ed9bceb4111..e8c5c5832359 100644
> --- a/tools/lib/bpf/bpf.h
> +++ b/tools/lib/bpf/bpf.h
> @@ -386,14 +386,73 @@ LIBBPF_API int bpf_link_get_fd_by_id(__u32 id);
> LIBBPF_API int bpf_link_get_fd_by_id_opts(__u32 id,
> const struct bpf_get_fd_by_id_opts *opts);
> LIBBPF_API int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len);
> -/* Type-safe variants of bpf_obj_get_info_by_fd(). The callers still needs to
> - * pass info_len, which should normally be
> - * sizeof(struct bpf_{prog,map,btf,link}_info), in order to be compatible with
> - * different libbpf and kernel versions.
> +
> +/**
> + * @brief **bpf_prog_get_info_by_fd()** obtains information about the eBPF
> + * program corresponding to *bpf_fd*.
> + *
> + * Populates up to *info_len* bytes of *info* and updates *info_len* with the
> + * actual number of bytes written to *info*.
> + *
> + * @param bpf_fd eBPF program file descriptor
> + * @param info pointer to **struct bpf_prog_info** that will be populated with
> + * eBPF program information
> + * @param info_len pointer to the size of *info*; on success updated with the
> + * number of bytes written to *info*
> + * @return 0, on success; negative error code, otherwise (errno is also set to
> + * the error code)
> */
> LIBBPF_API int bpf_prog_get_info_by_fd(int prog_fd, struct bpf_prog_info *info, __u32 *info_len);
> +
> +/**
> + * @brief **bpf_map_get_info_by_fd()** obtains information about the eBPF
> + * map corresponding to *bpf_fd*.
> + *
> + * Populates up to *info_len* bytes of *info* and updates *info_len* with the
> + * actual number of bytes written to *info*.
> + *
> + * @param bpf_fd eBPF map file descriptor
> + * @param info pointer to **struct bpf_map_info** that will be populated with
> + * eBPF map information
> + * @param info_len pointer to the size of *info*; on success updated with the
> + * number of bytes written to *info*
> + * @return 0, on success; negative error code, otherwise (errno is also set to
> + * the error code)
> + */
> LIBBPF_API int bpf_map_get_info_by_fd(int map_fd, struct bpf_map_info *info, __u32 *info_len);
> +
> +/**
> + * @brief **bpf_btf_get_info_by_fd()** obtains information about the eBPF
> + * BTF corresponding to *bpf_fd*.
> + *
> + * Populates up to *info_len* bytes of *info* and updates *info_len* with the
> + * actual number of bytes written to *info*.
> + *
> + * @param bpf_fd eBPF BTF file descriptor
> + * @param info pointer to **struct bpf_btf_info** that will be populated with
> + * eBPF BTF information
> + * @param info_len pointer to the size of *info*; on success updated with the
> + * number of bytes written to *info*
> + * @return 0, on success; negative error code, otherwise (errno is also set to
> + * the error code)
> + */
> LIBBPF_API int bpf_btf_get_info_by_fd(int btf_fd, struct bpf_btf_info *info, __u32 *info_len);
> +
> +/**
> + * @brief **bpf_btf_get_info_by_fd()** obtains information about the eBPF
> + * link corresponding to *bpf_fd*.
> + *
> + * Populates up to *info_len* bytes of *info* and updates *info_len* with the
> + * actual number of bytes written to *info*.
> + *
> + * @param bpf_fd eBPF link file descriptor
> + * @param info pointer to **struct bpf_link_info** that will be populated with
> + * eBPF link information
> + * @param info_len pointer to the size of *info*; on success updated with the
> + * number of bytes written to *info*
> + * @return 0, on success; negative error code, otherwise (errno is also set to
> + * the error code)
> + */
> LIBBPF_API int bpf_link_get_info_by_fd(int link_fd, struct bpf_link_info *info, __u32 *info_len);
>
> struct bpf_prog_query_opts {
> --
> 2.39.1
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd()
2023-02-20 23:49 [PATCH bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd() Ilya Leoshkevich
2023-02-27 21:32 ` Andrii Nakryiko
@ 2023-02-27 21:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-27 21:40 UTC (permalink / raw)
To: Ilya Leoshkevich; +Cc: ast, daniel, andrii, bpf, hca, gor, agordeev
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Tue, 21 Feb 2023 00:49:58 +0100 you wrote:
> Replace the short informal description with the proper doc comments.
>
> Suggested-by: Andrii Nakryiko <andrii@kernel.org>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> tools/lib/bpf/bpf.h | 67 ++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 63 insertions(+), 4 deletions(-)
Here is the summary with links:
- [bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd()
https://git.kernel.org/bpf/bpf-next/c/0a504fa1a780
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-27 21:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-20 23:49 [PATCH bpf-next] libbpf: Document bpf_{btf,link,map,prog}_get_info_by_fd() Ilya Leoshkevich
2023-02-27 21:32 ` Andrii Nakryiko
2023-02-27 21:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox