mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: Cong Liu <liucong2@kylinos.cn>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH 2/3] selftests: mptcp: Fix input fd lifecycle in reconnection loop
Date: Wed, 15 Jan 2025 09:06:27 +0800	[thread overview]
Message-ID: <e6e2731a54a4b56854d4bf61bdda27dde7ea35a3.camel@kernel.org> (raw)
In-Reply-To: <20250113085228.121778-3-liucong2@kylinos.cn>

cc mptcp only.

On Mon, 2025-01-13 at 16:52 +0800, Cong Liu wrote:
> When both cfg_input and cfg_sockopt_types.mptfo are set, the input
> file
> descriptor (fd_in) is opened before the reconnection loop but closed
> within the loop. However, when mptfo is enabled, the descriptor is
> not
> reopened in the loop, causing subsequent iterations to use an invalid
> file descriptor.
> 
> Move the file open operation into the loop to ensure fd_in is always
> valid when needed, regardless of mptfo setting.
> 
> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index 31f4c5618569..4d4ea4627daa 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -1247,12 +1247,6 @@ int main_loop(void)
>  	struct addrinfo *peer;
>  	struct wstate winfo;
>  
> -	if (cfg_input && cfg_sockopt_types.mptfo) {
> -		fd_in = open(cfg_input, O_RDONLY);
> -		if (fd_in < 0)
> -			xerror("can't open %s:%d", cfg_input,
> errno);
> -	}
> -
>  	memset(&winfo, 0, sizeof(winfo));
>  	fd = sock_connect_mptcp(cfg_host, cfg_port, cfg_sock_proto,
> &peer, fd_in, &winfo);

Is this 'fd_in' here valid if the previous 'fd_in = open(cfg_input,
O_RDONLY);' is deleted?

>  	if (fd < 0)
> @@ -1270,7 +1264,7 @@ int main_loop(void)
>  	if (cfg_cmsg_types.cmsg_enabled)
>  		apply_cmsg_types(fd, &cfg_cmsg_types);
>  
> -	if (cfg_input && !cfg_sockopt_types.mptfo) {
> +	if (cfg_input) {
>  		fd_in = open(cfg_input, O_RDONLY);
>  		if (fd_in < 0)
>  			xerror("can't open %s:%d", cfg_input,
> errno);


  reply	other threads:[~2025-01-15  1:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13  8:52 [PATCH 0/3] selftests: mptcp: Fix various issues in main_loop Cong Liu
2025-01-13  8:52 ` [PATCH 1/3] selftests: mptcp: Fix incorrect file descriptor check " Cong Liu
2025-01-13  8:52 ` [PATCH 2/3] selftests: mptcp: Fix input fd lifecycle in reconnection loop Cong Liu
2025-01-15  1:06   ` Geliang Tang [this message]
2025-01-13  8:52 ` [PATCH 3/3] selftests: mptcp: Clean up resources properly in main_loop Cong Liu
2025-01-15  1:13   ` Geliang Tang
2025-01-13 16:39 ` [PATCH 0/3] selftests: mptcp: Fix various issues " MPTCP CI
2025-01-13 16:50 ` MPTCP CI
2025-01-14 18:16 ` Matthieu Baerts
2025-01-16  8:54   ` [PATCH v2] selftests: mptcp: Fix incorrect file descriptor check " Cong Liu
2025-01-16 16:29     ` Matthieu Baerts

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=e6e2731a54a4b56854d4bf61bdda27dde7ea35a3.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=liucong2@kylinos.cn \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).