• Yonghong Song's avatar
    net: bpf: Add bpf_seq_afinfo in tcp_iter_state · b08d4d3b
    Yonghong Song authored
    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: default avatarYonghong Song <yhs@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Link: https://lore.kernel.org/bpf/20200623230804.3987829-1-yhs@fb.com
    b08d4d3b
tcp.h 70.8 KB