[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACYkzJ79eOai+k1=YfwvP_DNdxX1G+yJ-1vyhgoCqxWyJZGAGQ@mail.gmail.com>
Date: Thu, 19 Nov 2020 22:51:12 +0100
From: KP Singh <kpsingh@...omium.org>
To: Florent Revest <revest@...omium.org>
Cc: bpf <bpf@...r.kernel.org>, Al Viro <viro@...iv.linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <kafai@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andrii@...nel.org>,
Florent Revest <revest@...gle.com>,
open list <linux-kernel@...r.kernel.org>,
Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH v2 2/5] bpf: Add a bpf_sock_from_file helper
On Thu, Nov 19, 2020 at 5:27 PM Florent Revest <revest@...omium.org> wrote:
>
> From: Florent Revest <revest@...gle.com>
>
> While eBPF programs can check whether a file is a socket by file->f_op
> == &socket_file_ops, they cannot convert the void private_data pointer
> to a struct socket BTF pointer. In order to do this a new helper
> wrapping sock_from_file is added.
>
> This is useful to tracing programs but also other program types
> inheriting this set of helpers such as iterators or LSM programs.
>
> Signed-off-by: Florent Revest <revest@...gle.com>
Acked-by: KP Singh <kpsingh@...gle.com>
Some minor comments.
> ---
> include/uapi/linux/bpf.h | 7 +++++++
> kernel/trace/bpf_trace.c | 20 ++++++++++++++++++++
> scripts/bpf_helpers_doc.py | 4 ++++
> tools/include/uapi/linux/bpf.h | 7 +++++++
> 4 files changed, 38 insertions(+)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 162999b12790..7d598f161dc0 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -3787,6 +3787,12 @@ union bpf_attr {
> * *ARG_PTR_TO_BTF_ID* of type *task_struct*.
> * Return
> * Pointer to the current task.
> + *
> + * struct socket *bpf_sock_from_file(struct file *file)
> + * Description
> + * If the given file contains a socket, returns the associated socket.
"If the given file is a socket" or "represents a socket" would fit better here.
> + * Return
> + * A pointer to a struct socket on success or NULL on failure.
NULL if the file is not a socket.
Powered by blists - more mailing lists