* [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value
@ 2026-11-22 15:49 Jingjing Xu
2026-11-22 15:49 ` [PATCH net-next 2/2] selftests: net: cover zero receive mark and priority Jingjing Xu
2026-11-23 2:59 ` [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value Hangbin Liu
0 siblings, 2 replies; 4+ messages in thread
From: Jingjing Xu @ 2026-11-22 15:49 UTC (permalink / raw)
To: netdev
Cc: linux-kselftest, kuba, edumazet, pabeni, horms, shuah, willemb,
annaemesenyiri, idosch
so_rcv_listener passes the expected mark or priority to setsockopt() as
its SO_RCVMARK or SO_RCVPRIORITY enable flag. Consequently, expecting zero
also disables the ancillary message being tested. A zero mark or priority
is valid, but invoking the listener with -M 0 or -P 0 fails with ENOMSG.
Use a separate nonzero flag to enable reception and keep opt.val solely
for checking the received value.
This issue was found with AI-assisted source review and reproduced using
real UDP sockets. Zero and nonzero mark/priority tests pass over IPv4 and
IPv6 after the fix; the zero cases fail on the original helper.
No kernel instrumentation or fault injection was used.
Fixes: c935af429ec2 ("selftests: net: add support for testing SO_RCVMARK and SO_RCVPRIORITY")
Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
---
tools/testing/selftests/net/so_rcv_listener.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/so_rcv_listener.c b/tools/testing/selftests/net/so_rcv_listener.c
index bc5841192aa6..3d43fa688338 100644
--- a/tools/testing/selftests/net/so_rcv_listener.c
+++ b/tools/testing/selftests/net/so_rcv_listener.c
@@ -65,6 +65,7 @@ static void parse_args(int argc, char *argv[])
int main(int argc, char *argv[])
{
+ int enable = 1;
int err = 0;
int recv_fd = -1;
int ret_value = 0;
@@ -88,7 +89,7 @@ int main(int argc, char *argv[])
goto cleanup;
}
- err = setsockopt(recv_fd, SOL_SOCKET, opt.rcvname, &opt.val, sizeof(opt.val));
+ err = setsockopt(recv_fd, SOL_SOCKET, opt.rcvname, &enable, sizeof(enable));
if (err < 0) {
perror("Recv setsockopt error");
ret_value = -errno;
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net-next 2/2] selftests: net: cover zero receive mark and priority
2026-11-22 15:49 [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value Jingjing Xu
@ 2026-11-22 15:49 ` Jingjing Xu
2026-11-23 2:44 ` Hangbin Liu
2026-11-23 2:59 ` [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value Hangbin Liu
1 sibling, 1 reply; 4+ messages in thread
From: Jingjing Xu @ 2026-11-22 15:49 UTC (permalink / raw)
To: netdev
Cc: linux-kselftest, kuba, edumazet, pabeni, horms, shuah, willemb,
annaemesenyiri, idosch
Exercise SO_RCVMARK and SO_RCVPRIORITY with zero values as well as the
existing nonzero values, for both IPv4 and IPv6. These cases catch using
the expected metadata value as the ancillary-message enable flag.
Use the lowercase ksft_fail and ksft_pass constants defined by lib.sh.
The uppercase names are undefined, so the failure path otherwise exits
with the status of echo and incorrectly reports success to the runner.
With the new tests and the original listener, four of eight cases fail
and the script exits with status 1. With the fixed listener, all eight
pass and the script exits with status 0. The original four cases also
pass with the original listener. Verification used real UDP sockets in
isolated network namespaces; discovery and testing were AI-assisted.
No kernel instrumentation or fault injection was used.
Fixes: c935af429ec2 ("selftests: net: add support for testing SO_RCVMARK and SO_RCVPRIORITY")
Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
---
tools/testing/selftests/net/test_so_rcv.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/test_so_rcv.sh b/tools/testing/selftests/net/test_so_rcv.sh
index d8aa4362879d..3263ba2d1a67 100755
--- a/tools/testing/selftests/net/test_so_rcv.sh
+++ b/tools/testing/selftests/net/test_so_rcv.sh
@@ -11,6 +11,8 @@ FAILED_TESTS=0
declare -A TESTS=(
["SO_RCVPRIORITY"]="-P 2"
["SO_RCVMARK"]="-M 3"
+ ["SO_RCVPRIORITY_ZERO"]="-P 0"
+ ["SO_RCVMARK_ZERO"]="-M 0"
)
check_result() {
@@ -66,8 +68,8 @@ done
if [ "$FAILED_TESTS" -ne 0 ]; then
echo "FAIL - $FAILED_TESTS/$TOTAL_TESTS tests failed"
- exit ${KSFT_FAIL}
+ exit ${ksft_fail}
else
echo "OK - All $TOTAL_TESTS tests passed"
- exit ${KSFT_PASS}
+ exit ${ksft_pass}
fi
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next 2/2] selftests: net: cover zero receive mark and priority
2026-11-22 15:49 ` [PATCH net-next 2/2] selftests: net: cover zero receive mark and priority Jingjing Xu
@ 2026-11-23 2:44 ` Hangbin Liu
0 siblings, 0 replies; 4+ messages in thread
From: Hangbin Liu @ 2026-11-23 2:44 UTC (permalink / raw)
To: Jingjing Xu
Cc: netdev, linux-kselftest, kuba, edumazet, pabeni, horms, shuah,
willemb, annaemesenyiri, idosch
Hi Jingjing,
On Sun, Nov 22, 2026 at 03:49:12PM +0000, Jingjing Xu wrote:
> Exercise SO_RCVMARK and SO_RCVPRIORITY with zero values as well as the
> existing nonzero values, for both IPv4 and IPv6. These cases catch using
> the expected metadata value as the ancillary-message enable flag.
>
> Use the lowercase ksft_fail and ksft_pass constants defined by lib.sh.
> The uppercase names are undefined, so the failure path otherwise exits
> with the status of echo and incorrectly reports success to the runner.
>
> With the new tests and the original listener, four of eight cases fail
> and the script exits with status 1. With the fixed listener, all eight
> pass and the script exits with status 0. The original four cases also
> pass with the original listener. Verification used real UDP sockets in
> isolated network namespaces; discovery and testing were AI-assisted.
>
> No kernel instrumentation or fault injection was used.
>
> Fixes: c935af429ec2 ("selftests: net: add support for testing SO_RCVMARK and SO_RCVPRIORITY")
> Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
> ---
> tools/testing/selftests/net/test_so_rcv.sh | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/test_so_rcv.sh b/tools/testing/selftests/net/test_so_rcv.sh
> index d8aa4362879d..3263ba2d1a67 100755
> --- a/tools/testing/selftests/net/test_so_rcv.sh
> +++ b/tools/testing/selftests/net/test_so_rcv.sh
> @@ -11,6 +11,8 @@ FAILED_TESTS=0
> declare -A TESTS=(
> ["SO_RCVPRIORITY"]="-P 2"
> ["SO_RCVMARK"]="-M 3"
> + ["SO_RCVPRIORITY_ZERO"]="-P 0"
> + ["SO_RCVMARK_ZERO"]="-M 0"
> )
>
These are 2 new test cases.
> check_result() {
> @@ -66,8 +68,8 @@ done
>
> if [ "$FAILED_TESTS" -ne 0 ]; then
> echo "FAIL - $FAILED_TESTS/$TOTAL_TESTS tests failed"
> - exit ${KSFT_FAIL}
> + exit ${ksft_fail}
> else
> echo "OK - All $TOTAL_TESTS tests passed"
> - exit ${KSFT_PASS}
> + exit ${ksft_pass}
And this is a stand along fix.
I think you can split this into another patch.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value
2026-11-22 15:49 [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value Jingjing Xu
2026-11-22 15:49 ` [PATCH net-next 2/2] selftests: net: cover zero receive mark and priority Jingjing Xu
@ 2026-11-23 2:59 ` Hangbin Liu
1 sibling, 0 replies; 4+ messages in thread
From: Hangbin Liu @ 2026-11-23 2:59 UTC (permalink / raw)
To: Jingjing Xu
Cc: netdev, linux-kselftest, kuba, edumazet, pabeni, horms, shuah,
willemb, annaemesenyiri, idosch
On Sun, Nov 22, 2026 at 03:49:11PM +0000, Jingjing Xu wrote:
> so_rcv_listener passes the expected mark or priority to setsockopt() as
> its SO_RCVMARK or SO_RCVPRIORITY enable flag. Consequently, expecting zero
> also disables the ancillary message being tested. A zero mark or priority
> is valid, but invoking the listener with -M 0 or -P 0 fails with ENOMSG.
>
> Use a separate nonzero flag to enable reception and keep opt.val solely
> for checking the received value.
>
> This issue was found with AI-assisted source review and reproduced using
> real UDP sockets. Zero and nonzero mark/priority tests pass over IPv4 and
> IPv6 after the fix; the zero cases fail on the original helper.
>
> No kernel instrumentation or fault injection was used.
>
> Fixes: c935af429ec2 ("selftests: net: add support for testing SO_RCVMARK and SO_RCVPRIORITY")
> Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
> ---
> tools/testing/selftests/net/so_rcv_listener.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/so_rcv_listener.c b/tools/testing/selftests/net/so_rcv_listener.c
> index bc5841192aa6..3d43fa688338 100644
> --- a/tools/testing/selftests/net/so_rcv_listener.c
> +++ b/tools/testing/selftests/net/so_rcv_listener.c
> @@ -65,6 +65,7 @@ static void parse_args(int argc, char *argv[])
>
> int main(int argc, char *argv[])
> {
> + int enable = 1;
> int err = 0;
> int recv_fd = -1;
> int ret_value = 0;
> @@ -88,7 +89,7 @@ int main(int argc, char *argv[])
> goto cleanup;
> }
>
> - err = setsockopt(recv_fd, SOL_SOCKET, opt.rcvname, &opt.val, sizeof(opt.val));
> + err = setsockopt(recv_fd, SOL_SOCKET, opt.rcvname, &enable, sizeof(enable));
> if (err < 0) {
> perror("Recv setsockopt error");
> ret_value = -errno;
> base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
> --
> 2.53.0
>
>
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 2:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 15:49 [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value Jingjing Xu
2026-11-22 15:49 ` [PATCH net-next 2/2] selftests: net: cover zero receive mark and priority Jingjing Xu
2026-11-23 2:44 ` Hangbin Liu
2026-11-23 2:59 ` [PATCH net-next 1/2] selftests: net: enable receive metadata independently of its value Hangbin Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox