selftests: mptcp: connect cleanup TFO setup
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Tue, 3 Feb 2026 18:41:30 +0000 (19:41 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Feb 2026 02:45:34 +0000 (18:45 -0800)
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.

Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260203-net-next-mptcp-misc-feat-6-20-v1-14-31ec8bfc56d1@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/mptcp_connect.c

index a74b13e..1e87757 100644 (file)
@@ -259,7 +259,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;
 
@@ -336,7 +336,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 */
@@ -407,21 +407,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);