From nobody Tue Feb 10 15:44:49 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp607130uao; Sat, 17 Sep 2022 15:29:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lD2tJSJ5q3vVPYJzldlIZsY20OWigC/WMmblGH4thd6kjeQU/wkyaxhVyahUKHLLN5udd X-Received: by 2002:a17:90b:38c5:b0:202:98df:208c with SMTP id nn5-20020a17090b38c500b0020298df208cmr22990971pjb.129.1663453776513; Sat, 17 Sep 2022 15:29:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663453776; cv=pass; d=google.com; s=arc-20160816; b=OYHN7AFx7vPtl2ENcPw2qyjtcWU9CkYZ0TACVKHmeZKE85W3tL9R/4YrLoXqC4ic/F tnMeCxymI+ww1CPQj07X6ILu5P9V7aG8sG//nmnpADa1JRK02B2IvhWgthy4w3S5sc1D qlddtj9OMcVohZOUXSTP/hgS+8Pu4M1FNHeQ8ndte05FvzKjUs1/aNvrEZAe0H+nBWW4 uiG5JMeaFRdw6otNwLiA16cor1Ohcca3FxVOPhQnv3JWyePuUPiL6YJILTwR5FaU3in4 Ew8VVObv13btUJG55bL18dtaF3jCcZqasuPO2Wc/HqXmkJfS0gh8pyhowM/J9L6iPQf9 +wHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:date :subject:message-id:cc:to:from:dkim-signature; bh=A374qcFGZnxbZk1AlL4TUHso2FHnehXtgKDlDMolsaI=; b=T+WEuHLhrvsVzplZRlEdfwpiKEotdjLt4UcndpI+XMl5uj2vEUba6mzf24d2Ptm3UE 5KB+j9qU9rSywkRCQ7bcWVUqoGtZMmK6QfAf6xtP8Lfu2QeYDmyUMmJsl/AeRGbY/HOX IK1Z3/L/6GuLu+5ea3Gv7NFJ13twLIzRoSgJRe3wT8n5hM9XFs0yH2/ssRKeZp+SXO6h pCoLl+IkrKhwEsBD2p429Zk3p8gRYj3AoprO3EE6gJ/iC73Eme8TKKH2ti+werL5NSp8 VKbU0t2RoXFEF2WVTPwuDUETCjPbr29/OaOWpD5FxxZ4LtgQ6l1AWK5QgeXnJ68xB0iF ru2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=HuwFjOkL; arc=pass (i=1 spf=pass spfdomain=shytyi.net dkim=pass dkdomain=shytyi.net dmarc=pass fromdomain=shytyi.net>); spf=pass (google.com: domain of mptcp+bounces-6296-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6296-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j64-20020a638b43000000b0042b23090b1csi26144775pge.197.2022.09.17.15.29.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Sep 2022 15:29:36 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6296-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=HuwFjOkL; arc=pass (i=1 spf=pass spfdomain=shytyi.net dkim=pass dkdomain=shytyi.net dmarc=pass fromdomain=shytyi.net>); spf=pass (google.com: domain of mptcp+bounces-6296-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6296-wpasupplicant.patchew=gmail.com@lists.linux.dev" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A9639280CBF for ; Sat, 17 Sep 2022 22:29:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 189F85C87; Sat, 17 Sep 2022 22:29:32 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6AAE5C9B for ; Sat, 17 Sep 2022 22:29:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663453760; cv=none; d=zohomail.eu; s=zohoarc; b=CePXCIQVytVmQ9eqP9twB2xSWprKwawPnRsMUIstQZcqfGnU9fsxxPR5mBff4FAtzWUFnkosklr6Q9CeU+AEFQwcnKD3+/NTR7npD+uCcwYoF07YFZ+hmIaoiAwErj/g+yij2KM5rIdRwr5+ECdsxOM+XDsGTnhqRXDjkEKdUZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663453760; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=A374qcFGZnxbZk1AlL4TUHso2FHnehXtgKDlDMolsaI=; b=afuJAOk17ts56C30UhdyKplV1JrPWiyun2BRK13cYrXqFypiY8GDpRubFN3SFGjw9wUDILuf2T6ydP96OmNjMj+jiJH2KE2tHMa8IlCAOji9kK2RNmRviVKC4gscbiYDmcj7oK4XcYYuWD882MH+QTjHhEPBmW5M8+n92XPho+A= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=shytyi.net; spf=pass smtp.mailfrom=dmytro@shytyi.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1663453760; s=hs; d=shytyi.net; i=dmytro@shytyi.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=A374qcFGZnxbZk1AlL4TUHso2FHnehXtgKDlDMolsaI=; b=HuwFjOkL44m4Rm/pQsyzeM6/J8RV4tVPJrvZssuKmlxATV3JXqeEXa+WNz1WqcE0 rPY4qECgFfKkAtguKaFYmOLYStUsnWHiy5+b5sO7RlCWyS8F8HOQaCUoxQ/p7qtL+I/ joccEinO0ovFmmWfcXDkdon6H40fNYvYb3mgrNlI= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663453759878256.3947009535458; Sun, 18 Sep 2022 00:29:19 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220917222853.2406-12-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v7 11/11] selftests: mptfo initiator/listener Date: Sun, 18 Sep 2022 00:28:53 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220917222853.2406-1-dmytro@shytyi.net> References: <20220917222853.2406-1-dmytro@shytyi.net> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" MPTFO tests: these are examples of initiator (sendto) and listener, probably are going to be integrated to the mptcp_connect.* selftests Signed-off-by: Dmytro Shytyi --- tools/testing/selftests/net/mptcp/mptfo.sh | 13 +++ .../selftests/net/mptcp/mptfo_initiator.c | 41 ++++++++ .../selftests/net/mptcp/mptfo_listener.c | 98 +++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 tools/testing/selftests/net/mptcp/mptfo.sh create mode 100644 tools/testing/selftests/net/mptcp/mptfo_initiator.c create mode 100644 tools/testing/selftests/net/mptcp/mptfo_listener.c diff --git a/tools/testing/selftests/net/mptcp/mptfo.sh b/tools/testing/sel= ftests/net/mptcp/mptfo.sh new file mode 100644 index 000000000000..9ed0cb281094 --- /dev/null +++ b/tools/testing/selftests/net/mptcp/mptfo.sh @@ -0,0 +1,13 @@ +#!/bin/bash +#This is an example of environmen that was used to generate wireshark +sudo ip netns add server +sudo ip netns add client +sudo ip link add veth0 type veth peer name veth1 +sudo ip link set veth1 netns server +sudo ip link set veth0 netns client +sudo ip netns exec client ip a a 10.10.0.1/24 dev veth0 +sudo ip netns exec server ip a a 10.10.0.2/24 dev veth1 +sudo ip netns exec client ip link set dev veth0 up +sudo ip netns exec server ip link set dev veth1 up +sudo ip netns exec server bash -c "echo 2 > /proc/sys/net/ipv4/tcp_fastope= n" +sudo ip netns exec client bash -c "echo 1 > /proc/sys/net/ipv4/tcp_fastope= n" diff --git a/tools/testing/selftests/net/mptcp/mptfo_initiator.c b/tools/te= sting/selftests/net/mptcp/mptfo_initiator.c new file mode 100644 index 000000000000..e23b88693fb0 --- /dev/null +++ b/tools/testing/selftests/net/mptcp/mptfo_initiator.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SERVER_PORT 7003 + +int main(int argc, char *argv[]) +{ + unsigned char valsyn[3] =3D "abc"; + struct sockaddr_in daddr; + char *valend =3D "fff"; + char *val1 =3D "zz1"; + char *val2 =3D "zz2"; + char *val3 =3D "zz3"; + int sock_fd =3D -1; + int ret; + + memset(&daddr, 0, sizeof(daddr)); + inet_pton(AF_INET, "10.10.0.2", &daddr.sin_addr); + daddr.sin_family =3D AF_INET; + daddr.sin_port =3D htons(SERVER_PORT); + + sock_fd =3D socket(AF_INET, SOCK_STREAM, IPPROTO_MPTCP); + + ret =3D sendto(sock_fd, valsyn, 3, MSG_FASTOPEN, (struct sockaddr *) &dad= dr, sizeof(daddr)); + ret =3D write(sock_fd, val1, 3); + ret =3D write(sock_fd, val2, 3); + ret =3D write(sock_fd, val2, 3); + ret =3D write(sock_fd, val2, 3); + ret =3D write(sock_fd, val3, 3); + ret =3D write(sock_fd, valend, 3); + + close(sock_fd); + return EXIT_SUCCESS; +} diff --git a/tools/testing/selftests/net/mptcp/mptfo_listener.c b/tools/tes= ting/selftests/net/mptcp/mptfo_listener.c new file mode 100644 index 000000000000..7e3de8d1d08c --- /dev/null +++ b/tools/testing/selftests/net/mptcp/mptfo_listener.c @@ -0,0 +1,98 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CLIENT_QUEUE_LEN 10 +#define SERVER_PORT 7003 + +int main(void) +{ + int listen_sock_fd =3D -1, client_sock_fd =3D -1; + char str_addr[INET6_ADDRSTRLEN]; + struct sockaddr_in server_addr; + int ret, flag; + int qlen =3D 5; + char ch; + + server_addr.sin_family =3D AF_INET; + inet_pton(AF_INET, "10.10.0.2", &server_addr.sin_addr); + server_addr.sin_port =3D htons(SERVER_PORT); + + /* Create socket for listening (client requests) */ + listen_sock_fd =3D socket(AF_INET, SOCK_STREAM, IPPROTO_MPTCP); + if (listen_sock_fd =3D=3D -1) { + perror("socket()server"); + return EXIT_FAILURE; + } + + /* Set socket to reuse address */ + flag =3D 1; + ret =3D setsockopt(listen_sock_fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeo= f(flag)); + if (ret =3D=3D -1) { + perror("setsockopt()"); + return EXIT_FAILURE; + } + + ret =3D setsockopt(listen_sock_fd, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(q= len)); + if (ret =3D=3D -1) { + perror("setsockopt()TCP_FASTOPEN"); + return EXIT_FAILURE; + } + + /* Bind address and socket together */ + ret =3D bind(listen_sock_fd, (struct sockaddr *)&server_addr, sizeof(serv= er_addr)); + if (ret =3D=3D -1) { + perror("bind()"); + close(listen_sock_fd); + return EXIT_FAILURE; + } + + /* Create listening queue (client requests) */ + ret =3D listen(listen_sock_fd, CLIENT_QUEUE_LEN); + if (ret =3D=3D -1) { + perror("listen()"); + close(listen_sock_fd); + return EXIT_FAILURE; + } + perror("Server listening"); + while (1) { + /* Do TCP handshake with client */ + client_sock_fd =3D accept(listen_sock_fd, + NULL, + 0); + if (client_sock_fd =3D=3D -1) { + perror("accept()"); + close(listen_sock_fd); + return EXIT_FAILURE; + } else { + perror("ACCEPT_SUCCESS"); + } + + char rb[1024]; + + while (1) { + ret =3D read(client_sock_fd, rb, 3); + + if (ret =3D=3D -1) { + perror("SERVVERread()"); + close(client_sock_fd); + break; + } else { + fprintf(stderr, "received %c%c%c from client", rb[0], rb[1], rb[2]); + } + if (rb[0] =3D=3D 'f' && rb[1] =3D=3D 'f' && rb[2] =3D=3D 'f') { + close(client_sock_fd); + break; + } + + } + } + + return EXIT_SUCCESS; +} --=20 2.25.1