selftests/bpf: Update sockopt_sk test to the use bpf_set_retval
authorYiFei Zhu <zhuyifei@google.com>
Thu, 16 Dec 2021 02:04:29 +0000 (02:04 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 19 Jan 2022 21:05:13 +0000 (13:05 -0800)
commit1080ef5cc0c2c3419dbdd61e441d1e014410824a
tree544557b28f5a9e23ab446bcd10cd004d6099db45
parentb8bff6f890513e0ae0f711e481b368c1d133c558
selftests/bpf: Update sockopt_sk test to the use bpf_set_retval

The tests would break without this patch, because at one point it calls
  getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen)
This getsockopt receives the kernel-set -EINVAL. Prior to this patch
series, the eBPF getsockopt hook's -EPERM would override kernel's
-EINVAL, however, after this patch series, return 0's automatic
-EPERM will not; the eBPF prog has to explicitly bpf_set_retval(-EPERM)
if that is wanted.

I also removed the explicit mentions of EPERM in the comments in the
prog.

Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/4f20b77cb46812dbc2bdcd7e3fa87c7573bde55e.1639619851.git.zhuyifei@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
tools/testing/selftests/bpf/progs/sockopt_sk.c