selftests/bpf: Add an iterator selftest for bpf_sk_storage_get
authorFlorent Revest <revest@chromium.org>
Fri, 4 Dec 2020 11:36:08 +0000 (12:36 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 4 Dec 2020 21:32:40 +0000 (22:32 +0100)
commitbd9b327e58f98aa7126291bf12b50720c660e787
treec675f7887871b6279c14de91bfb4722e006f4baf
parent593f6d41abbbc63e1ad297f7a36ab6060a812f0c
selftests/bpf: Add an iterator selftest for bpf_sk_storage_get

The eBPF program iterates over all files and tasks. For all socket
files, it stores the tgid of the last task it encountered with a handle
to that socket. This is a heuristic for finding the "owner" of a socket
similar to what's done by lsof, ss, netstat or fuser. Potentially, this
information could be used from a cgroup_skb/*gress hook to try to
associate network traffic with processes.

The test makes sure that a socket it created is tagged with prog_tests's
pid.

Signed-off-by: Florent Revest <revest@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20201204113609.1850150-5-revest@google.com
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
tools/testing/selftests/bpf/progs/bpf_iter_bpf_sk_storage_helpers.c