All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
	MPTCP Linux <mptcp@lists.linux.dev>
Subject: Re: [PATCH mptcp-next] selftests: mptcp: print stats before socket closure
Date: Fri, 14 Aug 2026 18:44:20 +0200	[thread overview]
Message-ID: <b8ac43a1-d5f1-4498-8aae-dc87c2e3b437@redhat.com> (raw)
In-Reply-To: <20260814-sft-mptcp-stats-b4-close-v1-1-2945a591be7e@kernel.org>

On 8/14/26 4:07 PM, Matthieu Baerts (NGI0) wrote:
> 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.
> 
> 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 ea4cb6c1bd5e..842c0eb99aa9 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 id).nstat' nstat -s | "
> +		      "grep Tcp >&2");

Overall LGTM. I tried something similar in the past, but the correct
redirection always fouled me. A couple of questions:
- Is the '!' operator needed?
- Can we avoid the pipe? with something alike the following:
	(void)system("NSTAT_HISTORY='/tmp/$(ip netns id).nstat' nstat -s *Tcp*
>&2");

/P


  parent reply	other threads:[~2026-08-14 16:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 14:07 [PATCH mptcp-next] selftests: mptcp: print stats before socket closure Matthieu Baerts (NGI0)
2026-08-14 14:15 ` sashiko-bot
2026-08-14 15:06   ` Matthieu Baerts
2026-08-14 15:07 ` MPTCP CI
2026-08-14 16:44 ` Paolo Abeni [this message]
2026-08-14 17:15   ` Matthieu Baerts
2026-08-17  8:10     ` Paolo Abeni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b8ac43a1-d5f1-4498-8aae-dc87c2e3b437@redhat.com \
    --to=pabeni@redhat.com \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.