[PATCH mptcp-next 11/11] selftests: mptcp: connect cleanup TFO setup

Matthieu Baerts (NGI0) posted 11 patches 1 week, 6 days ago
[PATCH mptcp-next 11/11] selftests: mptcp: connect cleanup TFO setup
Posted by Matthieu Baerts (NGI0) 1 week, 6 days ago
To the TFO, only the file descriptor is needed, the family is not.

Also, the error can be handled the same way when 'sendto()' or
'connect()' are used. Only the printed error message is different.

This avoids a bit of confusions.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 27a93a25b142..6d2eb5cf8539 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -258,7 +258,7 @@ static void set_transparent(int fd, int pf)
 	}
 }
 
-static void set_mptfo(int fd, int pf)
+static void set_mptfo(int fd)
 {
 	int qlen = 25;
 
@@ -335,7 +335,7 @@ static int sock_listen_mptcp(const char * const listenaddr,
 			set_transparent(sock, pf);
 
 		if (cfg_sockopt_types.mptfo)
-			set_mptfo(sock, pf);
+			set_mptfo(sock);
 
 		if (bind(sock, a->ai_addr, a->ai_addrlen) == 0)
 			break; /* success */
@@ -406,21 +406,18 @@ static int sock_connect_mptcp(const char * const remoteaddr,
 				*peer = a;
 				break; /* success */
 			}
+			perror("sendto()");
 		} else {
 			if (connect(sock, a->ai_addr, a->ai_addrlen) == 0) {
 				*peer = a;
 				break; /* success */
 			}
-		}
-		if (cfg_sockopt_types.mptfo) {
-			perror("sendto()");
-			close(sock);
-			sock = -1;
-		} else {
 			perror("connect()");
-			close(sock);
-			sock = -1;
 		}
+
+		/* error */
+		close(sock);
+		sock = -1;
 	}
 
 	freeaddrinfo(addr);

-- 
2.51.0
Re: [PATCH mptcp-next 11/11] selftests: mptcp: connect cleanup TFO setup
Posted by Geliang Tang 1 week, 4 days ago
Hi Matt,

Thanks for this patch.

On Fri, 2025-12-26 at 07:40 +0100, Matthieu Baerts (NGI0) wrote:
> To the TFO, only the file descriptor is needed, the family is not.
> 
> Also, the error can be handled the same way when 'sendto()' or
> 'connect()' are used. Only the printed error message is different.
> 
> This avoids a bit of confusions.
> 
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

LGTM!

    Reviewed-by: Geliang Tang <geliang@kernel.org>

-Geliang

> ---
>  tools/testing/selftests/net/mptcp/mptcp_connect.c | 17 +++++++------
> ----
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index 27a93a25b142..6d2eb5cf8539 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -258,7 +258,7 @@ static void set_transparent(int fd, int pf)
>  	}
>  }
>  
> -static void set_mptfo(int fd, int pf)
> +static void set_mptfo(int fd)
>  {
>  	int qlen = 25;
>  
> @@ -335,7 +335,7 @@ static int sock_listen_mptcp(const char * const
> listenaddr,
>  			set_transparent(sock, pf);
>  
>  		if (cfg_sockopt_types.mptfo)
> -			set_mptfo(sock, pf);
> +			set_mptfo(sock);
>  
>  		if (bind(sock, a->ai_addr, a->ai_addrlen) == 0)
>  			break; /* success */
> @@ -406,21 +406,18 @@ static int sock_connect_mptcp(const char *
> const remoteaddr,
>  				*peer = a;
>  				break; /* success */
>  			}
> +			perror("sendto()");
>  		} else {
>  			if (connect(sock, a->ai_addr, a->ai_addrlen)
> == 0) {
>  				*peer = a;
>  				break; /* success */
>  			}
> -		}
> -		if (cfg_sockopt_types.mptfo) {
> -			perror("sendto()");
> -			close(sock);
> -			sock = -1;
> -		} else {
>  			perror("connect()");
> -			close(sock);
> -			sock = -1;
>  		}
> +
> +		/* error */
> +		close(sock);
> +		sock = -1;
>  	}
>  
>  	freeaddrinfo(addr);