]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
net: bpf: Add bpf_seq_afinfo in tcp_iter_state
authorYonghong Song <yhs@fb.com>
Tue, 23 Jun 2020 23:08:04 +0000 (16:08 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 25 Jun 2020 01:37:58 +0000 (18:37 -0700)
commitb08d4d3b6c0460306e8a0608413b201705200d33
treea39e5c744a188a6fe33a240facc9cd4159919d63
parentf9bcf96837f158db6ea982d15cd2c8161ca6bc23
net: bpf: Add bpf_seq_afinfo in tcp_iter_state

A new field bpf_seq_afinfo is added to tcp_iter_state
to provide bpf tcp iterator afinfo. There are two
reasons on why we did this.

First, the current way to get afinfo from PDE_DATA
does not work for bpf iterator as its seq_file
inode does not conform to /proc/net/{tcp,tcp6}
inode structures. More specifically, anonymous
bpf iterator will use an anonymous inode which
is shared in the system and we cannot change inode
private data structure at all.

Second, bpf iterator for tcp/tcp6 wants to
traverse all tcp and tcp6 sockets in one pass
and bpf program can control whether they want
to skip one sk_family or not. Having a different
afinfo with family AF_UNSPEC make it easier
to understand in the code.

This patch does not change /proc/net/{tcp,tcp6} behavior
as the bpf_seq_afinfo will be NULL for these two proc files.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200623230804.3987829-1-yhs@fb.com
include/net/tcp.h
net/ipv4/tcp_ipv4.c