bpf: selftest: Use bpf_skc_to_tcp_sock() in the sock_fields test
authorMartin KaFai Lau <kafai@fb.com>
Fri, 25 Sep 2020 00:04:46 +0000 (17:04 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 25 Sep 2020 20:58:02 +0000 (13:58 -0700)
commitedc2d66ad1851db6bd89a611b4e46470f1a40ba9
tree1edab3b11e5cf6f9c7973016c7e1bf9f0b813967
parentc40a565a04afd0429ecc8a1a2c9aff897796118f
bpf: selftest: Use bpf_skc_to_tcp_sock() in the sock_fields test

This test uses bpf_skc_to_tcp_sock() to get a kernel tcp_sock ptr "ktp".
Access the ktp->lsndtime and also pass ktp to bpf_sk_storage_get().

It also exercises the bpf_sk_cgroup_id() and bpf_sk_ancestor_cgroup_id()
with the "ktp".  To do that, a parent cgroup and a child cgroup are
created.  The bpf prog is attached to the child cgroup.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200925000446.3858975-1-kafai@fb.com
tools/testing/selftests/bpf/prog_tests/sock_fields.c
tools/testing/selftests/bpf/progs/test_sock_fields.c