public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
To: Saket Kumar Bhaskar <skb99@linux.ibm.com>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: ast@kernel.org, hbathini@linux.ibm.com, andrii@kernel.org,
	daniel@iogearbox.net, mykolal@fb.com, martin.lau@linux.dev,
	song@kernel.org, yonghong.song@linux.dev,
	john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
	haoluo@google.com, jolsa@kernel.org, shuah@kernel.org,
	miaxu@meta.com
Subject: Re: [PATCH] selftests/bpf: Fix sockopt selftest failure on powerpc
Date: Wed, 12 Mar 2025 12:47:25 +0530	[thread overview]
Message-ID: <ba66843b-1732-43dc-8296-aee5eb387293@linux.ibm.com> (raw)
In-Reply-To: <20250311084647.3686544-1-skb99@linux.ibm.com>


On 11/03/25 2:16 pm, Saket Kumar Bhaskar wrote:
> The SO_RCVLOWAT option is defined as 18 in the selftest header,
> which matches the generic definition. However, on powerpc,
> SO_RCVLOWAT is defined as 16. This discrepancy causes
> sol_socket_sockopt() to fail with the default switch case on powerpc.
>
> This commit fixes by defining SO_RCVLOWAT as 16 for powerpc.
>
> Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> ---
>   tools/testing/selftests/bpf/progs/bpf_tracing_net.h | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
> index 59843b430f76..bcd44d5018bf 100644
> --- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
> +++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
> @@ -15,7 +15,11 @@
>   #define SO_KEEPALIVE		9
>   #define SO_PRIORITY		12
>   #define SO_REUSEPORT		15
> +#if defined(__TARGET_ARCH_powerpc)
> +#define SO_RCVLOWAT		16
> +#else
>   #define SO_RCVLOWAT		18
> +#endif
>   #define SO_BINDTODEVICE		25
>   #define SO_MARK			36
>   #define SO_MAX_PACING_RATE	47


Applied this patch on linux-mainline and tested. It fixes the issue.

Without this patch:

#define SO_RCVBUF               8
#define SO_KEEPALIVE            9
#define SO_PRIORITY             12
#define SO_REUSEPORT            15
#define SO_RCVLOWAT             18
#define SO_BINDTODEVICE         25
#define SO_MARK                 36


  ./test_progs -t sockopt
#20      bpf_iter_setsockopt:OK
#21      bpf_iter_setsockopt_unix:OK
create_netns:PASS:create netns 0 nsec
create_netns:PASS:set lo up 0 nsec
create_netns:PASS:add veth 0 nsec
create_netns:PASS:bring veth up 0 nsec
test_setget_sockopt:PASS:open skel 0 nsec
test_setget_sockopt:PASS:if_nametoindex 0 nsec
test_setget_sockopt:PASS:load skel 0 nsec
test_setget_sockopt:PASS:attach cgroup 0 nsec
test_setget_sockopt:PASS:attach_cgroup 0 nsec
test_tcp:PASS:start_server 0 nsec
test_tcp:PASS:connect_to_fd_server 0 nsec
test_tcp:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_tcp:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_tcp:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_tcp:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_tcp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_tcp:PASS:nr_bind 0 nsec
test_tcp:PASS:start_server 0 nsec
test_tcp:PASS:connect_to_fd_server 0 nsec
test_tcp:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_tcp:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_tcp:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_tcp:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_tcp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_tcp:PASS:nr_bind 0 nsec
test_udp:PASS:start_server 0 nsec
test_udp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 < expected 1
test_udp:PASS:nr_bind 0 nsec
test_udp:PASS:start_server 0 nsec
test_udp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 < expected 1
test_udp:PASS:nr_bind 0 nsec
test_ktls:PASS:start_server 0 nsec
test_ktls:PASS:connect_to_fd 0 nsec
test_ktls:PASS:accept 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:read 0 nsec
test_ktls:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_ktls:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_ktls:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_ktls:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_ktls:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_ktls:PASS:nr_bind 0 nsec
test_ktls:FAIL:nr_fin_wait1 unexpected nr_fin_wait1: actual 0 != expected 1
test_ktls:PASS:start_server 0 nsec
test_ktls:PASS:connect_to_fd 0 nsec
test_ktls:PASS:accept 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:read 0 nsec
test_ktls:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_ktls:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_ktls:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_ktls:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_ktls:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_ktls:PASS:nr_bind 0 nsec
test_ktls:FAIL:nr_fin_wait1 unexpected nr_fin_wait1: actual 0 != expected 1
test_nonstandard_opt:PASS:start_server 0 nsec
test_nonstandard_opt:PASS:connect_to_fd_server 0 nsec
test_nonstandard_opt:PASS:getsockopt prog 0 nsec
test_nonstandard_opt:PASS:accept 0 nsec
test_nonstandard_opt:PASS:getsockopt_flags 0 nsec
test_nonstandard_opt:PASS:cb_flags_set 0 nsec
test_nonstandard_opt:PASS:start_server 0 nsec
test_nonstandard_opt:PASS:connect_to_fd_server 0 nsec
test_nonstandard_opt:PASS:getsockopt prog 0 nsec
test_nonstandard_opt:PASS:accept 0 nsec
test_nonstandard_opt:PASS:getsockopt_flags 0 nsec
test_nonstandard_opt:PASS:cb_flags_set 0 nsec
#303     setget_sockopt:FAIL
#326/1   sockopt/getsockopt: no expected_attach_type:OK
#326/2   sockopt/getsockopt: wrong expected_attach_type:OK
#326/3   sockopt/getsockopt: bypass bpf hook:OK
#326/4   sockopt/getsockopt: return EPERM from bpf hook:OK
#326/5   sockopt/getsockopt: no optval bounds check, deny loading:OK
#326/6   sockopt/getsockopt: read ctx->level:OK
#326/7   sockopt/getsockopt: deny writing to ctx->level:OK
#326/8   sockopt/getsockopt: read ctx->optname:OK
#326/9   sockopt/getsockopt: read ctx->retval:OK
#326/10  sockopt/getsockopt: deny writing to ctx->optname:OK
#326/11  sockopt/getsockopt: read ctx->optlen:OK
#326/12  sockopt/getsockopt: deny bigger ctx->optlen:OK
#326/13  sockopt/getsockopt: ignore >PAGE_SIZE optlen:OK
#326/14  sockopt/getsockopt: support smaller ctx->optlen:OK
#326/15  sockopt/getsockopt: deny writing to ctx->optval:OK
#326/16  sockopt/getsockopt: deny writing to ctx->optval_end:OK
#326/17  sockopt/getsockopt: rewrite value:OK
#326/18  sockopt/setsockopt: no expected_attach_type:OK
#326/19  sockopt/setsockopt: wrong expected_attach_type:OK
#326/20  sockopt/setsockopt: bypass bpf hook:OK
#326/21  sockopt/setsockopt: return EPERM from bpf hook:OK
#326/22  sockopt/setsockopt: no optval bounds check, deny loading:OK
#326/23  sockopt/setsockopt: read ctx->level:OK
#326/24  sockopt/setsockopt: allow changing ctx->level:OK
#326/25  sockopt/setsockopt: read ctx->optname:OK
#326/26  sockopt/setsockopt: allow changing ctx->optname:OK
#326/27  sockopt/setsockopt: read ctx->optlen:OK
#326/28  sockopt/setsockopt: ctx->optlen == -1 is ok:OK
#326/29  sockopt/setsockopt: deny ctx->optlen < 0 (except -1):OK
#326/30  sockopt/setsockopt: deny ctx->optlen > input optlen:OK
#326/31  sockopt/setsockopt: ignore >PAGE_SIZE optlen:OK
#326/32  sockopt/setsockopt: allow changing ctx->optlen within bounds:OK
#326/33  sockopt/setsockopt: deny write ctx->retval:OK
#326/34  sockopt/setsockopt: deny read ctx->retval:OK
#326/35  sockopt/setsockopt: deny writing to ctx->optval:OK
#326/36  sockopt/setsockopt: deny writing to ctx->optval_end:OK
#326/37  sockopt/setsockopt: allow IP_TOS <= 128:OK
#326/38  sockopt/setsockopt: deny IP_TOS > 128:OK
#326/39  sockopt/can attach only BPF_CGROUP_SETSOCKOP:OK
#326/40  sockopt/can attach only BPF_CGROUP_GETSOCKOP:OK
#326     sockopt:OK
#327     sockopt_inherit:OK
#328     sockopt_multi:OK
#329     sockopt_qos_to_cc:OK
#330     sockopt_sk:OK

All error logs:
create_netns:PASS:create netns 0 nsec
create_netns:PASS:set lo up 0 nsec
create_netns:PASS:add veth 0 nsec
create_netns:PASS:bring veth up 0 nsec
test_setget_sockopt:PASS:open skel 0 nsec
test_setget_sockopt:PASS:if_nametoindex 0 nsec
test_setget_sockopt:PASS:load skel 0 nsec
test_setget_sockopt:PASS:attach cgroup 0 nsec
test_setget_sockopt:PASS:attach_cgroup 0 nsec
test_tcp:PASS:start_server 0 nsec
test_tcp:PASS:connect_to_fd_server 0 nsec
test_tcp:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_tcp:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_tcp:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_tcp:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_tcp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_tcp:PASS:nr_bind 0 nsec
test_tcp:PASS:start_server 0 nsec
test_tcp:PASS:connect_to_fd_server 0 nsec
test_tcp:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_tcp:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_tcp:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_tcp:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_tcp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_tcp:PASS:nr_bind 0 nsec
test_udp:PASS:start_server 0 nsec
test_udp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 < expected 1
test_udp:PASS:nr_bind 0 nsec
test_udp:PASS:start_server 0 nsec
test_udp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 < expected 1
test_udp:PASS:nr_bind 0 nsec
test_ktls:PASS:start_server 0 nsec
test_ktls:PASS:connect_to_fd 0 nsec
test_ktls:PASS:accept 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:read 0 nsec
test_ktls:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_ktls:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_ktls:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_ktls:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_ktls:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_ktls:PASS:nr_bind 0 nsec
test_ktls:FAIL:nr_fin_wait1 unexpected nr_fin_wait1: actual 0 != expected 1
test_ktls:PASS:start_server 0 nsec
test_ktls:PASS:connect_to_fd 0 nsec
test_ktls:PASS:accept 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:setsockopt 0 nsec
test_ktls:PASS:read 0 nsec
test_ktls:FAIL:nr_listen unexpected nr_listen: actual 0 != expected 1
test_ktls:FAIL:nr_connect unexpected nr_connect: actual 0 != expected 1
test_ktls:FAIL:nr_active unexpected nr_active: actual 0 != expected 1
test_ktls:FAIL:nr_passive unexpected nr_passive: actual 0 != expected 1
test_ktls:FAIL:nr_socket_post_create unexpected nr_socket_post_create: 
actual 0 != expected 2
test_ktls:PASS:nr_bind 0 nsec
test_ktls:FAIL:nr_fin_wait1 unexpected nr_fin_wait1: actual 0 != expected 1
test_nonstandard_opt:PASS:start_server 0 nsec
test_nonstandard_opt:PASS:connect_to_fd_server 0 nsec
test_nonstandard_opt:PASS:getsockopt prog 0 nsec
test_nonstandard_opt:PASS:accept 0 nsec
test_nonstandard_opt:PASS:getsockopt_flags 0 nsec
test_nonstandard_opt:PASS:cb_flags_set 0 nsec
test_nonstandard_opt:PASS:start_server 0 nsec
test_nonstandard_opt:PASS:connect_to_fd_server 0 nsec
test_nonstandard_opt:PASS:getsockopt prog 0 nsec
test_nonstandard_opt:PASS:accept 0 nsec
test_nonstandard_opt:PASS:getsockopt_flags 0 nsec
test_nonstandard_opt:PASS:cb_flags_set 0 nsec
#303     setget_sockopt:FAIL
Summary: 7/40 PASSED, 0 SKIPPED, 1 FAILED


With this patch:


#if defined(__TARGET_ARCH_powerpc)
#define SO_RCVLOWAT             16
#else
#define SO_RCVLOWAT             18
#endif
#define SO_BINDTODEVICE         25
#define SO_MARK                 36
#define SO_MAX_PACING_RATE      47


./test_progs -t sockopt
#20      bpf_iter_setsockopt:OK
#21      bpf_iter_setsockopt_unix:OK
#303     setget_sockopt:OK
#326/1   sockopt/getsockopt: no expected_attach_type:OK
#326/2   sockopt/getsockopt: wrong expected_attach_type:OK
#326/3   sockopt/getsockopt: bypass bpf hook:OK
#326/4   sockopt/getsockopt: return EPERM from bpf hook:OK
#326/5   sockopt/getsockopt: no optval bounds check, deny loading:OK
#326/6   sockopt/getsockopt: read ctx->level:OK
#326/7   sockopt/getsockopt: deny writing to ctx->level:OK
#326/8   sockopt/getsockopt: read ctx->optname:OK
#326/9   sockopt/getsockopt: read ctx->retval:OK
#326/10  sockopt/getsockopt: deny writing to ctx->optname:OK
#326/11  sockopt/getsockopt: read ctx->optlen:OK
#326/12  sockopt/getsockopt: deny bigger ctx->optlen:OK
#326/13  sockopt/getsockopt: ignore >PAGE_SIZE optlen:OK
#326/14  sockopt/getsockopt: support smaller ctx->optlen:OK
#326/15  sockopt/getsockopt: deny writing to ctx->optval:OK
#326/16  sockopt/getsockopt: deny writing to ctx->optval_end:OK
#326/17  sockopt/getsockopt: rewrite value:OK
#326/18  sockopt/setsockopt: no expected_attach_type:OK
#326/19  sockopt/setsockopt: wrong expected_attach_type:OK
#326/20  sockopt/setsockopt: bypass bpf hook:OK
#326/21  sockopt/setsockopt: return EPERM from bpf hook:OK
#326/22  sockopt/setsockopt: no optval bounds check, deny loading:OK
#326/23  sockopt/setsockopt: read ctx->level:OK
#326/24  sockopt/setsockopt: allow changing ctx->level:OK
#326/25  sockopt/setsockopt: read ctx->optname:OK
#326/26  sockopt/setsockopt: allow changing ctx->optname:OK
#326/27  sockopt/setsockopt: read ctx->optlen:OK
#326/28  sockopt/setsockopt: ctx->optlen == -1 is ok:OK
#326/29  sockopt/setsockopt: deny ctx->optlen < 0 (except -1):OK
#326/30  sockopt/setsockopt: deny ctx->optlen > input optlen:OK
#326/31  sockopt/setsockopt: ignore >PAGE_SIZE optlen:OK
#326/32  sockopt/setsockopt: allow changing ctx->optlen within bounds:OK
#326/33  sockopt/setsockopt: deny write ctx->retval:OK
#326/34  sockopt/setsockopt: deny read ctx->retval:OK
#326/35  sockopt/setsockopt: deny writing to ctx->optval:OK
#326/36  sockopt/setsockopt: deny writing to ctx->optval_end:OK
#326/37  sockopt/setsockopt: allow IP_TOS <= 128:OK
#326/38  sockopt/setsockopt: deny IP_TOS > 128:OK
#326/39  sockopt/can attach only BPF_CGROUP_SETSOCKOP:OK
#326/40  sockopt/can attach only BPF_CGROUP_GETSOCKOP:OK
#326     sockopt:OK
#327     sockopt_inherit:OK
#328     sockopt_multi:OK
#329     sockopt_qos_to_cc:OK
#330     sockopt_sk:OK
Summary: 8/40 PASSED, 0 SKIPPED, 0 FAILED

Please add below tag.

Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>


Regards,

Venkat.


  reply	other threads:[~2025-03-12  7:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11  8:46 [PATCH] selftests/bpf: Fix sockopt selftest failure on powerpc Saket Kumar Bhaskar
2025-03-12  7:17 ` Venkat Rao Bagalkote [this message]
2025-03-13 21:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba66843b-1732-43dc-8296-aee5eb387293@linux.ibm.com \
    --to=venkat88@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=hbathini@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=miaxu@meta.com \
    --cc=mykolal@fb.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=skb99@linux.ibm.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox