Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] selftests: net: fix receive metadata and failure reporting
@ 2026-11-25  6:41 Jingjing Xu
  2026-11-25  6:41 ` [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner Jingjing Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jingjing Xu @ 2026-11-25  6:41 UTC (permalink / raw)
  To: netdev
  Cc: linux-kselftest, kuba, edumazet, pabeni, horms, shuah, willemb,
	annaemesenyiri, idosch, hangbin.liu

Separate the failure-status correction from the zero-value tests, as
requested by Hangbin Liu. The first patch repairs script failure reporting,
the second enables reception independently of the expected metadata, and
the third adds the zero mark/priority cases to the existing test.

Changes in v2:
- Split the exit-constant correction into a standalone fix (Hangbin Liu).
- Put both fixes before the added regression cases.
- Retain Hangbin Liu's Reviewed-by only on the receive-enable fix.
- Wrap that setsockopt() call to stay within 80 columns; behavior unchanged.
- Rebase onto net-next 57f165ff2f30.

v1:
https://lore.kernel.org/netdev/20261122154912.1272447-1-xujingjing@cmss.chinamobile.com/
Split request:
https://patchwork.kernel.org/comment/27396929/
Core-fix review:
https://patchwork.kernel.org/comment/27396955/

Validation used the existing host kernel and real IPv4/IPv6 UDP sockets
in private mount/network namespaces. The original four cases pass before
and after the fixes. A user-space mismatched-metadata sender makes those
four cases fail: the original script exits 0; patch 1 exits 1. Extended zero
cases with the original listener fail 4/8 and exit 1. The complete series
passes 8/8 and exits 0. All helpers build with gcc -Wall -Werror -O2.
No kernel instrumentation or kernel fault injection was used. The negative
sender fixture deliberately changes only user-space metadata arguments.
No hardware test suite was run.

Jingjing Xu (3):
  selftests: net: report SO_RCV test failures to the runner
  selftests: net: enable receive metadata independently of its value
  selftests: net: cover zero receive mark and priority

 tools/testing/selftests/net/so_rcv_listener.c | 4 +++-
 tools/testing/selftests/net/test_so_rcv.sh    | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.53.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner
  2026-11-25  6:41 [PATCH net-next v2 0/3] selftests: net: fix receive metadata and failure reporting Jingjing Xu
@ 2026-11-25  6:41 ` Jingjing Xu
  2026-11-25  7:18   ` Hangbin Liu
  2026-11-25  6:41 ` [PATCH net-next v2 2/3] selftests: net: enable receive metadata independently of its value Jingjing Xu
  2026-11-25  6:41 ` [PATCH net-next v2 3/3] selftests: net: cover zero receive mark and priority Jingjing Xu
  2 siblings, 1 reply; 5+ messages in thread
From: Jingjing Xu @ 2026-11-25  6:41 UTC (permalink / raw)
  To: netdev
  Cc: linux-kselftest, kuba, edumazet, pabeni, horms, shuah, willemb,
	annaemesenyiri, idosch, hangbin.liu

test_so_rcv.sh uses KSFT_FAIL and KSFT_PASS, but lib.sh defines the
lowercase ksft_fail and ksft_pass constants. With the uppercase variables
unset, exit has no argument and returns the successful echo status, even
when the script has reported failed tests.

Use the constants actually provided by lib.sh so failures produce a
nonzero exit status.

Run as root from tools/testing/selftests/net after building the helpers.
For the original four-case script, this changes only sender metadata to 1
while the listeners still expect 2 or 3:

  sed '/\.\/cmsg_sender/s/\$arg/${arg% *} 1/' test_so_rcv.sh | bash
  echo $?

Both versions report four failures. The original prints 0 as the exit
status; with this fix it prints 1.

AI-assisted inspection found this while extending the receive tests.
With deliberately mismatched sender metadata, all four original cases
fail on both versions: the original script exits 0 and
the corrected script exits 1. The unmodified sender passes all four cases
with exit 0. 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 | 4 ++--
 1 file changed, 2 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..ae01fa3c5329 100755
--- a/tools/testing/selftests/net/test_so_rcv.sh
+++ b/tools/testing/selftests/net/test_so_rcv.sh
@@ -66,8 +66,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: 57f165ff2f30491bc3511d24a52ca516751a268b
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 2/3] selftests: net: enable receive metadata independently of its value
  2026-11-25  6:41 [PATCH net-next v2 0/3] selftests: net: fix receive metadata and failure reporting Jingjing Xu
  2026-11-25  6:41 ` [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner Jingjing Xu
@ 2026-11-25  6:41 ` Jingjing Xu
  2026-11-25  6:41 ` [PATCH net-next v2 3/3] selftests: net: cover zero receive mark and priority Jingjing Xu
  2 siblings, 0 replies; 5+ messages in thread
From: Jingjing Xu @ 2026-11-25  6:41 UTC (permalink / raw)
  To: netdev
  Cc: linux-kselftest, kuba, edumazet, pabeni, horms, shuah, willemb,
	annaemesenyiri, idosch, hangbin.liu

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")
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
---
 tools/testing/selftests/net/so_rcv_listener.c | 4 +++-
 1 file changed, 3 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..a57fff256cc2 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,8 @@ 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: 57f165ff2f30491bc3511d24a52ca516751a268b
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 3/3] selftests: net: cover zero receive mark and priority
  2026-11-25  6:41 [PATCH net-next v2 0/3] selftests: net: fix receive metadata and failure reporting Jingjing Xu
  2026-11-25  6:41 ` [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner Jingjing Xu
  2026-11-25  6:41 ` [PATCH net-next v2 2/3] selftests: net: enable receive metadata independently of its value Jingjing Xu
@ 2026-11-25  6:41 ` Jingjing Xu
  2 siblings, 0 replies; 5+ messages in thread
From: Jingjing Xu @ 2026-11-25  6:41 UTC (permalink / raw)
  To: netdev
  Cc: linux-kselftest, kuba, edumazet, pabeni, horms, shuah, willemb,
	annaemesenyiri, idosch, hangbin.liu

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.

With the new tests and the original listener, four of eight cases fail
and the corrected 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.

Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
---
 tools/testing/selftests/net/test_so_rcv.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/net/test_so_rcv.sh b/tools/testing/selftests/net/test_so_rcv.sh
index ae01fa3c5329..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() {
base-commit: 57f165ff2f30491bc3511d24a52ca516751a268b
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner
  2026-11-25  6:41 ` [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner Jingjing Xu
@ 2026-11-25  7:18   ` Hangbin Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Hangbin Liu @ 2026-11-25  7:18 UTC (permalink / raw)
  To: Jingjing Xu
  Cc: netdev, linux-kselftest, kuba, edumazet, pabeni, horms, shuah,
	willemb, annaemesenyiri, idosch

On Wed, Nov 25, 2026 at 06:41:08AM +0000, Jingjing Xu wrote:
> test_so_rcv.sh uses KSFT_FAIL and KSFT_PASS, but lib.sh defines the
> lowercase ksft_fail and ksft_pass constants. With the uppercase variables
> unset, exit has no argument and returns the successful echo status, even
> when the script has reported failed tests.
> 
> Use the constants actually provided by lib.sh so failures produce a
> nonzero exit status.
> 
> Run as root from tools/testing/selftests/net after building the helpers.
> For the original four-case script, this changes only sender metadata to 1
> while the listeners still expect 2 or 3:
> 
>   sed '/\.\/cmsg_sender/s/\$arg/${arg% *} 1/' test_so_rcv.sh | bash
>   echo $?
> 
> Both versions report four failures. The original prints 0 as the exit
> status; with this fix it prints 1.
> 
> AI-assisted inspection found this while extending the receive tests.
> With deliberately mismatched sender metadata, all four original cases
> fail on both versions: the original script exits 0 and
> the corrected script exits 1. The unmodified sender passes all four cases
> with exit 0. 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 | 4 ++--
>  1 file changed, 2 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..ae01fa3c5329 100755
> --- a/tools/testing/selftests/net/test_so_rcv.sh
> +++ b/tools/testing/selftests/net/test_so_rcv.sh
> @@ -66,8 +66,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: 57f165ff2f30491bc3511d24a52ca516751a268b
> -- 
> 2.53.0
> 
> 
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-25  7:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  6:41 [PATCH net-next v2 0/3] selftests: net: fix receive metadata and failure reporting Jingjing Xu
2026-11-25  6:41 ` [PATCH net-next v2 1/3] selftests: net: report SO_RCV test failures to the runner Jingjing Xu
2026-11-25  7:18   ` Hangbin Liu
2026-11-25  6:41 ` [PATCH net-next v2 2/3] selftests: net: enable receive metadata independently of its value Jingjing Xu
2026-11-25  6:41 ` [PATCH net-next v2 3/3] selftests: net: cover zero receive mark and priority Jingjing Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox