selftest/bpf: Implement sample UNIX domain socket iterator program.
authorKuniyuki Iwashima <kuniyu@amazon.co.jp>
Sat, 14 Aug 2021 01:57:17 +0000 (10:57 +0900)
committerAndrii Nakryiko <andrii@kernel.org>
Sun, 15 Aug 2021 07:19:06 +0000 (00:19 -0700)
commit04e928180c14332fb15a1b8c64418b602978a51e
treec96b6d5b4e844e7d9280eb5fa3ad1d42ac4019c0
parent3478cfcfcddff0f3aad82891be2992e51c4f7936
selftest/bpf: Implement sample UNIX domain socket iterator program.

The iterator can output almost the same result compared to /proc/net/unix.
The header line is aligned, and the Inode column uses "%8lu" because "%5lu"
can be easily overflown.

  # cat /sys/fs/bpf/unix
  Num               RefCount Protocol Flags    Type St    Inode Path
  ffff963c0668980000000002 00000000 00010000 0001 01    18697 private/defer
  ffff963c7c979c0000000002 00000000 00000000 0001 01   598245 @Hello@World@

  # cat /proc/net/unix
  Num       RefCount Protocol Flags    Type St Inode Path
  ffff963c0668980000000002 00000000 00010000 0001 01 18697 private/defer
  ffff963c7c979c0000000002 00000000 00000000 0001 01 598245 @Hello@World@

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210814015718.42704-4-kuniyu@amazon.co.jp
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
tools/testing/selftests/bpf/progs/bpf_iter.h
tools/testing/selftests/bpf/progs/bpf_iter_unix.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/bpf_tracing_net.h