Skip to content

Commit 13e7a6e

Browse files
Geliang Tanggregkh
authored andcommitted
selftests: mptcp: sockopt: fix error messages
[ Upstream commit b86418b ] This patch fixes several issues in the error reporting of the MPTCP sockopt selftest: 1. Fix diff not printed: The error messages for counter mismatches had the actual difference ('diff') as argument, but it was missing in the format string. Displaying it makes the debugging easier. 2. Fix variable usage: The error check for 'mptcpi_bytes_acked' incorrectly used 'ret2' (sent bytes) for both the expected value and the difference calculation. It now correctly uses 'ret' (received bytes), which is the expected value for bytes_acked. 3. Fix off-by-one in diff: The calculation for the 'mptcpi_rcv_delta' diff was 's.mptcpi_rcv_delta - ret', which is off-by-one. It has been corrected to 's.mptcpi_rcv_delta - (ret + 1)' to match the expected value in the condition above it. Fixes: 5dcff89 ("selftests: mptcp: explicitly tests aggregate counters") Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20250912-net-mptcp-pm-uspace-deny_join_id0-v1-5-40171884ade8@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 10e54bf commit 13e7a6e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tools/testing/selftests/net/mptcp/mptcp_sockopt.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,22 +658,26 @@ static void process_one_client(int fd, int pipefd)
658658

659659
do_getsockopts(&s, fd, ret, ret2);
660660
if (s.mptcpi_rcv_delta != (uint64_t)ret + 1)
661-
xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret);
661+
xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64 ", diff %" PRId64,
662+
s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - (ret + 1));
662663

663664
/* be nice when running on top of older kernel */
664665
if (s.pkt_stats_avail) {
665666
if (s.last_sample.mptcpi_bytes_sent != ret2)
666-
xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64,
667+
xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64
668+
", diff %" PRId64,
667669
s.last_sample.mptcpi_bytes_sent, ret2,
668670
s.last_sample.mptcpi_bytes_sent - ret2);
669671
if (s.last_sample.mptcpi_bytes_received != ret)
670-
xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64,
672+
xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64
673+
", diff %" PRId64,
671674
s.last_sample.mptcpi_bytes_received, ret,
672675
s.last_sample.mptcpi_bytes_received - ret);
673676
if (s.last_sample.mptcpi_bytes_acked != ret)
674-
xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64,
675-
s.last_sample.mptcpi_bytes_acked, ret2,
676-
s.last_sample.mptcpi_bytes_acked - ret2);
677+
xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64
678+
", diff %" PRId64,
679+
s.last_sample.mptcpi_bytes_acked, ret,
680+
s.last_sample.mptcpi_bytes_acked - ret);
677681
}
678682

679683
close(fd);

0 commit comments

Comments
 (0)