[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQJiEeZe1v=612etTLpawZ1hHmTFWbJau1UBX_KegTX1Mg@mail.gmail.com>
Date: Wed, 24 Jun 2020 18:45:31 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Yonghong Song <yhs@...com>
Cc: bpf <bpf@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>,
Martin KaFai Lau <kafai@...com>
Subject: Re: [PATCH bpf-next v5 00/15] implement bpf iterator for tcp and udp sockets
On Tue, Jun 23, 2020 at 4:08 PM Yonghong Song <yhs@...com> wrote:
>
> bpf iterator implments traversal of kernel data structures and these
> data structures are passed to a bpf program for processing.
> This gives great flexibility for users to examine kernel data
> structure without using e.g. /proc/net which has limited and
> fixed format.
>
> Commit 138d0be35b14 ("net: bpf: Add netlink and ipv6_route bpf_iter targets")
> implemented bpf iterators for netlink and ipv6_route.
> This patch set intends to implement bpf iterators for tcp and udp.
>
> Currently, /proc/net/tcp is used to print tcp4 stats and /proc/net/tcp6
> is used to print tcp6 stats. /proc/net/udp[6] have similar usage model.
> In contrast, only one tcp iterator is implemented and it is bpf program
> resposibility to filter based on socket family. The same is for udp.
> This will avoid another unnecessary traversal pass if users want
> to check both tcp4 and tcp6.
>
> Several helpers are also implemented in this patch
> bpf_skc_to_{tcp, tcp6, tcp_timewait, tcp_request, udp6}_sock
> The argument for these helpers is not a fixed btf_id. For example,
> bpf_skc_to_tcp(struct sock_common *), or
> bpf_skc_to_tcp(struct sock *), or
> bpf_skc_to_tcp(struct inet_sock *), ...
> are all valid. At runtime, the helper will check whether pointer cast
> is legal or not. Please see Patch #5 for details.
>
> Since btf_id's for both arguments and return value are known at
> build time, the btf_id's are pre-computed once vmlinux btf becomes
> valid. Jiri's "adding d_path helper" patch set
> https://lore.kernel.org/bpf/20200616100512.2168860-1-jolsa@kernel.org/T/
> provides a way to pre-compute btf id during vmlinux build time.
> This can be applied here as well. A followup patch can convert
> to build time btf id computation after Jiri's patch landed.
>
> Changelogs:
> v4 -> v5:
> - fix bpf_skc_to_udp6_sock helper as besides sk_protocol, sk_family,
> sk_type == SOCK_DGRAM is also needed to differentiate from
> SOCK_RAW (Eric)
Applied. Thanks
Powered by blists - more mailing lists