🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27155

[PATCH net-next 10/10] selftests: mptcp: print stats before socket closure

#27155
From: "Matthieu Baerts (NGI0)"
Date: Fri, 04 Dec 2026 21:44
64 lines
10323 bytes
In case of poll timeout, it might be too late to print the stats after
the socket closure.

Now, in case of poll timeout, 'ss' and 'nstat' are invoked from
mptcp_connect to print the stats before exiting. This should help
debugging poll timeout issues.

Note: for this "workaround", system() is used for debugging purposes
only. The returned result can then be safely ignored, hence the (void)!
to avoid unused-result warnings.

Also, 'nstat *Tcp*' will print '#kernel' at the top, but that's OK, and
it seems better to avoid using a pipe here.

Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 178d98d91fea..8c788977e594 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -210,6 +210,19 @@ static void xgetaddrinfo(const char *node, const char *service,
 	}
 }
 
+static void print_err_stats(void)
+{
+	char cmd[128];
+
+	snprintf(cmd, sizeof(cmd), "ss -Menitam -o '%cport = :%s' >&2",
+		 listen_mode ? 's' : 'd', cfg_port);
+
+	fprintf(stderr, "socket stats before socket closure:\n");
+	(void)!system(cmd);
+	(void)!system("NSTAT_HISTORY=\"/tmp/$(ip netns identify).nstat\" "
+		      "nstat -s '*Tcp*' >&2");
+}
+
 static void set_rcvbuf(int fd, unsigned int size)
 {
 	int err;
@@ -658,6 +671,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd,
 			fprintf(stderr, "%s: poll timed out (events: "
 				"POLLIN %u, POLLOUT %u)\n", __func__,
 				fds.events & POLLIN, fds.events & POLLOUT);
+			print_err_stats();
 			return 2;
 		}
 
@@ -1196,6 +1210,7 @@ int main_loop_s(int listensock)
 		return 1;
 	case 0:
 		fprintf(stderr, "%s: timed out\n", __func__);
+		print_err_stats();
 		close(listensock);
 		return 2;
 	}

-- 
2.55.0
Technical Details
Message-ID: <20261204-net-next-mptcp-misc-feat-7-5-v1-10-1449de51adae@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377659-linux-kernel-netdev=dewy.ru
References: <20261204-net-next-mptcp-misc-feat-7-5-v1-0-1449de51adae@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377659-linux-kernel-netdev=dewy.ru
From: matttbe@kernel.org ("Matthieu Baerts (NGI0)")
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 10/10] selftests: mptcp: print stats before socket
 closure
Date: Fri, 04 Dec 2026 22:44:42 +0100
Organization: Usenet Network
Message-ID: <20261204-net-next-mptcp-misc-feat-7-5-v1-10-1449de51adae@kernel.org>
References: <20261204-net-next-mptcp-misc-feat-7-5-v1-0-1449de51adae@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2878880"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:B7ADgYoDnCX/n4RpwcYVWNRcNZQ= sha256:T7LDT6U/kk9ZwkrhAmBUvW97zDfR7lh24mN/QuyWLMw=
	sha1:ojNZH/2gOfKSA/DKYLWfXGlw/gU= sha256:I0Cv4DvY0Xh9fqHSjAknZuMhmQeDPZs6V33lNG1EGfQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CD725117CFC; Sat,  5 Dec 2026 00:45:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 1CVBkuC_DZj3;
	Sat,  5 Dec 2026 00:45:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377659-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 4A51C117CFB; Sat,  5 Dec 2026 00:45:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id DE4843B6A5; Fri,  4 Dec 2026 21:45:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796420729;
	b=k5hQhrNq6OZWwAcjfmbPEDQ/sCzg6Xv0+q4Q3I411Vnf1KpJLvkZYmSJNrbmIikQMKsK
	 3QG5KCo/W1ERnjbGbPOAG7Z2taCKtQUKJRxnKPEh5Y5uGRdmdJpFLvzkTVnV3Ebx/doMZ
	 18bNki2LDT5oU+MbcGrc4eYauu4Im6Y6FdyKPgp+mt5SLCSPsdJYeXtvFjh44CfDEd2ne
	 8fR75hiwxnEQbL4HInUIbCCf1st511DsHtz/kbUrH/XNrpdhsYQSPLGbuWVccqG6qNu2D
	 sOt6EBRYMOvc1yQ8nWLrI0q0eH9NXPRINOI5PGKFcyCrx6bkoBjWG6KkIDE4aXEfwmw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796420729;
	h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer:X-Developer-Signature:X-Developer-Key;
	bh=cbXqO/bHIWQkS6P5R61JmnpV6B1rfcgiCdXUyDiHA6g=;
	b=yFwHNBUBUwF8zYYdvysSDg/HOkWH4Ys0KK7c+2vk8hbiqZNwZA+M4tNnMVhMwmZxl0Tn
	 kF1Y4dlZ8/UlQVnreXcIPYQEGLavFGbwGdAXHG3rlTFYoxLR+JTMAZ5JQLFIwPnsFGwRu
	 /5TzaQFtdDfHgZCWxngPXcR+EwePNeFUcRqmBJZx8smzvlaZ44ZHbM2MsygBq4lN/X1h5
	 XXS2wofCwPlU826XXZc+V7/62DG7/ydKbgAe+EEU1cFR0nFx2MDk+Rz+a3BQZCsR1o68n
	 O/bp4C6xlslLlW8ntKB/uxvsZ2GEuIuMvoxGUE4/eR8guGJTJtcPPb/mhvlmVo2RHYA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AJ0Kr7bA;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D3CC9606A33B;
	Fri,  4 Dec 2026 21:45:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AJ0Kr7bA
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796420729;
	b=bKtWssjNqrUgX7Rk0kvv65lvsPSAjkNC/YL9TGUrnSo22DS8zloEqxgimQ0uSAI3dBEt
	 br0i4rG2di1wB7C3Du7D4fj7OsCL4a5NKTRfM/PilT3THnQcaYfCcUk1Xmj3zkEZ7IVlt
	 NHM54b8OBLi9mzPjZ5oyzdXvp/mYoUxLXx3Z8qy6ijI4oVnJ4oJFhUHZ5OFyklVke0WJE
	 YejVwQHSoblG6miJnWSJhD8uW9rPuXol28rBP7WjuukYFTlAw/K8FQ2ZuZTzgx66Hpc0Y
	 BjUUo0/WGqEEIOtiVTXoSZijU4+TDaZRu0K6WXdjZEzwXcqP05w/TWY2+F3nuVN1YAg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796420729;
	h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer:X-Developer-Signature:X-Developer-Key;
	bh=cbXqO/bHIWQkS6P5R61JmnpV6B1rfcgiCdXUyDiHA6g=;
	b=F91ayEJy1tztn0yAJQlk/jK8uV1ZDK3s937FlKtU50wfCE00nPym0Ug5sjt8HOj2I4yC
	 tUXFsmFAAGZ5zukNj6eiPHOKrYcpB67BCZtKkx+0zofuxiDZJj5kuL1aoSKU4QaM+lb7U
	 JpnGn58pC5++AiljAxS/1B6hDKnD5ythGd34WMUULhRDby/xjpPbONEnu9g06u9hr4xwS
	 UBah8sRBg3BAzfzgQq1WyteiSASvfFyB3UiKlrqXGMilSFYVcMTa/ETX6X1EjsISEgAph
	 xrGNnPQUVxy0wLztPxh4dKDebZSFzvEtVPCTWQE5RErgEgCM0ErMXRe2R3loFUpb4iA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AJ0Kr7bA;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF2B5606A32C;
	Fri,  4 Dec 2026 21:45:28 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57AEC1F00A06;
	Fri,  4 Dec 2026 21:45:26 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796420728;
	bh=cbXqO/bHIWQkS6P5R61JmnpV6B1rfcgiCdXUyDiHA6g=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc;
	b=AJ0Kr7bA9zP9s/Vf73xzv99hIS9/d/rx5PRtoq4AdsoXyxi2hAUU+CbUIU7A+8nA0
	 o6wOvgnHs7C40Vn8qED4QsZDrXJ5fGM/QJFV1zbIQDqHGhR8D1MTEte/0DwkpkAhPb
	 mVTpPMqJxyRDEczooASTpM6idotKbYA9ZOMxr3ZZJzJWoCO1OZfzutcJ7DlnfDacCb
	 ZSYzKJIGzsBuJ5Qbe7i/BpgkFSDCJGDxb8duUKr1wbhbSRRZo5KJcL5Ie3C17gHryU
	 lA8tFR8Dq5dx2BC0nXxXxxQp0XTDmVibz81R21oSwbbOvL5ZeMKF93H5JIyVV4L7+5
	 jx2hW5gqqZErA==
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261204-net-next-mptcp-misc-feat-7-5-v1-0-1449de51adae@kernel.org>
X-Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, 
 linux-kselftest@vger.kernel.org, 
 "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=openpgp-sha256; l=2072; i=matttbe@kernel.org;
 h=from:subject:message-id; bh=3Sc+hVHW2Pdvr/ndTfI+CVYdrTtj/OtdTvBWLtsTb4k=;
 b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLKFTcLKOnfOD29/nMVRtS5xwabyJANnLqYfHSUb3zZ8U
 txkcD2ro5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCJeFxkZ2lY5/M2IP/PEWH1e
 n4tQeBDTHeegU5sk5j7ScvRNnxE7lZFhs8CJ4Fkbil+w/5yYv/KFe7nK12KvVM+v0/ReyLL94v7
 OBQA=
X-Developer-Key: i=matttbe@kernel.org; a=openpgp;
 fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073