From nobody Wed Sep 17 16:39:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6EBE7494 for ; Fri, 12 Sep 2025 03:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757648415; cv=none; b=hk+ebu2HyT5FwgknJczY5ARen8rMnQ1JN3mlY7NblJKsieGj8AO7SUTxGxpYSHnW5G+NmyvAoNZdC7CrW7Ii+4Smzdxd6Wt6poByyR1GLQXMIesNvAv47+cPd9ujT4IgTx21xVS0qcShreLZIk7A6ydkwMbSwl5iXbhk6FFYo+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757648415; c=relaxed/simple; bh=FzaI3OlxGvwaDioGWLmO5qY7kCDTpj0+XvxM+WzGfY8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZSGsbxv7zqEzkS8bGa9eOYugugX+yZOL9UduOthG8gZJV+OzgZsisp30KgOO5XfH7ZlSV6nLX7g84XKEDDcjyn+n/CWKpQgMcJs9JOSyQLhZhEWr3iTTIX46nS77B98fXNf2/3RYSaqINOnC4d7NDR8YB6MNNXXZr+Md7/CoWkc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oSuRvi2z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oSuRvi2z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68EFDC4CEF4; Fri, 12 Sep 2025 03:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757648414; bh=FzaI3OlxGvwaDioGWLmO5qY7kCDTpj0+XvxM+WzGfY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oSuRvi2zKboXWgNDfobkEiPR3FyQ/CrqVWBbQJVn34HcUjQaIVi5yhnaFxuDQi1sE bNP3satQ6vBfCQnOfGRs+NH7Wilsncp/hjgIT5Cq5wGIuevUbhOY7aZJ3lgUku4cD7 syBaPv42hvaeVYZIGgmkHGRwQr2TZ9yTsOSN63G1lx6+BFm6j31tT2NnUZ7YCavLgk wOswVcH5YOsgOgVLMW6OHuBAA9uL0dUpc9myAS+mR7w4e3S1aOZ1zzJzpV58Cl0M5A M7sEOYK7SI7Dl8qQe7rV2JpolIaE8GXtN4FC97HD/e8ZtSHQC2DJqlyYp7DQm1rT2W Ve3mKfG6oAYoQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-net v3 1/3] selftests: mptcp: sockopt: fix error messages Date: Fri, 12 Sep 2025 11:40:03 +0800 Message-ID: <46a76424b742faf97df213882d1048cfec2348be.1757647967.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang 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: 5dcff89e1455 ("selftests: mptcp: explicitly tests aggregate counters= ") Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- .../testing/selftests/net/mptcp/mptcp_sockopt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/test= ing/selftests/net/mptcp/mptcp_sockopt.c index e934dd26a59d..112c07c4c37a 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -667,22 +667,26 @@ static void process_one_client(int fd, int pipefd) =20 do_getsockopts(&s, fd, ret, ret2); if (s.mptcpi_rcv_delta !=3D (uint64_t)ret + 1) - xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_del= ta, ret + 1, s.mptcpi_rcv_delta - ret); + xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64 ", diff %" PRId64, + s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - (ret + 1)); =20 /* be nice when running on top of older kernel */ if (s.pkt_stats_avail) { if (s.last_sample.mptcpi_bytes_sent !=3D ret2) - xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64, + xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64 + ", diff %" PRId64, s.last_sample.mptcpi_bytes_sent, ret2, s.last_sample.mptcpi_bytes_sent - ret2); if (s.last_sample.mptcpi_bytes_received !=3D ret) - xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64, + xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64 + ", diff %" PRId64, s.last_sample.mptcpi_bytes_received, ret, s.last_sample.mptcpi_bytes_received - ret); if (s.last_sample.mptcpi_bytes_acked !=3D ret) - xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64, - s.last_sample.mptcpi_bytes_acked, ret2, - s.last_sample.mptcpi_bytes_acked - ret2); + xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64 + ", diff %" PRId64, + s.last_sample.mptcpi_bytes_acked, ret, + s.last_sample.mptcpi_bytes_acked - ret); } =20 close(fd); --=20 2.48.1 From nobody Wed Sep 17 16:39:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36F477494 for ; Fri, 12 Sep 2025 03:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757648418; cv=none; b=u5kbhtWDQoD90ANQrRCgtVPRayobLzxlD7Ix6OapaG04d3rz9u5I7Y9OsoD6I17xWbBzX3vxzWRFkuavQm1w/zV9h3XXHKd4BUjVWBpAp5rvoBCdIFyDSKXGiPwURV3EC+PfoPhUzJDwIa+M1xxgbHS7ojFEHiEgz/WSOoyxbCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757648418; c=relaxed/simple; bh=D8RIPRZBGOqDjp1yVASIDLiMvJLKsG3GCUReBIPbOog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IElGDjR9UFoFmm3A55yPTs8p/PBv/EmNP3DfBmwyFCX6M55tYVR5ewBCUD3daB8Hi47CpH0AUm7NgnhQkMM+70yPfrw/XiST+p9Ltt0TF26SdytlnI6NAiXMhV+MFGKg4Y57Xt/51943nhvuYodLWf5/JmeoOrSEPAx4nQm/dyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K30iOp9V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K30iOp9V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFDE7C4CEF5; Fri, 12 Sep 2025 03:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757648417; bh=D8RIPRZBGOqDjp1yVASIDLiMvJLKsG3GCUReBIPbOog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K30iOp9VI+LGQ1v3+CCEI7GtRrcnzPFRG5SHcocqaTv3dFwDWHVyOgejXqbOw+KXs RYm3X7AUZIBDTgHfq7utDjkrLimHbFhyjcyJtLj0Vo4FlL3N3G+3TPu+/StRUrCKEY GCX7BxKuAwOd6myY8HUSVAGZnmPoErkmLs7p/yOHo6Li8bmcANPASL+OknrX7gjPPY we60Tgt0VEodwgntPL01lLbAhgmTYpxe07dtoFiDlZeMokfo2k+i9qcC+G++zsEEgD deupi6D7/FJL4QNo/iqZKgPlprR6bkdbyXjErqVC+a2MswJ2MZyl3JdVaQonYPOoUW 3d4VtO4iua8Gg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang , "Matthieu Baerts (NGI0)" Subject: [PATCH mptcp-next v3 2/3] selftests: mptcp: close server file descriptors Date: Fri, 12 Sep 2025 11:40:04 +0800 Message-ID: <2be1f94bbf834ad615333af818ed499d96d81805.1757647967.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang The server file descriptor ('fd') is opened in server() but never closed. While accepted connections are properly closed in process_one_client(), the main listening socket remains open, causing a resource leak. This patch ensures the server fd is properly closed after processing clients, bringing the sockopt and inq test cases in line with proper resource cleanup practices. Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_inq.c | 1 + tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/= selftests/net/mptcp/mptcp_inq.c index f3bcaa48df8f..40f2a1b24763 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_inq.c +++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c @@ -502,6 +502,7 @@ static int server(int unixfd) =20 process_one_client(r, unixfd); =20 + close(fd); return 0; } =20 diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/test= ing/selftests/net/mptcp/mptcp_sockopt.c index 112c07c4c37a..200f0942fb67 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -726,6 +726,7 @@ static int server(int pipefd) =20 process_one_client(r, pipefd); =20 + close(fd); return 0; } =20 --=20 2.48.1 From nobody Wed Sep 17 16:39:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A64F37494 for ; Fri, 12 Sep 2025 03:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757648419; cv=none; b=bCuhQs56RkMgJWiCbVwuVDM+6057/rmwLwPJEXEWUgHMtK3Mr1fdcm7VZua2AiWGke7ElH24RubtfYuNqw1+eIIKK2u5J1R/8TIc7Bq8Hbm8Gvb66voN1tu0lE/F/ibIyPbz8Qpu2kr2HCYkMz1D5ieHDGNuZqYielt4v3uXSmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757648419; c=relaxed/simple; bh=e0gYAq+aaFLHErt15+GKOwNmGL8pidS3R8Xg1LEhsbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j8t82FwAHj4n+sEyWpWcWWiHPVh2T8BlK++uo2OTu+Y2zF/H0lANdNbMz+316AFzAb51wEFYlGGBi97Wf0ePJMdDogvlnOLdvhzTco7r3h8l2oIH47Zu6t+bnbkIpy5T/tRHJXqC3+Viwaag+MoDJ3Y7ZgCJr5sTUQKHSwUdovk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fJvH8Wzc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fJvH8Wzc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A4B5C4CEF5; Fri, 12 Sep 2025 03:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757648419; bh=e0gYAq+aaFLHErt15+GKOwNmGL8pidS3R8Xg1LEhsbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fJvH8WzcwSTISbapU/Srrd3EgZU2ZPRmIcS2I4iWHApE5fw21I5hmrdr5dS1RH4Bw sj+t+Rx57U+qVs0pztNiZGT2qHcFTMV1FZ2FgpED7dI350UHF9IQiXyyHY8DE1M2I5 4IaNnbd9PzYFcbN8jc16+WJ9sjuWhT6zokTWkhP9MDGmbUCwutOTUnyEXpA5IgLFwj Y7/J+b23D7V+Bs+D8/AgkMNl44Rr21IUlfZk0BdgcJlrTCFcS9hRSanG5+8vy6CkGb mg61K8VUquEXVV7N9XUpMyWUPbOM+yZOebAtRGXw4AbnU1MVveJ1CViy38DDuUZ8B4 ftlw3N9nsRPyQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 3/3] selftests: mptcp: close server IPC descriptors Date: Fri, 12 Sep 2025 11:40:05 +0800 Message-ID: <2727c1367577504c5a1c4fad62578d0c2b3a8f9f.1757647967.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang The client-side function connect_one_server() properly closes its IPC descriptor after use, but the server-side code in both mptcp_sockopt.c and mptcp_inq.c was missing corresponding close() calls for their IPC descriptors, leaving file descriptors open unnecessarily. This change ensures proper cleanup by: 1. Adding missing close(pipefds[0]/unixfds[0]) in server processes 2. Adding close(pipefds[1]/unixfds[1]) after server() function calls This ensures both ends of the IPC pipe are properly closed in their respective processes, preventing file descriptor leaks. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_inq.c | 8 ++++++-- tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/= selftests/net/mptcp/mptcp_inq.c index 40f2a1b24763..8e8f6441ad8b 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_inq.c +++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c @@ -581,8 +581,12 @@ int main(int argc, char *argv[]) die_perror("pipe"); =20 s =3D xfork(); - if (s =3D=3D 0) - return server(unixfds[1]); + if (s =3D=3D 0) { + close(unixfds[0]); + ret =3D server(unixfds[1]); + close(unixfds[1]); + return ret; + } =20 close(unixfds[1]); =20 diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/test= ing/selftests/net/mptcp/mptcp_sockopt.c index 200f0942fb67..286164f7246e 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -852,8 +852,12 @@ int main(int argc, char *argv[]) die_perror("pipe"); =20 s =3D xfork(); - if (s =3D=3D 0) - return server(pipefds[1]); + if (s =3D=3D 0) { + close(pipefds[0]); + ret =3D server(pipefds[1]); + close(pipefds[1]); + return ret; + } =20 close(pipefds[1]); =20 --=20 2.48.1