From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704607uao; Thu, 15 Sep 2022 16:56:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vTKfuD18caW1uG+aRHk+AfdiM1oU+VcQ8KM2zRKpq7RV1/rrd1dw7GRuIvp+dKKla85Xy X-Received: by 2002:a17:902:e843:b0:178:29d3:5544 with SMTP id t3-20020a170902e84300b0017829d35544mr1973883plg.99.1663286202615; Thu, 15 Sep 2022 16:56:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286202; cv=pass; d=google.com; s=arc-20160816; b=bgP8d3/RE7tqMwXdBHkR33Pjg6WlkUwDIafIIIJvz62qQnhEgHbn7j2QRnEQh0TG5f tem7i9UGWlNeeSFXo8+fazofuctpg7IaP0cUcBNWXhv0Mw+LCh52YqySgw8AN/YPHzx+ ss9wQOSbFkU9KqzGE6cqa0vku03hJDbZyzxPdagV68q+itS5Zz2R+JzC/DB6c85FHObM L2MCWEzE4d71gTIOqWqah4TZ9DU8azvEDnmxkNd6DG28yeCYUQ67xJdBayVFLRGo4PA6 cQhLRlbZCTYL/ycb4j55lgE6CfWza9sjrbM1czViprRYyooisJCyCHoeg/mZdCLBVk5u abPA== 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=GsQyvmSGizvFF+1HgibWVVbslT+CcV6JOXOiNAGM9iQ=; b=vs69JFP/TKK+3wZc9Gpttf1zYxxXv16RQLPqiSZVgqfLJfjdKlz9pVqZQXx0ldGcG4 LEUysKdA3owhRMqdgGpPZdqQKihyweBXr+sq+itKAE9yjSTtPgT5S7QM6wbu2etI+dJz 3h0scYeDrUWI46LICLeQOD02OZwu9YiQAHDD+n/+xSvC097zOGR9ja8x0amUxNDWx7KK 2ZuTt2FKsu75QCHI+CjOyLeGTjF9qdrWvw0J+tFi4ztxjaQ6xpW562BCrUZEmhJDnMNL U5BOKGKGVibPWe+Dg6mdLq4b1eBjbpZqX8RMCAP0bMmKMP8mvQBWvkQ0ArRvh4GRGn4G 9ETw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=PLr64Pyg; 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-6284-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6284-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e22-20020a656896000000b004392e26a2f7si12374192pgt.404.2022.09.15.16.56.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6284-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=PLr64Pyg; 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-6284-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6284-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 9618C280C96 for ; Thu, 15 Sep 2022 23:56:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D83F16AB1; Thu, 15 Sep 2022 23:56:38 +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 42E1B6713 for ; Thu, 15 Sep 2022 23:56:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286185; cv=none; d=zohomail.eu; s=zohoarc; b=hqYziGTsk7NqAyeZb3bA34DPkU+ZtpjxIX7Ey8MFfVBHQqe4+VKMTdVuB0y5VKSfQIvTMyqYV2tHuiwtacB+jd6kuOu5qcmWQElOMusp5uZFvpSg9VAfyMjifH/b1iUOY3ayti5MYUsnVghTEYqSdgScn9HIxttchGQTcLPw/U0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286185; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=GsQyvmSGizvFF+1HgibWVVbslT+CcV6JOXOiNAGM9iQ=; b=e3EPfMQBxTJzMjXkSZP2P03eIlA0W63o9vZ5s9ChXbHMNpy+kboSP8PNH/6eDnbEzf1tvfzP9HdFhzmocirl5C+WkEWNIcuv9H1QZcejZxSWTLPZ8C/gy7Bsp2vWeuN8a+1ivhYBhNtbkp+P5sKuoHno2ryr/gA2UeA11vQHhm4= 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=1663286185; 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=GsQyvmSGizvFF+1HgibWVVbslT+CcV6JOXOiNAGM9iQ=; b=PLr64PygENnUwb8Fs81Sy3bLq19n2HC9jQE2sRVFnkUzemwKL08Zr9gLNfwaeWo3 o75RMrGF3juoPoWYxB7Ma71/bMRksC3w4GpolSWJPLfWI2GfdK9Q9SZyl8gjqONbH/n 65Ds2tdmFxGa+KZS/rG6FJ7CcSWtrmjlwWG1PspA= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286184155722.8943006248229; Fri, 16 Sep 2022 01:56:24 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-2-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 1/9] Add separate fastopen.c file. Date: Fri, 16 Sep 2022 01:55:56 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" Add separate *.c file. Function prototypes are coming to protocol.h (Suggestion of @palbeni (JUN 17)) Signed-off-by: Dmytro Shytyi --- net/mptcp/Makefile | 2 +- net/mptcp/fastopen.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 net/mptcp/fastopen.c diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 8a7f68efa35f..c42ad8609876 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_MPTCP) +=3D mptcp.o =20 mptcp-y :=3D protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o d= iag.o \ - mib.o pm_netlink.o sockopt.o pm_userspace.o sched.o + mib.o pm_netlink.o sockopt.o pm_userspace.o sched.o fastopen.o =20 obj-$(CONFIG_SYN_COOKIES) +=3D syncookies.o obj-$(CONFIG_INET_MPTCP_DIAG) +=3D mptcp_diag.o diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c new file mode 100644 index 000000000000..0c9ef6f5d528 --- /dev/null +++ b/net/mptcp/fastopen.c @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0 + * MPTCP Fast Open Mechanism. Copyright (c) 2021-2022, Dmytro SHYTYI + */ + +#include "protocol.h" --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704609uao; Thu, 15 Sep 2022 16:56:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SPGl7N3A0X+fxbLWG01U/YM/JTUwzlIDKo3OcijGOCC1ZeIzVfE4qoVxtKkuDakpiNbRp X-Received: by 2002:a63:5d52:0:b0:439:36bb:c07c with SMTP id o18-20020a635d52000000b0043936bbc07cmr2134533pgm.272.1663286202885; Thu, 15 Sep 2022 16:56:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286202; cv=pass; d=google.com; s=arc-20160816; b=udIOI+UbxrcjIMOts34LR32yotSwxkTvD4OPk5Y5W7OJNBQDdWa8t1CXNXCaslOH1P Cgk7eEjTki4qfOM1rZtlwKa99k585vKcZfcscpdKWFxqPjoM2DJ4vMgMxJlsJsfDM31V 40CSWhOFZDwbUefv9m3gf5y0awBJok8swP/7DWXOyxtG1AOFog7547iUHbz+vp5mJLn6 QKp1v1lfk//yDLTymVWRung4uMmmc/o2/SidMt+iBuiL4jXva1UBY+jNAM06pvAkITI8 s7GstUhWBuCiBMy3xIGT1PmhCcyrIpKYudLTFug3ULiRvSpvCK07sOr8P9Npm3+rrIX/ IotQ== 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=nJx9T7UcYHoYNb+qgpWl9AFqIl7y/SRTGdgCMh6o250=; b=ILCaaSqwySW5BYyYAK5xp4vK5zIx6nZaGi+IKg+7+ISU+5h6rp0/6VRF1DGuLA8WbK GOG6mwUYtb0lpKtA6OIOf547TdUzcqSSlF6C79nmGJPhBzlrViCSKUfHbB5D47QkrfMl 51IaLr7DkQYVJixyheGnK0gmRJFdJz1mzZe5nbOOSZFeOyyGiVEASmbfMcai0s7Zjghg JsuhM8hYGfzn0qkgK3g7SgDnhcnQB37Lwyix3E9kHFJTziiSTyGezLnl0GBh6CiIbKIv fr/X7d0tj8LkoqZHvytqPxH8Lubf8Ihp0HbMUo4kQHfdmILnxkoWIovNQsP8A7tZ0Ogg HRyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=hHGfEY8D; 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-6285-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6285-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z128-20020a633386000000b0042a330a7ca7si21485562pgz.659.2022.09.15.16.56.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6285-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=hHGfEY8D; 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-6285-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6285-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 9E38B280CA7 for ; Thu, 15 Sep 2022 23:56:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E98146AB2; Thu, 15 Sep 2022 23:56:38 +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 40E5B6712 for ; Thu, 15 Sep 2022 23:56:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286186; cv=none; d=zohomail.eu; s=zohoarc; b=XftBtHEApY6XMQLIdwqVbinzxh34JeWNwUn08qSmHwWUDOFdUUaEEZGo19V2Q3gKNJityUD/pHLSzhPT6sbupCnrvVk4lyU0bv5+UHSq0UkqaQ7kBoXyXDCjOOJ0X6JeK3AzvNjpNFUSAb3Iajq+IXOP/eRydo9agiMNWlmAIF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286186; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nJx9T7UcYHoYNb+qgpWl9AFqIl7y/SRTGdgCMh6o250=; b=b1sCPqwmrTH1YbDcmUjN0+eZ9NQ+Ild3nNc9Fjp028oYtkKMrsIDkSZ6Qq6CMt4ldm3tAYJmm1VUXLzzZflDeMi9b+SNl7OPOj8k0DBOMnVqB7a+mpwBLJR+DQjZ/zDoK7EUaa4CQBBrtlv+588fUdgcCM3mPZwPzhKWPIoql00= 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=1663286186; 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=nJx9T7UcYHoYNb+qgpWl9AFqIl7y/SRTGdgCMh6o250=; b=hHGfEY8DJT1TvwBILYLD/kpf2hHapYSrUbz8Fso2KldiMazKPv92dHzYDhYPI1aE AICvsc4cR9t8y9vaDgXlzXcACv3X8TCywulXB2Nz1UNcRUlUnxiHmDyFp/KLyNRoVCW Qvk2GRpe+CL57EDLay0tTHArLgisIjNiTfwBfp9Q= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286184373652.6967180822953; Fri, 16 Sep 2022 01:56:24 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-3-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 2/9] Initiator: MSG_FASTOPEN sendto(). request cookie Date: Fri, 16 Sep 2022 01:55:57 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" Initiator: MSG_FASTOPEN in sendto triggers the mptcp_sendsmg_fastopen. It requests a MPTFO cookie.=20 Suggestion @palbeni(JAN 17): 'split the patch in several small one'. Signed-off-by: Dmytro Shytyi --- net/mptcp/fastopen.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 4 ++-- net/mptcp/protocol.h | 6 ++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 0c9ef6f5d528..9974508e0f4c 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -3,3 +3,53 @@ */ =20 #include "protocol.h" + +int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, + size_t len, struct mptcp_sock *msk, + size_t *copied) +{ + const struct iphdr *iph; + struct ubuf_info *uarg; + struct sockaddr *uaddr; + struct sk_buff *skb; + struct tcp_sock *tp; + struct socket *ssk; + int ret; + + ssk =3D __mptcp_nmpc_socket(msk); + if (unlikely(!ssk)) + goto out_EFAULT; + skb =3D tcp_stream_alloc_skb(ssk->sk, 0, ssk->sk->sk_allocation, true); + if (unlikely(!skb)) + goto out_EFAULT; + iph =3D ip_hdr(skb); + if (unlikely(!iph)) + goto out_EFAULT; + uarg =3D msg_zerocopy_realloc(sk, len, skb_zcopy(skb)); + if (unlikely(!uarg)) + goto out_EFAULT; + uaddr =3D msg->msg_name; + + tp =3D tcp_sk(ssk->sk); + if (unlikely(!tp)) + goto out_EFAULT; + if (!tp->fastopen_req) + tp->fastopen_req =3D kzalloc(sizeof(*tp->fastopen_req), + ssk->sk->sk_allocation); + + if (unlikely(!tp->fastopen_req)) + goto out_EFAULT; + tp->fastopen_req->data =3D msg; + tp->fastopen_req->size =3D len; + tp->fastopen_req->uarg =3D uarg; + + /* requests a cookie */ + ret =3D mptcp_stream_connect(sk->sk_socket, uaddr, + msg->msg_namelen, msg->msg_flags); + if (!ret) + *copied =3D len; + return ret; +out_EFAULT: + ret =3D -EFAULT; + return ret; +} diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 55442df8fb97..6bbf1b86465d 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1672,9 +1672,9 @@ static int mptcp_sendmsg(struct sock *sk, struct msgh= dr *msg, size_t len) int ret =3D 0; long timeo; =20 - /* we don't support FASTOPEN yet */ + /* we don't fully support FASTOPEN yet */ if (msg->msg_flags & MSG_FASTOPEN) - return -EOPNOTSUPP; + ret =3D mptcp_sendmsg_fastopen(sk, msg, len, msk, &copied); =20 /* silently ignore everything else */ msg->msg_flags &=3D MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 1bc9f6e77ddd..ad51910f1cc9 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -836,6 +836,12 @@ void mptcp_event_addr_announced(const struct sock *ssk= , const struct mptcp_addr_ void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id); bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); =20 +// Fast Open Mechanism functions begin +int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, + size_t len, struct mptcp_sock *msk, + size_t *copied); +// Fast Open Mechanism functions end + static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { return READ_ONCE(msk->pm.addr_signal) & --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704586uao; Thu, 15 Sep 2022 16:56:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4XFleA2p9riYKnFRAKNEfC8ZPio10uqB04zF4QOzeperfV4FppBQ4bbkJzmbeDRDH0Nb0d X-Received: by 2002:a63:4f4f:0:b0:434:b9db:b9f with SMTP id p15-20020a634f4f000000b00434b9db0b9fmr2138420pgl.438.1663286199665; Thu, 15 Sep 2022 16:56:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286199; cv=pass; d=google.com; s=arc-20160816; b=yokiEnjuwo4GJgzaYSyigLKOiPJVmhOYRd+YLRoaIA/OOAK3JOb6VjA3oz22KQPasH +TbJW0tdoCQrIPjNnzNwVdgv4+YZ5oD7DuZNhMCY6uj3ut/ytNN0Fy31Wkha1nFvhjQN sujwYe2Ui4ikEnYvW3PzgP87Aga4FynnmkcxQV+q3gOX5U8cPm6x5tqQ/s+cjC/fVOx3 hgfZ6A4r12NTx7TT2w1bohrqdnKmGBo9sOmg30HWKcoF/yzFetOkwAi9fZwmokPwGu1D p6up21APNvVqinEZFvXELN9FQGk2IKxo6ll8Kg+lWP0mChLyZI6slk+prlOykPc29nOm G0Mw== 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=zntg//5FjP1US/NQkEPqMMv2dDieVdYUJMm6/o1css0=; b=j+pJ7r7o9QwOFxPQor/yq0PdZZuBo5+DcQIDhe/13W7/jUiqaAAk5ab+HpcGQzM7Bi F1nx0x6zIQ+JZIlzzvvc94jxj1NKN4S/obmUXx8cEkakN4pyA/AvQXzfJo48+JofEL9H ZUIhiGtF5BbYP9BCN5NpY+fA6sPOLycAv/nqtzpz5PBL/zou+4Fciv78nqlF2hyCAz/N CbdRud1nw/Wj+yg7/1iy1NrOzz+WGJv+MLlikHjNVSRee5qZxmTekya2p3+04Mv0CQ/n 4MRvd3jf68s1CnzEaLVFAClYVKxMaKB7A2K8jNzQqARBK6bMV/7nl7djCIJSxeFvcCVC jVYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=fJNdykHL; 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-6281-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6281-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f21-20020a63f755000000b0042e9fb65f7fsi19690230pgk.134.2022.09.15.16.56.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6281-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=fJNdykHL; 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-6281-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6281-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 6EC8C280C4A for ; Thu, 15 Sep 2022 23:56:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B89C671D; Thu, 15 Sep 2022 23:56:37 +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 C126D184 for ; Thu, 15 Sep 2022 23:56:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286185; cv=none; d=zohomail.eu; s=zohoarc; b=D/3Z49ObZNi6/URMHVALG5BBWkjM/5OTeMYo7UOAVbfxfUV6smoJT/ALx7unBPtcxv3NpUhSymF9gh+cLcDmKKj+y6XDykBq7/1kKoSy1phq+XYzUeSWM8DpYjqq2LEcCMCcp/TiEdwfXvrsYy32Yx+ElaU5YXFVMT933wbpDHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286185; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=zntg//5FjP1US/NQkEPqMMv2dDieVdYUJMm6/o1css0=; b=RsM2v9td7pptDOpiAeXYXGfj3enLvVlHpa+5HS1VMEuur4f2X7+griYLasLLPAIMy6YjJvzBJCeaz9O9klJ1NSYXCvsOXDSYjaDYcNM0KEx1I1eDfSwUB/XXQGAZYifBFskZ0i8McHJqMPQtQNLhKFmUyv/u1YdbF15GAJOPnr0= 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=1663286185; 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=zntg//5FjP1US/NQkEPqMMv2dDieVdYUJMm6/o1css0=; b=fJNdykHLkOEpslNslKpB024fVmV+fd0YGbFbaeoVmSwtSe/mbFjzMdDmta9wtw3X aEKHkiSSinivNfrMypzUhyB6HhaOH4SUI3z4NWvGAMNCt/RlLXhuL3XflElEKGP0b05 l+1nE9DxuO8JuvAAVSw6c/upQ8NRIbVxrJ7qTFRM= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286184587218.62465368228095; Fri, 16 Sep 2022 01:56:24 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-4-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 3/9] rfree(), rmem_uncharge() prototypes to protocol.h Date: Fri, 16 Sep 2022 01:55:58 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" These 2 functions required the mptcp_fastopen_add_skb() that is not in protocol.c. Thus we export them to *.h and reuse in fastopen.c Signed-off-by: Dmytro Shytyi --- net/mptcp/protocol.c | 4 ++-- net/mptcp/protocol.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 6bbf1b86465d..ba50aa88d5d8 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -178,7 +178,7 @@ static void __mptcp_rmem_reclaim(struct sock *sk, int a= mount) __sk_mem_reduce_allocated(sk, amount); } =20 -static void mptcp_rmem_uncharge(struct sock *sk, int size) +void mptcp_rmem_uncharge(struct sock *sk, int size) { struct mptcp_sock *msk =3D mptcp_sk(sk); int reclaimable; @@ -191,7 +191,7 @@ static void mptcp_rmem_uncharge(struct sock *sk, int si= ze) __mptcp_rmem_reclaim(sk, reclaimable); } =20 -static void mptcp_rfree(struct sk_buff *skb) +void mptcp_rfree(struct sk_buff *skb) { unsigned int len =3D skb->truesize; struct sock *sk =3D skb->sk; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index ad51910f1cc9..5cd14eacd1d6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -835,6 +835,9 @@ void mptcp_event(enum mptcp_event_type type, const stru= ct mptcp_sock *msk, void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp= _addr_info *info); void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id); bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); +int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, int = addr_len, int flags); +void mptcp_rmem_uncharge(struct sock *sk, int size); +void mptcp_rfree(struct sk_buff *skb); =20 // Fast Open Mechanism functions begin int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704590uao; Thu, 15 Sep 2022 16:56:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44z5mlekU6YzdL8ZkhUpnoPQGrlwY08BMCIUS7Iwe3RSxqc6cQBVdwjNeb2GgJajycirVD X-Received: by 2002:a05:6a00:1253:b0:546:3d50:3284 with SMTP id u19-20020a056a00125300b005463d503284mr1985691pfi.72.1663286200482; Thu, 15 Sep 2022 16:56:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286200; cv=pass; d=google.com; s=arc-20160816; b=c2M44zLCOIdioYZUm6BsXTpgFgHPV8n91pZ5dusbz8Uzw8+vRUCMSfDsMK1dGvJaUE ITaJLwYrYtEg+KebiZxIq/EtwdHavM5iDieck2Dp2YPcZmDT1ylT0qzzha1mFz1QmSrz 6cbl9Qjk1C/OrAJVGDBtTZWD/N0YXJfQaR5X/jtjL9LXrmOtQ3f6FYKX5zlsc41pUc2p D0DnyJVXs0cvg84eeeY3E1ka5zZFoIGBhsjLzK06QlRSbtudOCzn8L+aYwfsm45l35Nc kC3LURPN5eY31PHPRZoHLPxQMx6V9RF0ygqaBcGobky5NCe5GwPInVYilmMQnKWfzGTK TRMA== 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=2N3o6l/q6D7RtZEz3bpDPeMZps8KZHlbykcetGxgfdk=; b=n9AnQ9YZZBsNFJnc0aW+E/eigEfNWG+dG+cMr8yxfIxw3zsULEtlh7GKdhqHIbX7qS P+yOHNMkKAMmGfZOvkLLdD+qWo9o7F1/H/UOJo75E84QPkN3X+S4bBMgdJocQrE5zPS4 BbCCj8uevBzSaNHnbTrIKmmEwP7IsuSZjKKIvkXIx+kaCl3wCIgbvkAznZbFkZLHiHdb nfH/YVR3zDHo566OXDtmLf+NwEp/s5JR4AiJ2tdb5yrul6PlwBWRLX7u66jbdIUfKF9s z20sHOdcUVYEcpjaBjNg6li4e1u185sXo7vYE8GEeaaLPsozRAylN8buQ4Y5KmNwZZNQ uPdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=BPZHPiFa; 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-6282-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6282-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u12-20020a170902b28c00b00174903c4bf9si1887037plr.72.2022.09.15.16.56.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:40 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6282-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=BPZHPiFa; 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-6282-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6282-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 9C2B2280C6C for ; Thu, 15 Sep 2022 23:56:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F5086AAE; Thu, 15 Sep 2022 23:56:38 +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 C339F670B for ; Thu, 15 Sep 2022 23:56:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286186; cv=none; d=zohomail.eu; s=zohoarc; b=TMBLy+IgH3EcB4iOIjCVjxPHnkWgN+SiXo3CGmDSIdn21L9WbguaDZd1rZiDPL76hgwpgeRPXBsTE9sAmk5NJRpc/2jYArQrZxQKRIifNLfJnb1KyLvQJVhkvYG5ncL7z5rAouYeKAwgB9+LD/uO/K7SoEZ3VAxvNFvbJScLfSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286186; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2N3o6l/q6D7RtZEz3bpDPeMZps8KZHlbykcetGxgfdk=; b=Vd+0x8+LCW5xARd8VpC/I5K48zFsgBtwTLps/xE9kcwTPTO+TSKgmCVfgn+ncLgfRSmScByZLvzrrC/m1LMPD7Jdv6M3wUnehyeUhTNmZ0s846fr+BOPgRdXlLOWyiY8lWrpWccG9rMMb5RGorP1XIyYQ34M9namRp9B7e91jFw= 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=1663286186; 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=2N3o6l/q6D7RtZEz3bpDPeMZps8KZHlbykcetGxgfdk=; b=BPZHPiFaifAVr+ny5TTlmIAwSELjN3AJQjSa/P1QUwwtOCgs+QJN1F5/+3Nn2cml 6NFd0ALdN4uoRyH4X/RowKrmbUe5cPD+Bo4XhIlMMSPviJYu9fELosya+wHkuUBkwWW B0tYvsND/CQ0Sd1VcPxLGvtlkzQjWmWGCmnUB4AA= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286184801578.0101048230161; Fri, 16 Sep 2022 01:56:24 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-5-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 4/9] Initiator: add locks() to mptcp_sendmsg_fastopen. Date: Fri, 16 Sep 2022 01:55:59 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" Suggestion of @mmartineau : 'add locks' is implemented in this patch=20 Signed-off-by: Dmytro Shytyi --- net/mptcp/fastopen.c | 42 ++++++++++++++++++++++++++++++++++++++++-- net/mptcp/protocol.c | 4 ++-- net/mptcp/protocol.h | 5 +++++ net/mptcp/sockopt.c | 3 +++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 9974508e0f4c..436e773d798a 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -16,6 +16,7 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr= *msg, struct socket *ssk; int ret; =20 + lock_sock((struct sock *)msk); ssk =3D __mptcp_nmpc_socket(msk); if (unlikely(!ssk)) goto out_EFAULT; @@ -30,26 +31,63 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msgh= dr *msg, goto out_EFAULT; uaddr =3D msg->msg_name; =20 + lock_sock(ssk->sk); + tp =3D tcp_sk(ssk->sk); if (unlikely(!tp)) - goto out_EFAULT; + goto out_lock_EFAULT; if (!tp->fastopen_req) tp->fastopen_req =3D kzalloc(sizeof(*tp->fastopen_req), ssk->sk->sk_allocation); =20 if (unlikely(!tp->fastopen_req)) - goto out_EFAULT; + goto out_lock_EFAULT; tp->fastopen_req->data =3D msg; tp->fastopen_req->size =3D len; tp->fastopen_req->uarg =3D uarg; =20 + release_sock(ssk->sk); + release_sock((struct sock *)msk); + /* requests a cookie */ ret =3D mptcp_stream_connect(sk->sk_socket, uaddr, msg->msg_namelen, msg->msg_flags); if (!ret) *copied =3D len; return ret; + +out_lock_EFAULT: + release_sock(ssk->sk); out_EFAULT: + release_sock((struct sock *)msk); ret =3D -EFAULT; return ret; } + +int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t op= tval, + unsigned int optlen) +{ + struct sock *sk =3D (struct sock *)msk; + struct net *net =3D sock_net(sk); + int val; + int ret; + + ret =3D 0; + + if (copy_from_sockptr(&val, optval, sizeof(val))) + return -EFAULT; + + lock_sock(sk); + + if (val >=3D 0 && ((1 << sk->sk_state) & (TCPF_CLOSE | + TCPF_LISTEN))) { + tcp_fastopen_init_key_once(net); + fastopen_queue_tune(sk, val); + } else { + ret =3D -EINVAL; + } + + release_sock(sk); + + return ret; +} diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index ba50aa88d5d8..357767a84c57 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3474,8 +3474,8 @@ static void mptcp_subflow_early_fallback(struct mptcp= _sock *msk, __mptcp_do_fallback(msk); } =20 -static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uadd= r, - int addr_len, int flags) +int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, + int addr_len, int flags) { struct mptcp_sock *msk =3D mptcp_sk(sock->sk); struct mptcp_subflow_context *subflow; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 5cd14eacd1d6..2a4b6dfb6f8f 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -838,11 +838,16 @@ bool mptcp_userspace_pm_active(const struct mptcp_soc= k *msk); int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, int = addr_len, int flags); void mptcp_rmem_uncharge(struct sock *sk, int size); void mptcp_rfree(struct sk_buff *skb); +int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, int = addr_len, int flags); +void mptcp_rmem_uncharge(struct sock *sk, int size); +void mptcp_rfree(struct sk_buff *skb); =20 // Fast Open Mechanism functions begin int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, size_t len, struct mptcp_sock *msk, size_t *copied); +int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t op= tval, + unsigned int optlen); // Fast Open Mechanism functions end =20 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 423d3826ca1e..f62f0d63b8e6 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -559,6 +559,7 @@ static bool mptcp_supported_sockopt(int level, int optn= ame) case TCP_NOTSENT_LOWAT: case TCP_TX_DELAY: case TCP_INQ: + case TCP_FASTOPEN: return true; } =20 @@ -796,6 +797,8 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *= msk, int optname, return mptcp_setsockopt_sol_tcp_nodelay(msk, optval, optlen); case TCP_DEFER_ACCEPT: return mptcp_setsockopt_sol_tcp_defer(msk, optval, optlen); + case TCP_FASTOPEN: + return mptcp_setsockopt_sol_tcp_fastopen(msk, optval, optlen); } =20 return -EOPNOTSUPP; --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704627uao; Thu, 15 Sep 2022 16:56:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rfeymvBVJfCMqjahBOpamj3u+TWx1a8m6o8V8l8/nh7MymV/eO6vI/cnMZCB+to1k4HJG X-Received: by 2002:a05:620a:c9b:b0:6cb:cde2:27b5 with SMTP id q27-20020a05620a0c9b00b006cbcde227b5mr2096861qki.293.1663286205198; Thu, 15 Sep 2022 16:56:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286205; cv=pass; d=google.com; s=arc-20160816; b=w4FfEtGapzX8j6gK7ZsIRlJg2JhmhFSvRu2769s+afp0cMCQCOebTHjZHHFp70mdHi KPvalQYWskoDc9qThpML/sxlt2MohWbgI71Gs38hKq796Fh+mfDrRCCRxQnsJkPSulDz fRmdwEDUaWb5aYXGeZjX7fiNTjkkvvGkDrkmT/cofh+7wJqogQFDNNOHbFqoIPdn5EfB MM9saUPG/8Rzg1eCC+saEb2QEr1fuS90Ag4G2nLBNvWFWS4jFGeVglbp+lnK4dIpLQJ4 99QxuknLL33MOGx84IFkeOzCvB4QsFGeH52CrjyUoO2D6XdhYtcTXyJbxsrddmIJ/AGf wNPQ== 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=Mp/yDBj06jP76eco8LmFyPLhjSEIxCkX+ZUDyJXkFLM=; b=k86Q4CL9O3seoPtQ0ZI9f/ECY4kEm9pu429SGv+3SqKcdDBbzH4lHXna62XD72mrhg HG7D6umbDcDYN028B0s4ApeaE8FGnMgzeMktm00FcWYmntn0mxiF3AzVGvkhu/Z+AhFz r9+RmsXFgYJulLOSvVxcQEHrQcKu1P0eTWUxWBEGY9p2MBl7OytokxNz7C9DvvX8MF9+ a6/93QqYjnvs1OvE6PDfNhj3mqARuFhBC2xqrYznPBuPbD4PoBv54I1x2/x1gX6TOSha dHe7e6PYk2Va0HKDpdmtMGrJJSh3XrLTOEr2MvRrz/RX+9rhPth4wIR70BqPuiYI2bIo opZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=LhjBC5rm; 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-6287-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6287-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j15-20020a05620a410f00b006bb54c81cc3si4293523qko.684.2022.09.15.16.56.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:45 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6287-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=LhjBC5rm; 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-6287-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6287-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 106FF1C20998 for ; Thu, 15 Sep 2022 23:56:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D87136AB4; Thu, 15 Sep 2022 23:56:39 +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 D07496AA9 for ; Thu, 15 Sep 2022 23:56:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286187; cv=none; d=zohomail.eu; s=zohoarc; b=b5DPWH8Pk4o97unsALMrFFJnp2S873dzVfklAm0q3ZdBvkhCnWX4L3pUQAi3UvCkoizwSnbls5vpMow0t+kMslaPWGFQ5NE+SwvJ2d0RJMmyMr2P9VnS35oGDJQlcqRuMiWFY/in/ljm5dbe1BTDUuTI5HooVekVBIoXVy+WyQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286187; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Mp/yDBj06jP76eco8LmFyPLhjSEIxCkX+ZUDyJXkFLM=; b=g8nsrjWk82yHcUFyZoVVSpKUQIl7X2OhSZ/inVtlx/hYUrDSkhXgvslqilQytsoZBdNrCgcqlmUGc0hCjc8/ibSFh6emh3EBJe8soT9bY2WKhuR23Oz8FsKYu+x65Uyypm+/CN7COpRED9dOxLMTDyb6kK0Ns6cmNvqrU3xpV5A= 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=1663286187; 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=Mp/yDBj06jP76eco8LmFyPLhjSEIxCkX+ZUDyJXkFLM=; b=LhjBC5rm7HbOvETJAn2dj7ZzAJ7kVng2nCnEsjPt2nmMdjM3QpKUNR4QWxVOWrjm 3dMhB1EuaNUGQ40rpo+qwLPiLSQjQ3DgleHB9aBCUpMUztOcO27/xa0NN8dJmtpLAUd RsIogrzcjNEFfIQANGH5ErYDhntsUOJ7LQkJNhSk= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 166328618501544.71671186897254; Fri, 16 Sep 2022 01:56:25 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-6-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 5/9] Fix unxpctd val of subflow->map_seq(dscrd packet) Date: Fri, 16 Sep 2022 01:56:00 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" This fixes the unexpected value of subflow->map_seq for the=20 second packet that leads to packet discard and further=20 retransmit. Signed-off-by: Dmytro Shytyi --- net/mptcp/subflow.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index c7d49fb6e7bd..075c61d1d37f 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1077,8 +1077,10 @@ static enum mapping_status get_mapping_status(struct= sock *ssk, /* will validate the next map after consuming the current one */ goto validate_csum; } - - subflow->map_seq =3D map_seq; + if (msk->is_mptfo) + subflow->map_seq =3D READ_ONCE(msk->ack_seq); + else + subflow->map_seq =3D map_seq; subflow->map_subflow_seq =3D mpext->subflow_seq; subflow->map_data_len =3D data_len; subflow->map_valid =3D 1; --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704617uao; Thu, 15 Sep 2022 16:56:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fYnyS/zZvtIyeFd1HrU4xZO1QX4cT70Z7d46q52+W8VyjcMrU9jwig2ptdv0jeSKmvcHz X-Received: by 2002:ac8:7e84:0:b0:35b:a902:57c3 with SMTP id w4-20020ac87e84000000b0035ba90257c3mr2245058qtj.37.1663286204142; Thu, 15 Sep 2022 16:56:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286204; cv=pass; d=google.com; s=arc-20160816; b=VqkWoQakXVYf/Onsw/UIvcxH7oWr2BNnuybiDflBzKYqt/leonDgJqdiU7CRwsi2ly UDw3sLI0sBYb1pWC7kpGhpRDdsdlGF5YMRZ1eE9YNK3jFSFynWyseXGpwjvWX3DEBEVm n5wg8kZN1HSg8mxBHj2c+f0jHS8RMt2bDYtZdZlf0ZmDEWt7MtXxc/lNHDJRMh62l/1e MpKvn8S9y302DeQHzoUZFz9ILtlEZCR4ll17A2YBYYTvf4OMhOi6Rq52MfvoUv82sJI6 0ZrkugaOwm2nrSHz3MLldRUvo9aeCQWC6W9SJu4phnD1IMRYijdzwG2ljMTxRg6hPtC7 /e4A== 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=BffKtKL+iY7yu11hLHREQ3MEbrwGh7lMWG68utuU7Gw=; b=OjzLuaD+VRHkYtpJ89t7JqgpQqYCBold8feVQBqqsge+VGfrg7A7BNFcPW9n9UjpTg xZGrISWQj48X+d4R4wg9o3SQtqQc4wmC1O4pgvSvTNcBhFVpKH6d5bt6TyZGRuY6vtpN JDLdM3jXRAKq0BWYcFnWBdfhOgag4fhwFtwC+D4+4unkWfUvHBWbvcB57dEKPi2FIhtb zNyPoxxTdfxi0tAehjKrLm7GRvqOpAqHzrduvdbxdHM4dN9WLJNzoHUGQdF01RHcmQYg 1p8ECQD6Pe8FWlwjuGzwGU3zhSOCTuKjBDoijq1cdFTl6HhbwNBEKlxWoPykcHUUiaxv ys4Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=RraBTiCs; 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-6286-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6286-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c4-20020a05620a268400b006c08f90ef2bsi4318492qkp.401.2022.09.15.16.56.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6286-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=RraBTiCs; 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-6286-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6286-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F30341C20993 for ; Thu, 15 Sep 2022 23:56:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7DFA6AB3; Thu, 15 Sep 2022 23:56:39 +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 346C86718 for ; Thu, 15 Sep 2022 23:56:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286188; cv=none; d=zohomail.eu; s=zohoarc; b=NoWX8/03wXgQKm9h8Oc1hNclai9zNlZFk5cRtV51TDMYldEskezRHtJsSuTTajudKfIvoWv3ANi7TmS7WUsokNO1gStK80btFgipz26aDmMD17W1r3yqIR3BEfFFwBZbQr9EQ/e0lCim4v9Y4EPrFfMhe+GziSNXeoPxGecBDVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286188; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BffKtKL+iY7yu11hLHREQ3MEbrwGh7lMWG68utuU7Gw=; b=KGLEfn/EZEPhGRmwKSLyyfURIcJ+MwHVp8ZIdVpkfeUNmehv7plPp9j0zMR0fP+BXWlXIXYYvjWXaGZv0ct8Dyerf12rdf0CMWoBdxT/vbXhRmEdCWNMZ7xc+f1C5mz/whF5Ekb6hKv6FbLDJaMl+NGhJay6B+B+z9Vf/tlvrtw= 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=1663286188; 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=BffKtKL+iY7yu11hLHREQ3MEbrwGh7lMWG68utuU7Gw=; b=RraBTiCs+dea2ZL3I69nVkVfFrL0DJ4LlLtUTF7NYd0aVTv9TjgG/H5r6pTU8pxs T46oy4aRtOoHewB15/1EoEzxOjOlYNiLbxOGhKBXVuDi5YnZ4BtlXFqye6CpG33fUzq /fO10HS3bIR3oL2XA9x6JUa4VhMuC4D+RqlrBcSs= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286185231612.162719830736; Fri, 16 Sep 2022 01:56:25 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-7-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 6/9] mptfo variables for msk, options. Fix loop retrans Date: Fri, 16 Sep 2022 01:56:01 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" Introduce mptfo variables for msk and options.=20 Also fixe the infinite retransmissions in the end of second session.=20 Suggestion @palbeni (SEP 1) during the meting to 'look at data_ack' Signed-off-by: Dmytro Shytyi --- net/mptcp/fastopen.c | 16 ++++++++++++++++ net/mptcp/options.c | 3 +++ net/mptcp/protocol.h | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 436e773d798a..149a4b1d3dac 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -91,3 +91,19 @@ int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock = *msk, sockptr_t optval, =20 return ret; } + +void mptcp_treat_hshake_ack_fastopen(struct mptcp_sock *msk, struct mptcp_= subflow_context *subflow, + struct mptcp_options_received mp_opt) +{ + u64 ack_seq; + + if (mp_opt.suboptions & OPTIONS_MPTCP_MPC && mp_opt.is_mptfo && msk->is_m= ptfo) { + msk->can_ack =3D true; + msk->remote_key =3D mp_opt.sndr_key; + mptcp_crypto_key_sha(msk->remote_key, NULL, &ack_seq); + ack_seq++; + WRITE_ONCE(msk->ack_seq, ack_seq); + pr_debug("ack_seq=3D%llu sndr_key=3D%llu", msk->ack_seq, mp_opt.sndr_key= ); + atomic64_set(&msk->rcv_wnd_sent, ack_seq); + } +} diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 30d289044e71..185b069e57f4 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -91,6 +91,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr +=3D 8; } if (opsize >=3D TCPOLEN_MPTCP_MPC_ACK) { + mp_opt->is_mptfo =3D 1; mp_opt->rcvr_key =3D get_unaligned_be64(ptr); ptr +=3D 8; } @@ -1124,6 +1125,8 @@ bool mptcp_incoming_options(struct sock *sk, struct s= k_buff *skb) return sk->sk_state !=3D TCP_CLOSE; =20 if (unlikely(mp_opt.suboptions !=3D OPTION_MPTCP_DSS)) { + mptcp_treat_hshake_ack_fastopen(msk, subflow, mp_opt); + if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) && msk->local_key =3D=3D mp_opt.rcvr_key) { WRITE_ONCE(msk->rcv_fastclose, true); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 2a4b6dfb6f8f..c364616c2d56 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -155,7 +155,8 @@ struct mptcp_options_received { echo:1, backup:1, deny_join_id0:1, - __unused:2; + is_mptfo:1, + __unused:1; u8 join_id; u64 thmac; u8 hmac[MPTCPOPT_HMAC_LEN]; @@ -282,6 +283,7 @@ struct mptcp_sock { bool use_64bit_ack; /* Set when we received a 64-bit DSN */ bool csum_enabled; bool allow_infinite_fallback; + bool is_mptfo; u8 mpc_endpoint_id; u8 recvmsg_inq:1, cork:1, @@ -848,6 +850,8 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msgh= dr *msg, size_t *copied); int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t op= tval, unsigned int optlen); +void mptcp_treat_hshake_ack_fastopen(struct mptcp_sock *msk, struct mptcp_= subflow_context *subflow, + struct mptcp_options_received mp_opt); // Fast Open Mechanism functions end =20 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704644uao; Thu, 15 Sep 2022 16:56:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5O43LrfGwJoMmYrt1rG1HDYZDHpl+/ZJbocM82m1n7fVGjOotDjrC/OvS36fGku+6BFO+U X-Received: by 2002:a17:902:9007:b0:176:9f9d:463 with SMTP id a7-20020a170902900700b001769f9d0463mr1947929plp.32.1663286208025; Thu, 15 Sep 2022 16:56:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286208; cv=pass; d=google.com; s=arc-20160816; b=PxIWheiNsmgqMLls7zX2yzYFJrNtXqf1cQFTcMG4tasz7sZHiY3Bq5jvDt23snaw82 2nlMq0R22tm9lrZEO0k6PuH0bnB8/Xc4CPsRllGc1HuSdDmZaKkAjtb5vGDbmidHcLga tbuf853LEfHA67KxqHByXawzptuH0PG/54Jv9Fu8O12gV8lRjE/9tLfVFPqKFiVCU599 vAHnfSIqp5FvEm6b2xfVd+e0mWqlPYqn+tTYYbXGMDI7mFyajd3QLhLA1ZGHIzRydWh+ jk8i1P3klLPI2aP4+6M5ZAbOo9GyOgROG9DHiSED8vo1RryZNCmyL0LrM3/EU0F2ueNy wRew== 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=2/14IFbo3tjcxNiL9UtorWiaWMb2qFnUucq3XpD0JG0=; b=s4IcgkhJfj2RhbzC8D5x/5JWr0zWqeFzFZyqi+QHXiPOzuIEVm+1t1faPAIWV0r9Ze BYluq5aFqdavdgNOkmnpyLAdFb58Py4QTD6ZkKZkpcwgj7b7+r5Rgzs0ORuhaIYwK6vp 0rWMT0djt7yd6p5J9ELuZlZ8+r2KG8z8YTVTqyN/oEO6l2iJo+qHLR+5MJ/oTUSoEHP9 e9cVmUfGz2VVEpLzgv8F1ffNEojGIr+gthbWE6wm981Op+A+9GIVFw7plVOutMf9pED6 ElAovbcLnBVcgffrYz4JjfF7r8RWrH3o/Mqpm6IbrueYq+6uuzEFqaAi6Fqz0JmCxpIO H2fQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=T5C7d0Cu; 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-6289-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6289-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l2-20020a170903244200b00172bb36712fsi22805206pls.514.2022.09.15.16.56.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6289-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=T5C7d0Cu; 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-6289-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-6289-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 1C56B280C77 for ; Thu, 15 Sep 2022 23:56:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E56E6AAA; Thu, 15 Sep 2022 23:56:40 +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 4B9B06AA5 for ; Thu, 15 Sep 2022 23:56:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286187; cv=none; d=zohomail.eu; s=zohoarc; b=YIxnShrQYBJ+/qGtV8NQxYXRkMVqymdfe0D4EzLG25j5jUF3hxtREtQotmVtlg3s6vdsPsy3W5I18T6W1QyZXvWtQyXezl0M3WcnmzV/A7X0sAIJZf0yHztdY3qhV0QPFDEhpQSkdXHgtIdP/JC+1KojNpOxd4iIK2w0GT3yfJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286187; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2/14IFbo3tjcxNiL9UtorWiaWMb2qFnUucq3XpD0JG0=; b=G+BZu6GZwgQsJ5XlMT5SpLJHG8F5Ce0rrrloqdYp0dwE4bbRPn07txNaMOZQKygUMQQRgVGba5lbhKAk14BZWFA6srY88XwQ75r5MWf7Y9Tl+UwhaTgD0seXBXS8CkJb97BfVc+RAq33nLEJH6dhVoqVp5hHOXH2+1+qQNpbmAE= 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=1663286187; 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=2/14IFbo3tjcxNiL9UtorWiaWMb2qFnUucq3XpD0JG0=; b=T5C7d0CuhEP1n85ZlvFXUWvmHznzK7jOmcZlZ6dDnFsR+1jjwbEzwS2zhxYV3brS zxwuteYCmkD8Wc3beRqeub39roC3DoFMqMU1BgB8NaDD6ZB+xGIIKvqaIxK2tcaTzpt A89vPkj5IFnudLvyF6HfSRmsHFK43vNekKWQE1i4= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 166328618544369.14989025115233; Fri, 16 Sep 2022 01:56:25 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-8-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 7/9] Listener: Add received skb to msk Date: Fri, 16 Sep 2022 01:56:02 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" Add the received skb on the listener side to msk and set flag mptfo to 1=20 to treat some parts only in MPTFO case.=20 This function is called from the functions presented in the one of the=20 patch of this serie (mptcp_add_skb helpers). Signed-off-by: Dmytro Shytyi --- net/mptcp/fastopen.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 43 +++++++++++++++++++++++++++++ net/mptcp/subflow.c | 2 +- 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 149a4b1d3dac..7070d2a966c9 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -107,3 +107,68 @@ void mptcp_treat_hshake_ack_fastopen(struct mptcp_sock= *msk, struct mptcp_subflo atomic64_set(&msk->rcv_wnd_sent, ack_seq); } } + +void mptcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb, struct r= equest_sock *req) +{ + struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(sk); + struct tcp_request_sock *tcp_r_sock =3D tcp_rsk(req); + struct sock *socket =3D mptcp_subflow_ctx(sk)->conn; + struct mptcp_sock *msk =3D mptcp_sk(socket); + struct tcp_sock *tp =3D tcp_sk(sk); + + if (TCP_SKB_CB(skb)->end_seq =3D=3D tp->rcv_nxt) + return; + + skb =3D skb_clone(skb, GFP_ATOMIC); + if (!skb) + return; + + skb_dst_drop(skb); + + tp->segs_in =3D 0; + tcp_segs_in(tp, skb); + __skb_pull(skb, tcp_hdrlen(skb)); + sk_forced_mem_schedule(sk, skb->truesize); + + TCP_SKB_CB(skb)->seq++; + TCP_SKB_CB(skb)->tcp_flags &=3D ~TCPHDR_SYN; + + tp->rcv_nxt =3D TCP_SKB_CB(skb)->end_seq; + + msk->is_mptfo =3D 1; + + //Solves: WARNING: at 704 _mptcp_move_skbs_from_subflow+0x5d0/0x651 + tp->copied_seq +=3D tp->rcv_nxt - tcp_r_sock->rcv_isn - 1; + + TCP_SKB_CB(skb)->seq +=3D tp->rcv_nxt - tcp_r_sock->rcv_isn - 1; + TCP_SKB_CB(skb)->end_seq =3D TCP_SKB_CB(skb)->seq; + + TCP_SKB_CB(skb)->seq +=3D tp->rcv_nxt - tcp_r_sock->rcv_isn - 1; + TCP_SKB_CB(skb)->end_seq =3D TCP_SKB_CB(skb)->seq; + + subflow->map_seq =3D mptcp_subflow_get_mapped_dsn(subflow); + + //Solves: BAD mapping: ssn=3D0 map_seq=3D1 map_data_len=3D3 + subflow->ssn_offset =3D tp->copied_seq - 1; + + skb_ext_reset(skb); + + //mptcp_set_owner_r begin + skb_orphan(skb); + skb->sk =3D socket; + skb->destructor =3D mptcp_rfree; + atomic_add(skb->truesize, &socket->sk_rmem_alloc); + msk->rmem_fwd_alloc -=3D skb->truesize; + //mptcp_set owner_r end + + __skb_queue_tail(&msk->receive_queue, skb); + + atomic64_set(&msk->rcv_wnd_sent, mptcp_subflow_get_mapped_dsn(subflow)); + + tp->syn_data_acked =3D 1; + + tp->bytes_received =3D skb->len; + + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) + tcp_fin(sk); +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c364616c2d56..815d1bc6c6f2 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -852,6 +852,49 @@ int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_soc= k *msk, sockptr_t optval, unsigned int optlen); void mptcp_treat_hshake_ack_fastopen(struct mptcp_sock *msk, struct mptcp_= subflow_context *subflow, struct mptcp_options_received mp_opt); +void mptcp_treat_3d_ack_fastopen(struct mptcp_sock *msk, struct mptcp_subf= low_context *subflow, + struct mptcp_options_received mp_opt); +void mptcp_treat_3d_ack_fastopen(struct mptcp_sock *msk, struct mptcp_subf= low_context *subflow, + struct mptcp_options_received mp_opt); +void mptcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb, + struct request_sock *req); +void mptcp_reqsk_record_syn(const struct sock *sk, + struct request_sock *req, + const struct sk_buff *skb); +void mptcp_ecn_create_request(struct request_sock *req, + const struct sk_buff *skb, + const struct sock *listen_sk, + const struct dst_entry *dst); +void mptcp_openreq_init(struct request_sock *req, + const struct tcp_options_received *rx_opt, + struct sk_buff *skb, const struct sock *sk); +struct sock *mptcp_fastopen_create_child(struct sock *sk, + struct sk_buff *skb, + struct request_sock *req); +bool mptcp_fastopen_queue_check(struct sock *sk); +bool mptcp_fastopen_cookie_gen_cipher(struct request_sock *req, + struct sk_buff *syn, + const siphash_key_t *key, + struct tcp_fastopen_cookie *foc); +void mptcp_fastopen_cookie_gen(struct sock *sk, + struct request_sock *req, + struct sk_buff *syn, + struct tcp_fastopen_cookie *foc); +int mptcp_fastopen_cookie_gen_check(struct sock *sk, + struct request_sock *req, + struct sk_buff *syn, + struct tcp_fastopen_cookie *orig, + struct tcp_fastopen_cookie *valid_foc); +bool mptcp_fastopen_no_cookie(const struct sock *sk, + const struct dst_entry *dst, + int flag); +struct sock *mptcp_try_fastopen(struct sock *sk, struct sk_buff *skb, + struct request_sock *req, + struct tcp_fastopen_cookie *foc, + const struct dst_entry *dst); +int mptcp_conn_request(struct request_sock_ops *rsk_ops, + const struct tcp_request_sock_ops *af_ops, + struct sock *sk, struct sk_buff *skb); // Fast Open Mechanism functions end =20 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 075c61d1d37f..ff5fe4ff3d21 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -542,7 +542,7 @@ static int subflow_v4_conn_request(struct sock *sk, str= uct sk_buff *skb) if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) goto drop; =20 - return tcp_conn_request(&mptcp_subflow_request_sock_ops, + return mptcp_conn_request(&mptcp_subflow_request_sock_ops, &subflow_request_sock_ipv4_ops, sk, skb); drop: --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704650uao; Thu, 15 Sep 2022 16:56:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gbp9WMwNFv/0e9s+6Lg31SZZ6qZZFQj2BcUgZpPwaX5jRnGt/YtWsi6nQc8cM/vSa+L56 X-Received: by 2002:a05:6a00:84d:b0:542:4254:17ef with SMTP id q13-20020a056a00084d00b00542425417efmr2527201pfk.31.1663286208407; Thu, 15 Sep 2022 16:56:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286208; cv=pass; d=google.com; s=arc-20160816; b=Uyt+Hyc6NiPSKG/wgA9pppz5wxSWFLFgUzhoxUc5x2s6ntYUxukMI01YVxaX487gq+ sGlLyf/yALOpv4QiLU+4mEggFrgJar4kXQ1gBsPCwVnZitAbzzN5vwTvptFnsoENtnVh K5N6gwV8wzXA5UORlb6kFzaGm7Ez9c6Z1dv284AILiwOVC0VSRxxKpkWdOTea8uBjrLc cz9mgTfdRCJ06j9kC5Sxk6Sg5dU8HFHeVM51B9JcLmsIkxZCBkB5nXyaJaA1UGtsxO+a 8zog55WkR6HLU2DtOLz63k57W/P6fU/ZDsX5JNCtFTzGppMsuUGhk9wN12vA/nzMKzYA kqog== 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=ygGQpdRZvswOt6I6wejESAcOwaLvydG/I0UF1dTxjwM=; b=Vw0pD2RIAGadJqoDt+KmnYSGryWd6LWGogcj/0WMkLqnhpnZkgDj2LBVrIthJ62DZz RzyNZTH/5VYbQyiBoQbXE0dY0OCkwUpkF9qd7T/4mVvsT7XioZi0RoA4OUwNArMv7eET jFJU+K61lUXJPXr8biMkZpDHjuqgru2IzodfrrPkNIamWUnGCtl/xw5wUSPWCWofHgtf W/CuOXeQHJI9/s5Gyo8FT284sRaBY/BswhUqVl9HbJD94+lhvrnJ6yuwqCzvvEZPLtWW qR0EnBbEpzinp2UhEUrke4D3ERHCREstrIf/AG39nDk3KTypCw4GAiYeXcrtgwvTPwUw jRdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=RgSgckpv; 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-6290-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6290-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 v11-20020a63f20b000000b00429946b0642si19029122pgh.469.2022.09.15.16.56.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6290-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=RgSgckpv; 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-6290-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="mptcp+bounces-6290-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 1A285280CBC for ; Thu, 15 Sep 2022 23:56:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 649306AA5; Thu, 15 Sep 2022 23:56:40 +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 E54C06AAC for ; Thu, 15 Sep 2022 23:56:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286188; cv=none; d=zohomail.eu; s=zohoarc; b=GSbF+1gS02cuVjpyacs6UBGZVFLksci5SiWMxqiS5low9PlgkQnSncbZoUGGF+MhqS7HOcfZEa0Ep4zUq4rIQf1lIFlo9DgSJW2wSerrwKetQVmcluEJ0W+nPUd05Ig2IA28lV+NfpE4F/a+vi5vYByrZfN73a1pM1YtcDNlDMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286188; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ygGQpdRZvswOt6I6wejESAcOwaLvydG/I0UF1dTxjwM=; b=Qnrnsqos4k4tJSd6jafPM8q2Y4DLd3MPnzkbdSPsfyknU+ot7YJ35TCGUwPogP+tXcF7Dop1uZmjTbcisOyb5g9OqHoFXYRdEh2QoAdt1uzxfBvlMhIxjaFKM2LA47M89hMt2ca1FK+WSp7zp23BFYrBGNrjy8exBEbHrGTHt60= 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=1663286188; 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-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=ygGQpdRZvswOt6I6wejESAcOwaLvydG/I0UF1dTxjwM=; b=RgSgckpvZmZn19ojBQPdHjF3NNSwVXDWAeSlAzrUbCK9vFkuaYPbwk/UmxglZ355 oQKVVeiJh3P3doehhlyngZrMN/4lba2XzHwoQ5qLR1o0lGTaZxw71AtdQDhbJ5ESc0o YREumv/f0Tsn/LEF21Xq15RqVO9nwLnfrwYFFFAw= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286185679305.49044090522693; Fri, 16 Sep 2022 01:56:25 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-9-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 8/9] mptcp_fastopen_add_skb() helpers (skb to msk) Date: Fri, 16 Sep 2022 01:56:03 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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" Set of helpers for mptcp_skb_add(). Some functions are inspired from tcp fastopen.c file. This chain helps to add =E2=80=9Cskb=E2=80=9D to =E2=80=9C= &msk->sk_receive_queue=E2=80=9D (=E2=80=9Csubflow_v4_conn_request=E2=80=9D->=E2=80=9Dmptcp_conn_request=E2= =80=9D->=E2=80=9Dmptcp_try_fastopen=E2=80=9D-> =E2=80=9Dmptcp_fastopen_create_child=E2=80=9D->=E2=80=9Dmptcp_fastopen_add_= skb=E2=80=9D) Signed-off-by: Dmytro Shytyi --- net/mptcp/fastopen.c | 379 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 379 insertions(+) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 7070d2a966c9..815bae37097a 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -172,3 +172,382 @@ void mptcp_fastopen_add_skb(struct sock *sk, struct s= k_buff *skb, struct request if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) tcp_fin(sk); } + +struct sock *mptcp_fastopen_create_child(struct sock *sk, + struct sk_buff *skb, + struct request_sock *req) +{ + struct request_sock_queue *r_sock_queue =3D &inet_csk(sk)->icsk_accept_qu= eue; + struct tcp_sock *tp; + struct sock *child_sock; + bool own_req; + + child_sock =3D inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NUL= L, + NULL, &own_req); + if (!child_sock) + return NULL; + + spin_lock(&r_sock_queue->fastopenq.lock); + r_sock_queue->fastopenq.qlen++; + spin_unlock(&r_sock_queue->fastopenq.lock); + + tp =3D tcp_sk(child_sock); + + rcu_assign_pointer(tp->fastopen_rsk, req); + tcp_rsk(req)->tfo_listener =3D true; + + tp->snd_wnd =3D ntohs(tcp_hdr(skb)->window); + tp->max_window =3D tp->snd_wnd; + + inet_csk_reset_xmit_timer(child_sock, ICSK_TIME_RETRANS, + TCP_TIMEOUT_INIT, TCP_RTO_MAX); + + refcount_set(&req->rsk_refcnt, 2); + + tcp_init_transfer(child_sock, BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, skb); + + tp->rcv_nxt =3D TCP_SKB_CB(skb)->seq + 1; + + mptcp_fastopen_add_skb(child_sock, skb, req); + + tcp_rsk(req)->rcv_nxt =3D tp->rcv_nxt; + tp->rcv_wup =3D tp->rcv_nxt; + + return child_sock; +} + +bool mptcp_fastopen_queue_check(struct sock *sk) +{ + struct fastopen_queue *fo_queue; + struct request_sock *req_sock; + + fo_queue =3D &inet_csk(sk)->icsk_accept_queue.fastopenq; + if (fo_queue->max_qlen =3D=3D 0) + return false; + + if (fo_queue->qlen >=3D fo_queue->max_qlen) { + spin_lock(&fo_queue->lock); + req_sock =3D fo_queue->rskq_rst_head; + if (!req_sock || time_after(req_sock->rsk_timer.expires, jiffies)) { + spin_unlock(&fo_queue->lock); + return false; + } + fo_queue->rskq_rst_head =3D req_sock->dl_next; + fo_queue->qlen--; + spin_unlock(&fo_queue->lock); + reqsk_put(req_sock); + } + return true; +} + +bool mptcp_fastopen_cookie_gen_cipher(struct request_sock *req, + struct sk_buff *syn, + const siphash_key_t *key, + struct tcp_fastopen_cookie *foc) +{ + if (req->rsk_ops->family =3D=3D AF_INET) { + const struct iphdr *iph =3D ip_hdr(syn); + + foc->val[0] =3D cpu_to_le64(siphash(&iph->saddr, + sizeof(iph->saddr) + + sizeof(iph->daddr), + key)); + foc->len =3D TCP_FASTOPEN_COOKIE_SIZE; + return true; + } + + return false; +} + +void mptcp_fastopen_cookie_gen(struct sock *sk, + struct request_sock *req, + struct sk_buff *syn, + struct tcp_fastopen_cookie *foc) +{ + struct tcp_fastopen_context *ctx; + + rcu_read_lock(); + ctx =3D tcp_fastopen_get_ctx(sk); + if (ctx) + mptcp_fastopen_cookie_gen_cipher(req, syn, &ctx->key[0], foc); + rcu_read_unlock(); +} + +int mptcp_fastopen_cookie_gen_check(struct sock *sk, + struct request_sock *req, + struct sk_buff *syn, + struct tcp_fastopen_cookie *orig, + struct tcp_fastopen_cookie *valid_foc) +{ + struct tcp_fastopen_cookie mptcp_search_foc =3D { .len =3D -1 }; + struct tcp_fastopen_cookie *mptcp_foc =3D valid_foc; + struct tcp_fastopen_context *mptcp_fo_ctx; + int i, ret =3D 0; + + rcu_read_lock(); + mptcp_fo_ctx =3D tcp_fastopen_get_ctx(sk); + if (!mptcp_fo_ctx) + goto out; + for (i =3D 0; i < tcp_fastopen_context_len(mptcp_fo_ctx); i++) { + mptcp_fastopen_cookie_gen_cipher(req, syn, &mptcp_fo_ctx->key[i], mptcp_= foc); + if (tcp_fastopen_cookie_match(mptcp_foc, orig)) { + ret =3D i + 1; + goto out; + } + mptcp_foc =3D &mptcp_search_foc; + } +out: + rcu_read_unlock(); + return ret; +} + +bool mptcp_fastopen_no_cookie(const struct sock *sk, + const struct dst_entry *dst, + int flag) +{ + return (sock_net(sk)->ipv4.sysctl_tcp_fastopen & flag) || + tcp_sk(sk)->fastopen_no_cookie || + (dst && dst_metric(dst, RTAX_FASTOPEN_NO_COOKIE)); +} + +struct sock *mptcp_try_fastopen(struct sock *sk, struct sk_buff *skb, + struct request_sock *req, + struct tcp_fastopen_cookie *foc, + const struct dst_entry *dst) +{ + bool syn_data_status =3D TCP_SKB_CB(skb)->end_seq !=3D TCP_SKB_CB(skb)->s= eq + 1; + struct tcp_fastopen_cookie valid_mptcp_foc =3D { .len =3D -1 }; + struct sock *child_sock; + int ret =3D 0; + + if ((syn_data_status || foc->len >=3D 0) && + mptcp_fastopen_queue_check(sk)) { + foc->len =3D -1; + return NULL; + } + + if (mptcp_fastopen_no_cookie(sk, dst, TFO_SERVER_COOKIE_NOT_REQD)) + goto fastopen; + + if (foc->len =3D=3D 0) { + mptcp_fastopen_cookie_gen(sk, req, skb, &valid_mptcp_foc); + } else if (foc->len > 0) { + ret =3D mptcp_fastopen_cookie_gen_check(sk, req, skb, foc, + &valid_mptcp_foc); + if (ret) { +fastopen: + child_sock =3D mptcp_fastopen_create_child(sk, skb, req); + if (child_sock) { + if (ret =3D=3D 2) { + valid_mptcp_foc.exp =3D foc->exp; + *foc =3D valid_mptcp_foc; + } else { + foc->len =3D -1; + } + return child_sock; + } + } + } + valid_mptcp_foc.exp =3D foc->exp; + *foc =3D valid_mptcp_foc; + return NULL; +} + +int mptcp_conn_request(struct request_sock_ops *rsk_ops, + const struct tcp_request_sock_ops *af_ops, + struct sock *sk, struct sk_buff *skb) +{ + struct tcp_fastopen_cookie mptcp_foc =3D { .len =3D -1 }; + struct tcp_options_received tmp_opt_rcvd; + __u32 isn =3D TCP_SKB_CB(skb)->tcp_tw_isn; + struct tcp_sock *tp_sock =3D tcp_sk(sk); + struct sock *mptcp_fo_sk =3D NULL; + struct net *net =3D sock_net(sk); + struct request_sock *req_sock; + bool want_cookie =3D false; + struct dst_entry *dst; + struct flowi fl; + + if (sk_acceptq_is_full(sk)) + goto drop; + + req_sock =3D inet_reqsk_alloc(rsk_ops, sk, !want_cookie); + if (!req_sock) + goto drop; + + req_sock->syncookie =3D want_cookie; + tcp_rsk(req_sock)->af_specific =3D af_ops; + tcp_rsk(req_sock)->ts_off =3D 1; + tcp_rsk(req_sock)->is_mptcp =3D 1; + + tcp_clear_options(&tmp_opt_rcvd); + tmp_opt_rcvd.mss_clamp =3D af_ops->mss_clamp; + tmp_opt_rcvd.user_mss =3D tp_sock->rx_opt.user_mss; + tcp_parse_options(sock_net(sk), skb, &tmp_opt_rcvd, 0, + want_cookie ? NULL : &mptcp_foc); + + if (want_cookie && !tmp_opt_rcvd.saw_tstamp) + tcp_clear_options(&tmp_opt_rcvd); + + if (IS_ENABLED(CONFIG_SMC) && want_cookie) + tmp_opt_rcvd.smc_ok =3D 0; + + tmp_opt_rcvd.tstamp_ok =3D 0; + mptcp_openreq_init(req_sock, &tmp_opt_rcvd, skb, sk); + inet_rsk(req_sock)->no_srccheck =3D inet_sk(sk)->transparent; + + inet_rsk(req_sock)->ir_iif =3D inet_request_bound_dev_if(sk, skb); + + dst =3D af_ops->route_req(sk, skb, &fl, req_sock); + if (!dst) + goto drop_and_free; + + if (tmp_opt_rcvd.tstamp_ok) + tcp_rsk(req_sock)->ts_off =3D af_ops->init_ts_off(net, skb); + + if (!want_cookie && !isn) { + if (!net->ipv4.sysctl_tcp_syncookies && + (net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) < + (net->ipv4.sysctl_max_syn_backlog >> 2)) && + !tcp_peer_is_proven(req_sock, dst)) { + goto drop_and_release; + } + + isn =3D af_ops->init_seq(skb); + } + + mptcp_ecn_create_request(req_sock, skb, sk, dst); + + if (want_cookie) { + isn =3D cookie_init_sequence(af_ops, sk, skb, &req_sock->mss); + if (!tmp_opt_rcvd.tstamp_ok) + inet_rsk(req_sock)->ecn_ok =3D 0; + } + + tcp_rsk(req_sock)->snt_isn =3D isn; + tcp_rsk(req_sock)->txhash =3D net_tx_rndhash(); + tcp_rsk(req_sock)->syn_tos =3D TCP_SKB_CB(skb)->ip_dsfield; + + tcp_openreq_init_rwin(req_sock, sk, dst); + sk_rx_queue_set(req_to_sk(req_sock), skb); + if (!want_cookie) { + mptcp_reqsk_record_syn(sk, req_sock, skb); + mptcp_fo_sk =3D mptcp_try_fastopen(sk, skb, req_sock, &mptcp_foc, dst); + } + if (mptcp_fo_sk) { + af_ops->send_synack(mptcp_fo_sk, dst, &fl, req_sock, + &mptcp_foc, TCP_SYNACK_FASTOPEN, skb); + if (!inet_csk_reqsk_queue_add(sk, req_sock, mptcp_fo_sk)) { + reqsk_fastopen_remove(mptcp_fo_sk, req_sock, false); + bh_unlock_sock(mptcp_fo_sk); + sock_put(mptcp_fo_sk); + goto drop_and_free; + } + sk->sk_data_ready(sk); + bh_unlock_sock(mptcp_fo_sk); + sock_put(mptcp_fo_sk); + } else { + tcp_rsk(req_sock)->tfo_listener =3D false; + if (!want_cookie) { + req_sock->timeout =3D tcp_timeout_init((struct sock *)req_sock); + inet_csk_reqsk_queue_hash_add(sk, req_sock, req_sock->timeout); + } + af_ops->send_synack(sk, dst, &fl, req_sock, &mptcp_foc, + !want_cookie ? TCP_SYNACK_NORMAL : + TCP_SYNACK_COOKIE, + skb); + if (want_cookie) { + reqsk_free(req_sock); + return 0; + } + } + reqsk_put(req_sock); + return 0; + +drop_and_release: + dst_release(dst); +drop_and_free: + __reqsk_free(req_sock); +drop: + tcp_listendrop(sk); + return 0; +} + +void mptcp_reqsk_record_syn(const struct sock *sk, + struct request_sock *req, + const struct sk_buff *skb) +{ + if (tcp_sk(sk)->save_syn) { + u32 length =3D skb_network_header_len(skb) + tcp_hdrlen(skb); + struct saved_syn *svd_syn; + u32 mac_headerlen; + void *base; + + if (tcp_sk(sk)->save_syn =3D=3D 2) { + base =3D skb_mac_header(skb); + mac_headerlen =3D skb_mac_header_len(skb); + length +=3D mac_headerlen; + } else { + base =3D skb_network_header(skb); + mac_headerlen =3D 0; + } + + svd_syn =3D kmalloc(struct_size(svd_syn, data, length), + GFP_ATOMIC); + if (svd_syn) { + svd_syn->mac_hdrlen =3D mac_headerlen; + svd_syn->network_hdrlen =3D skb_network_header_len(skb); + svd_syn->tcp_hdrlen =3D tcp_hdrlen(skb); + memcpy(svd_syn->data, base, length); + req->saved_syn =3D svd_syn; + } + } +} + +void mptcp_ecn_create_request(struct request_sock *req, + const struct sk_buff *skb, + const struct sock *listen_sk, + const struct dst_entry *dst) +{ + const struct tcphdr *thdr =3D tcp_hdr(skb); + const struct net *net =3D sock_net(listen_sk); + bool thdr_ecn =3D thdr->ece && thdr->cwr; + bool ect_stat, ecn_okay; + u32 ecn_okay_dst; + + if (!thdr_ecn) + return; + + ect_stat =3D !INET_ECN_is_not_ect(TCP_SKB_CB(skb)->ip_dsfield); + ecn_okay_dst =3D dst_feature(dst, DST_FEATURE_ECN_MASK); + ecn_okay =3D net->ipv4.sysctl_tcp_ecn || ecn_okay_dst; + + if (((!ect_stat || thdr->res1) && ecn_okay) || tcp_ca_needs_ecn(listen_sk= ) || + (ecn_okay_dst & DST_FEATURE_ECN_CA) || + tcp_bpf_ca_needs_ecn((struct sock *)req)) + inet_rsk(req)->ecn_ok =3D 1; +} + +void mptcp_openreq_init(struct request_sock *req, + const struct tcp_options_received *rx_opt, + struct sk_buff *skb, const struct sock *sk) +{ + struct inet_request_sock *ireq =3D inet_rsk(req); + + req->rsk_rcv_wnd =3D 0; + tcp_rsk(req)->rcv_isn =3D TCP_SKB_CB(skb)->seq; + tcp_rsk(req)->rcv_nxt =3D TCP_SKB_CB(skb)->seq + 1; + tcp_rsk(req)->snt_synack =3D 0; + tcp_rsk(req)->last_oow_ack_time =3D 0; + req->mss =3D rx_opt->mss_clamp; + req->ts_recent =3D rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; + ireq->tstamp_ok =3D rx_opt->tstamp_ok; + ireq->sack_ok =3D rx_opt->sack_ok; + ireq->snd_wscale =3D rx_opt->snd_wscale; + ireq->wscale_ok =3D rx_opt->wscale_ok; + ireq->acked =3D 0; + ireq->ecn_ok =3D 0; + ireq->ir_rmt_port =3D tcp_hdr(skb)->source; + ireq->ir_num =3D ntohs(tcp_hdr(skb)->dest); + ireq->ir_mark =3D inet_request_mark(sk, skb); +} --=20 2.25.1 From nobody Fri Apr 19 21:19:50 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:32da:0:0:0:0:0 with SMTP id f26csp704636uao; Thu, 15 Sep 2022 16:56:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xlCiW3Dg4M/+kN5mjuyqE0nivSc05UPhxJDjxDMQHKH+seieJgoWdBx3w9s5czvm8dcEB X-Received: by 2002:ac8:664b:0:b0:35b:aff2:9684 with SMTP id j11-20020ac8664b000000b0035baff29684mr2228240qtp.686.1663286206446; Thu, 15 Sep 2022 16:56:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663286206; cv=pass; d=google.com; s=arc-20160816; b=aq8jCBIyHIHaCX3JiMZGWDlqNKpQvA57i0BRQdF94eN6++kWzbAlQIrG6d2jBYmGd2 JV8cJ1nfa0ZHV1OC3t9p7UQojdfpCB3KVi7Ta75mhX5fIiQ6H22XVj3dNBXh8xB0eAX+ HjJxHWgyr5QwTtjobpjv1McYUBlp2Om4dd0oW6z9IEWhA+YnyhD9bhF8QuW4olP/DaE/ hvxxgDBOQApomJCGI+5lZZycqR1rlocOjz+reg8QREM6eG9VObs/KeTeqN13Cdk5w5g6 7PEXimNwr0gxyV7jnJPaaSDRPuqJTWqXBHRopwxSMsOLixf2Lld+Br9Zdr5042lS9gIm wXnw== 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=b4zKrGARJ7e33+3v6s/NTW+HuTAWQQrbb8194YNLMBWrcfXI2EXqOPh2VOT2qdCB24 unAyFhtqOUYqaOlJ9eQyiPZG4Jp8H/X85NVQbxzn6KQ15duPkJXduCxI+qauIhaa/rHB ofiN19wxOt5MQP962g7kStrzML4sPq7fM4iqiQhdRCyGeXaFexh3dmchRAmeNXB4TIhs FH72/BJ9UgT3/a85dam5GoHdmn8RGxBcJpMGRJpyB/1xqQlZuBpX0yyTFreP+oZRgmAy MfabjnP6+swy7ksn46k2Dj1nBsDcu50UQhir81YNLItVItf7kfYauLgOUVGnPGWhDlyb A7cQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=G9OlOz8Z; 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-6288-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.199.223 as permitted sender) smtp.mailfrom="mptcp+bounces-6288-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dt22-20020a05620a479600b006ce5aaeb4acsi4376569qkb.297.2022.09.15.16.56.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2022 16:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-6288-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@shytyi.net header.s=hs header.b=G9OlOz8Z; 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-6288-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.199.223 as permitted sender) smtp.mailfrom="mptcp+bounces-6288-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 391731C208D8 for ; Thu, 15 Sep 2022 23:56:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17B7A6AA9; Thu, 15 Sep 2022 23:56:40 +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 E23CC6AAA for ; Thu, 15 Sep 2022 23:56:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1663286187; cv=none; d=zohomail.eu; s=zohoarc; b=emJbEKEr1pwa3/lAeLM14uh0x36PKCqkbo/BWUgrT0aXo7/jaIg83jfgr3Wn4fHyUhnGErNqAtdVR3KP0E1pR62wZrksWfNizwkjMO/+6Hl9GKwlkc+qxJsl0CTFb7IhH7wcvtt2+6Q1BTGQKVy3tOgcrufen7reGSWx2StXpqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1663286187; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=A374qcFGZnxbZk1AlL4TUHso2FHnehXtgKDlDMolsaI=; b=H0JTpYeGwSZQMoagkpbqjIHgEkGhNx1NEPithBrJK9//I/E2upTUPqHJU6E4ePkaRfPyMjDiyWZlZ0+qNLs1JJmIMByUmfwiXenVQNxnkKtZwu6OuYJXBMo+PTnNleVms715uH2tj2XU2HB5hExDR7yeTd72yMN7WHh6YnQ9JY8= 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=1663286187; 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=G9OlOz8Zsl13LGUnCswonTTQKb6oaFoZaSmdwCTPtYpL8nanTHyVTK+xgWsv01RI tc7bEflj7gtZ9SMjP/4QC7zVBPVqYjkVl1ay+6RxJKi9n7DMJ1nKcxD/iQLbn1em7xh joU4zlCy21/B/2HnDKsJLrlH9Zc0Mzo4RicDYhnk= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1663286185891764.2179158547953; Fri, 16 Sep 2022 01:56:25 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220915235604.26018-10-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v6 9/9] selftests: mptfo initiator/listener Date: Fri, 16 Sep 2022 01:56:04 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915235604.26018-1-dmytro@shytyi.net> References: <20220915235604.26018-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