From patchwork Tue Dec 19 21:31:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 181270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2242756dyi; Tue, 19 Dec 2023 13:39:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqHkDXjF/nQyj/AcSjed42JI6LGrdirmhDCjDSKOvqkDzENuzbg+p5RBN1EV8dWDrZFXT7 X-Received: by 2002:a17:906:259:b0:a23:33aa:7ff1 with SMTP id 25-20020a170906025900b00a2333aa7ff1mr3045644ejl.12.1703021945886; Tue, 19 Dec 2023 13:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703021945; cv=none; d=google.com; s=arc-20160816; b=MqKiJYJKdn3eMw7MUXcwHCZ8nfwiH+e5pAzW3Mjo612SVsdZTz4U/LbCZsD4pzN1Ww 11ynqqFvthaogm4I2Y0I6PccEI58/bCw9Qg43FMXp1vO6o8+vE16NbSLu47qKSRRQZgW cs+kyW4EoT0rMB0ZqZc38VV5UQz8/ypiTDGGTrNOINiOtxnq0wvjL6eDB2dkZRTeuST+ PP8R2zhbpDQ6dGnhjf7Rz6BLmDP1iG1S332gO7JtVv1h8UYsB9QwmAnZPnWu4gWDoPiw LDJEwnDygQ+9V6/IJSd+/uyL0glCz4Fxfob07B+567PRSYuZRGuah9lrjnq85Ud1sXju c+0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=/JXs81XQot+/AC59ZZptze3pJ15srgOc0knsnw2CS1E=; fh=9bPvzr65Cd0XByo2yad68DjrgiofXoLUOaM8TC9kRko=; b=UxIZAkwyybNVNIJfJhFOCWyEtQOmx4o0nFsIDHTQTFqemmo6CHtK/kXObZ2Zk5+CUc ldS8MZxUFhPj6EcGU0H568Ei1M0vqkgXm7uoMu0Rcu0K7GxN2LLXkz5YLoNEjYpiqXHX ozZAvmppzph8Wtj+fSsUjvA3GIpdWkl4cn+MyrCW5q4fWGBJIkU5i9hEXtphARJiCWzZ pCWaRRkoj4OR5s1OtsxmXEFPY0LrDXd2wjO7UkR6SBhwxodp9uRxHc1TnkTaPjlFflJl NCmXEuzGKDzZz/bLLoYp7SEIXIBhh/QaFO0TAscRjlHSrPQkFCdEO+Ahb42g+RybMDwB Osfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HuDvY7y+; spf=pass (google.com: domain of linux-kernel+bounces-5976-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5976-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k5-20020a1709063e0500b00a2357b5a235si2126772eji.768.2023.12.19.13.39.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 13:39:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5976-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HuDvY7y+; spf=pass (google.com: domain of linux-kernel+bounces-5976-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5976-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 54CB81F25EFD for ; Tue, 19 Dec 2023 21:39:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81F263D0CD; Tue, 19 Dec 2023 21:38:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HuDvY7y+" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B6A343C6A6; Tue, 19 Dec 2023 21:38:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4271EC433CB; Tue, 19 Dec 2023 21:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703021901; bh=8Zn/iQVfoK4WIL45SvwHhkDsI7IJQsZYNrWnNX4iYfk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HuDvY7y+npE2BYFAUTGUmPTqoqv1kQMFubqpoOMTHEw94/UgqfarMZzqIiU292UCR oTwpXDOt1LH+RBBpPCu1RGziPoGXjlBTH3BCDP1Jhxst0EE58gKfPwljzajMSC7eV0 MjM3FCS8WxleAUTw3W/ttmaeCDWe5lXkWt9B70wbCscQ/c34zvHC+Gv9ZV4a5uH3Qp esBH+U6iYGdlWkdNPrxus/UvWPjqL6R+3kRgYoyxc9/mM3LKsNl/cn2FG6S++8yqSA 7m2TAmhODtgAxL3wJ4yyeRV2YpPbzi87RKfd7sV7nqpLCyhhVZBedXlmUEsSaOMo7X Z6Hzp7bdMGGGA== From: Matthieu Baerts Date: Tue, 19 Dec 2023 22:31:04 +0100 Subject: [PATCH net-next 1/4] mptcp: don't overwrite sock_ops in mptcp_is_tcpsk() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-1-2b13bedfcaf8@kernel.org> References: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> In-Reply-To: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Davide Caratti X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=5762; i=matttbe@kernel.org; h=from:subject:message-id; bh=v4M3WEJtEY7LyvLuXHxK426HlsZ0UnL0hBK4mmkBBmM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlgg1GSxhyd+Jy3SU8214jmetGhy6hxnoL0WzJj F0ZIO/6uleJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZYINRgAKCRD2t4JPQmmg c4eqEAC5G8QY+40kuyodpRXOK2hthefXhY9PWnUYLMK3OWk0kSxOo6+Yq1WiEOGKFgBmNKzjX/m a214ydCa+XPU8Gb61k6UoJdNUQzjxdMIB4NJVHgQuvHxK5IM1wSqdlegxfel+6zyKN5yKjiUjs8 AT8uijfxfKekhF5OoM0qoZ2ddLh3sWw4EyEiqvVReBcpdlZlzSLIXXcm4fsnkTaBj7paPujid39 RgmZ+9R1189GME94H4E8rLb/HFkLBVc9N7X7EMXPC59TAG03psJi0biEuXhMwtbfBagMPyS9t2k GfvkFccygiuR4V3DOVXsyEMyQW5No/VFVEsGvnz0vuUrhawUxzx8vSiI7dLv0K2gqC2GKtct0mC 8wqeKYt6Sih7PhM+FhFYwDnpzDekAjVYuOjsF4qfFcYeY4K3k96J4xB8BKvNessUljRKfwA16zD kNGdRMvAjhFj+9amHHHrqujggIRFUhTiKD//xBqZ4/VUIQ4uiBs7XSA5NnUqPA36q85NmQjIWGA aDbXAdIxhj5BXSQAKtbIBEk0OGqMwyJNV4pp8HrixqJbmx6QObj4xBrg3BwohjiKMyyn+ZwT5A1 cw4BCHZlTBBHj2WG95mXgxdy8S1bhjjJm7SbriqRVn4jdVBk31YFa9OCy9d/wFF6usHpvvwvjaN uAXWkYP9KQEU4lg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785747940281156183 X-GMAIL-MSGID: 1785747940281156183 From: Davide Caratti Eric Dumazet suggests: > The fact that mptcp_is_tcpsk() was able to write over sock->ops was a > bit strange to me. > mptcp_is_tcpsk() should answer a question, with a read-only argument. re-factor code to avoid overwriting sock_ops inside that function. Also, change the helper name to reflect the semantics and to disambiguate from its dual, sk_is_mptcp(). While at it, collapse mptcp_stream_accept() and mptcp_accept() into a single function, where fallback / non-fallback are separated into a single sk_is_mptcp() conditional. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/432 Suggested-by: Eric Dumazet Signed-off-by: Davide Caratti Acked-by: Paolo Abeni Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 108 +++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 64 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index bc81ea53a049..5cbbd1221030 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -55,28 +55,14 @@ static u64 mptcp_wnd_end(const struct mptcp_sock *msk) return READ_ONCE(msk->wnd_end); } -static bool mptcp_is_tcpsk(struct sock *sk) +static const struct proto_ops *mptcp_fallback_tcp_ops(const struct sock *sk) { - struct socket *sock = sk->sk_socket; - - if (unlikely(sk->sk_prot == &tcp_prot)) { - /* we are being invoked after mptcp_accept() has - * accepted a non-mp-capable flow: sk is a tcp_sk, - * not an mptcp one. - * - * Hand the socket over to tcp so all further socket ops - * bypass mptcp. - */ - WRITE_ONCE(sock->ops, &inet_stream_ops); - return true; #if IS_ENABLED(CONFIG_MPTCP_IPV6) - } else if (unlikely(sk->sk_prot == &tcpv6_prot)) { - WRITE_ONCE(sock->ops, &inet6_stream_ops); - return true; + if (sk->sk_prot == &tcpv6_prot) + return &inet6_stream_ops; #endif - } - - return false; + WARN_ON_ONCE(sk->sk_prot != &tcp_prot); + return &inet_stream_ops; } static int __mptcp_socket_create(struct mptcp_sock *msk) @@ -3258,44 +3244,6 @@ void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk) WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd); } -static struct sock *mptcp_accept(struct sock *ssk, int flags, int *err, - bool kern) -{ - struct sock *newsk; - - pr_debug("ssk=%p, listener=%p", ssk, mptcp_subflow_ctx(ssk)); - newsk = inet_csk_accept(ssk, flags, err, kern); - if (!newsk) - return NULL; - - pr_debug("newsk=%p, subflow is mptcp=%d", newsk, sk_is_mptcp(newsk)); - if (sk_is_mptcp(newsk)) { - struct mptcp_subflow_context *subflow; - struct sock *new_mptcp_sock; - - subflow = mptcp_subflow_ctx(newsk); - new_mptcp_sock = subflow->conn; - - /* is_mptcp should be false if subflow->conn is missing, see - * subflow_syn_recv_sock() - */ - if (WARN_ON_ONCE(!new_mptcp_sock)) { - tcp_sk(newsk)->is_mptcp = 0; - goto out; - } - - newsk = new_mptcp_sock; - MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPCAPABLEPASSIVEACK); - } else { - MPTCP_INC_STATS(sock_net(ssk), - MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK); - } - -out: - newsk->sk_kern_sock = kern; - return newsk; -} - void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags) { struct mptcp_subflow_context *subflow, *tmp; @@ -3739,7 +3687,6 @@ static struct proto mptcp_prot = { .connect = mptcp_connect, .disconnect = mptcp_disconnect, .close = mptcp_close, - .accept = mptcp_accept, .setsockopt = mptcp_setsockopt, .getsockopt = mptcp_getsockopt, .shutdown = mptcp_shutdown, @@ -3849,18 +3796,36 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, if (!ssk) return -EINVAL; - newsk = mptcp_accept(ssk, flags, &err, kern); + pr_debug("ssk=%p, listener=%p", ssk, mptcp_subflow_ctx(ssk)); + newsk = inet_csk_accept(ssk, flags, &err, kern); if (!newsk) return err; - lock_sock(newsk); - - __inet_accept(sock, newsock, newsk); - if (!mptcp_is_tcpsk(newsock->sk)) { - struct mptcp_sock *msk = mptcp_sk(newsk); + pr_debug("newsk=%p, subflow is mptcp=%d", newsk, sk_is_mptcp(newsk)); + if (sk_is_mptcp(newsk)) { struct mptcp_subflow_context *subflow; + struct sock *new_mptcp_sock; + + subflow = mptcp_subflow_ctx(newsk); + new_mptcp_sock = subflow->conn; + + /* is_mptcp should be false if subflow->conn is missing, see + * subflow_syn_recv_sock() + */ + if (WARN_ON_ONCE(!new_mptcp_sock)) { + tcp_sk(newsk)->is_mptcp = 0; + goto tcpfallback; + } + + newsk = new_mptcp_sock; + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPCAPABLEPASSIVEACK); + + newsk->sk_kern_sock = kern; + lock_sock(newsk); + __inet_accept(sock, newsock, newsk); set_bit(SOCK_CUSTOM_SOCKOPT, &newsock->flags); + msk = mptcp_sk(newsk); msk->in_accept_queue = 0; /* set ssk->sk_socket of accept()ed flows to mptcp socket. @@ -3882,6 +3847,21 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, if (unlikely(list_is_singular(&msk->conn_list))) inet_sk_state_store(newsk, TCP_CLOSE); } + } else { + MPTCP_INC_STATS(sock_net(ssk), + MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK); +tcpfallback: + newsk->sk_kern_sock = kern; + lock_sock(newsk); + __inet_accept(sock, newsock, newsk); + /* we are being invoked after accepting a non-mp-capable + * flow: sk is a tcp_sk, not an mptcp one. + * + * Hand the socket over to tcp so all further socket ops + * bypass mptcp. + */ + WRITE_ONCE(newsock->sk->sk_socket->ops, + mptcp_fallback_tcp_ops(newsock->sk)); } release_sock(newsk); From patchwork Tue Dec 19 21:31:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 181271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2242899dyi; Tue, 19 Dec 2023 13:39:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlpLGAYUoWadvDBEOrVmEnJJzwpzL5+DM0klZwXVx+4yRJmYCw29xaVhtNQ9Sh2V66YfBn X-Received: by 2002:a50:9302:0:b0:553:83ca:60be with SMTP id m2-20020a509302000000b0055383ca60bemr1669412eda.4.1703021968362; Tue, 19 Dec 2023 13:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703021968; cv=none; d=google.com; s=arc-20160816; b=rqc2lPJfneFSepXIJ29D7IFQoF30cMf5Ejn+IiXKYEF+Jujpc+XjgzQrZWJOtxq7ko +aWi9pr5vxBezl+XJy53VyOU9acW1ZhJ45alZ7GePLdY9fPIBWwUdAMXameEeyh8nG9C 2BzaJ7Hqgr7vAom/Fj/PURWZ9DV4zfR3cMSaMIwFvr/EyzDfIkQorvJjnuiUUc9yL3Ec /5z2eKHAB+476pzHydvNzhBBOdKrWhYI5jwa74l8U3opubTivVBPsESmVEuqVTA23GgL /Fbf0I6lR+FNYpZ/SsUZG2PfmGFb9jyenTcNaDkqUTn7qIj0GeUTjLa6k74QE715tXs+ NnnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=9SD1pldbCZggPK+J+yWKry2bq8z7UC6Gl4i+8+cxlEY=; fh=aOwBygz+wKB3128x8oB/xLQze0DGN0/RLCJBUjfqRNQ=; b=DtcQ8aQnyJQm+//bVaq6HXSppjSbScpZdzDuw9S+gpn1hME2zNz2T5cM2DRQhqHfg0 qVVYhPHTEVVYsjUpjs7QBYrJraaBQ+ndKX78J66Pn8Iu6LQPkAoc4m3/3+ANUCRMaySU jPphmCvRhWKQPFjWED4OdESMlodMRVBPSG6kL1DnACM0NT8QfqAus3ZVggOlkU7gkGgu A/SfPL3dBg9M1S2lqBn9weBB7NIrKQF04zRnej97ERAJZQ3qpKFADPgtI5ByKGDi82Yw AyxyeWpISgwyT4iVlOzCNimTRzxVIwaIjV4NumHjHZikPOhR1yNN/5fL4FySo+Bb9ff9 BiGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkKCl1TN; spf=pass (google.com: domain of linux-kernel+bounces-5977-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5977-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 22-20020a508e16000000b005538ad08b5dsi1049320edw.611.2023.12.19.13.39.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 13:39:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5977-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkKCl1TN; spf=pass (google.com: domain of linux-kernel+bounces-5977-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5977-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0118D1F25A5B for ; Tue, 19 Dec 2023 21:39:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 090853EA7D; Tue, 19 Dec 2023 21:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CkKCl1TN" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4385C3D0D4; Tue, 19 Dec 2023 21:38:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C031CC433C9; Tue, 19 Dec 2023 21:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703021904; bh=aBjfw6fT7ns+cc6CISw+cYXM6DUUWWc2pJdKMlpk6Cs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CkKCl1TNYdbOkyCjQmBr7REKoe0KAojB26oGv6kloSJ0yKCjpJpIDIZNq+ZgTFdFp +p96bDLLf+SqLYSWIoomW9fksc7WzWLxgXM3dRvxT0O077MLEh6u7LF+jFxSBzKVzX rbckGuCpHc2BiBORyG+BB+3+dYneTqldA5+hizQdoHLJHHhjxNu5CbbI54Ck/n94AU zsnvDNVEcFb+NYaTSjKuNa9vs/OICm/sQOABGgH4DAjssoypiMzC1Hn5itPaZrE425 cI4xWlDFaMmFezKR70BJ8MWxW6ZgWx+F2kYpBwN3KEqzBkuBxivCm50komVPWni5Bq 8/UIFheBD+DNw== From: Matthieu Baerts Date: Tue, 19 Dec 2023 22:31:05 +0100 Subject: [PATCH net-next 2/4] mptcp: rename mptcp_setsockopt_sol_ip_set_transparent() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-2-2b13bedfcaf8@kernel.org> References: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> In-Reply-To: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Maxim Galaganov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1404; i=matttbe@kernel.org; h=from:subject:message-id; bh=XEswUomoEVDRkr2zFcuVgd5ZmZS3x1/YVKLTXtSAG2Y=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlgg1Gc19zG3z5FZc014YtOLHZwI0p6AgQkvKDA 0TQMeadrUaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZYINRgAKCRD2t4JPQmmg cx83D/9CIsHNlz8qyUptArMYLOswrCZAMJlfedxNZJJyOZxxm+ODAaGqkcyZOCbH4H8KUuQ6rba mxfsQKlbA3/+l4p40BD7l7Vx4LMub2DX9n+gmJQfGPd/hXlF+z56r/veTLruY9+n5K0IUhujCFu BzBqDqdmmAjtNpctgvxB0TjkVuZFGjaf4zQDqfDTck4DMwLy0wHl1zou8s2eym+JR69pQlipK0D r7oV/uuoVCJJub1bz/NVK/lUka/b7wKHdt2T0hLTM7ARjNEmZTmvjSYcsfFDaC7H05E2og9jeLG NfvZFOt9g15Q5d9d2GYSl2OvS+uXWQDYGaeS18pAaihETHuYxZiOmig8Hsc5kiQy8aNgtcUQ7TY 2s8SWc9ziu6j5wZqirVemi4Aay/X1XJiGBnVe7xqkyhRu0KKUK6pvqhchabkrW++nd6rXxTIiAW NSYuuOp/cNcmgV1S3/vXN43gJ/dV7EPH3/3UTlwrqBURTAmwEqSuyIPSq4KC4O2zHHJjLHmBcXu Sib2YLXKApgsaTmC19fSdVQ0ptFh6reEcqgK+qFSOsqSLvE0QUsaVkVIWVuEIF6Lk2ndK/lE5PQ Ioog4TYsNHrEDrwHOLO+aiL84la0YsRZkBQwi577lcMPWMxveYZlwbRQs1SKONKG/wX0WZqfGXG pcza2nO5ThCpt6A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785747963448292263 X-GMAIL-MSGID: 1785747963448292263 From: Maxim Galaganov Next patch extends this function so that it's not specific to IP_TRANSPARENT. Change function name to mptcp_setsockopt_sol_ip_set(). Reviewed-by: Mat Martineau Signed-off-by: Maxim Galaganov Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index cabe856b2a45..a4bf337e6f77 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -683,8 +683,8 @@ static int mptcp_setsockopt_sol_tcp_nodelay(struct mptcp_sock *msk, sockptr_t op return 0; } -static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int optname, - sockptr_t optval, unsigned int optlen) +static int mptcp_setsockopt_sol_ip_set(struct mptcp_sock *msk, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; struct sock *ssk; @@ -755,7 +755,7 @@ static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, switch (optname) { case IP_FREEBIND: case IP_TRANSPARENT: - return mptcp_setsockopt_sol_ip_set_transparent(msk, optname, optval, optlen); + return mptcp_setsockopt_sol_ip_set(msk, optname, optval, optlen); case IP_TOS: return mptcp_setsockopt_v4_set_tos(msk, optname, optval, optlen); } From patchwork Tue Dec 19 21:31:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 181272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2243031dyi; Tue, 19 Dec 2023 13:39:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGv1vdG4JXuIhXgYt5nN381LrGofY6/h2gK9bwRG4o+1lcx8j1Xcoh/vJhfKXOo8AVEpXlJ X-Received: by 2002:a05:622a:15c1:b0:425:4054:bc5d with SMTP id d1-20020a05622a15c100b004254054bc5dmr2594334qty.57.1703021989913; Tue, 19 Dec 2023 13:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703021989; cv=none; d=google.com; s=arc-20160816; b=PxkXQ1EjKmFH87ueSnVsBOY87cdvvZTLbsSLLABzKOycL1DilZEmRe/02m6ptqDorY Nwcno+OJov3RixcbrmpO+nRPmhcXE/88mL0dZAXC5+AYAiYf5HW3Nzgf5pIRbNmSQlFD 8ci7ErNAtYpc+IqXqGiEbPO1i9hE2h5Py9NL9V2YHwcDIVLtg5i8Dq5NvISS8GBg8mRH FaBgROVbaKzHDRNVucYjEaICR6g/yWEWP81SxQR1/xrKfXX0e48fZGr22n1GtonHmgdk fo8T8fsbQ/oRYQZbXZMmT6Cf1YLmIn5Wtw8vsl7O4ZQ9NoS683mdrRwxy2NDlLWSpqn+ 6eIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=00+MTSXEWOsHN/I9d1HH7Kx5bFWt0GMxkSvS0fOs2d0=; fh=aOwBygz+wKB3128x8oB/xLQze0DGN0/RLCJBUjfqRNQ=; b=M83vcnpleqDsWMFAbqbu3bfHsHfIVjfi4UhLdOechb/YVJYcYifmbXJiWlPkpba7Th DVaKa9XH5+HN/wZmSqbmsRK4EWmWy+ka+Qkyc2OGg9rBmKSolid/K3NP/OSnV+pUm901 nnTMvfuEgp/EE+qEj8jdLzc++Kdl4N0SgTuPmKUpl9nVEutS8VmBUw9S6EOGBZGiNbAr CO5tLm19FF+/fiftYXQnFIuAy55v/aTJZEHAtPtNS7/q17kq0Kfg9ZnLmiJk/U4qW7h0 /35tFXdmo91URnILT7Mt/bVyjWg0GVct29QgUdKgL5tO/Fl0KOfS9raUPzrdLLhMt8kZ oQUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tmKIW94g; spf=pass (google.com: domain of linux-kernel+bounces-5978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5978-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d11-20020a05622a15cb00b004260c8f8d1esi11312216qty.328.2023.12.19.13.39.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 13:39:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5978-ouuuleilei=gmail.com@vger.kernel.org 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=@kernel.org header.s=k20201202 header.b=tmKIW94g; spf=pass (google.com: domain of linux-kernel+bounces-5978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5978-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 B1D9D1C20E77 for ; Tue, 19 Dec 2023 21:39:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7793D405C6; Tue, 19 Dec 2023 21:38:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tmKIW94g" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A741A3EA8B; Tue, 19 Dec 2023 21:38:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EB2FC433CA; Tue, 19 Dec 2023 21:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703021908; bh=G38Y9vn95+svfjge9y+7TA53QzHDBFEvohQmqR7X9S0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tmKIW94ggHYEEuJS3LH5KeTGTmWWVNDLQumexqYTobX2FFho7PEdNHNMmVxDBTr7s AlYQhXw9rMlYaUqX754X+zmy2HVg+LJWdKM5Or3sAR6FIZdYCrGYa20PQAVOL95yqv EvgMlNYUjp00QVDRENQAsG2AeYTTTliPWkwR4woSEEtanEDaG9+vA0OQ5Gzz6rld7o rWnjQTxxbGkh++HvX/vD1cG7UA4otl9z/Lzhiugjz4ucWAmTQ0FRj6JhRPOtOTOgEi W0XASrD/PXLk3LBxpehDD9Jx4mrivV6a51sl553+TDKkMdQC/qfTmqyiYQEvdne5dc WS2lxg2b2Wm/w== From: Matthieu Baerts Date: Tue, 19 Dec 2023 22:31:06 +0100 Subject: [PATCH net-next 3/4] mptcp: sockopt: support IP_LOCAL_PORT_RANGE and IP_BIND_ADDRESS_NO_PORT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-3-2b13bedfcaf8@kernel.org> References: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> In-Reply-To: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Maxim Galaganov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3769; i=matttbe@kernel.org; h=from:subject:message-id; bh=4AJuGj51MOryvbeh06GHzAMXOcN8IZTC5d1GACIH8bU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlgg1GkzI21MpKNVXeJqL+Um1GIYAx9tptIJjm3 VfM6Rdw80CJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZYINRgAKCRD2t4JPQmmg cxCiEADa2UUfnDGEUYxlYYSLwol3CIRPfWs4mZdWacMIUQF/EySYy+SQxY/7onvCwcLCXnvzklM Z1RABidfzMyYk4OhkyL4NnhjGLuatez6SaWXBmp8WQbTLWIpxjxgGpKZ2IF3MPFubawJ9C2Ebd8 RXP39ELMWTyib48ikGHDT+6Toqqfu8j4MFcDLtif7nXWukru5uAh3nnMBy/1NOCsU+XfWGkaJ26 LEXA2Y1iP3B0QXiO3CnRQWzcc2eQO4kDKTqtAQfyaA4UpegE0R3JZYuASRgBATLDB4nQ3Z+CEi2 H7t2F2YqOziO4e2pazUiRoH05jR/ibEd4t/kWMVvqR2wUewzoaIn0m502SktNCx/PuLiw1lWFlu QPEs9GZ0NILc3/CY86sSS25Vx4chBfKmni43MsPPTI6bjo62suanTni1SD8kZHRF4ZfYVskB+4n RpHtTZaXih+OPNxcMMsvxZo92bit5qe+0fSkCZDYqp7nCcGxJ2yOke3N5CuZdifCQP4zqUtLY1i bDs1M6uwotbx7lyt5muiuEwVDsqKnC7y5bBoob5eudVjfMX7hWoEIIGAy7y9YE5av7jULk5ofhe rkuWVPzMlFfzCyMYUzkJTM14eBXNXMhNmZIeX0YL1qqNUHBtm+ev1axLJ62Oio2d1C7c2S3ZdWY SPTB5TvSkFXWalQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785747986222226071 X-GMAIL-MSGID: 1785747986222226071 From: Maxim Galaganov Support for IP_BIND_ADDRESS_NO_PORT sockopt was introduced in [1]. Recently [2] allowed its value to be accessed without locking the socket. Support for (newer) IP_LOCAL_PORT_RANGE sockopt was introduced in [3]. In the same series a selftest was added in [4]. This selftest also covers the IP_BIND_ADDRESS_NO_PORT sockopt. This patch enables getsockopt()/setsockopt() on MPTCP sockets for these socket options, syncing set values to subflows in sync_socket_options(). Ephemeral port range is synced to subflows, enabling NAT usecase described in [3]. [1] commit 90c337da1524 ("inet: add IP_BIND_ADDRESS_NO_PORT to overcome bind(0) limitations") [2] commit ca571e2eb7eb ("inet: move inet->bind_address_no_port to inet->inet_flags") [3] commit 91d0b78c5177 ("inet: Add IP_LOCAL_PORT_RANGE socket option") [4] commit ae5439658cce ("selftests/net: Cover the IP_LOCAL_PORT_RANGE socket option") Signed-off-by: Maxim Galaganov Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index a4bf337e6f77..c40f1428e602 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -440,6 +440,8 @@ static bool mptcp_supported_sockopt(int level, int optname) /* should work fine */ case IP_FREEBIND: case IP_TRANSPARENT: + case IP_BIND_ADDRESS_NO_PORT: + case IP_LOCAL_PORT_RANGE: /* the following are control cmsg related */ case IP_PKTINFO: @@ -455,7 +457,6 @@ static bool mptcp_supported_sockopt(int level, int optname) /* common stuff that need some love */ case IP_TOS: case IP_TTL: - case IP_BIND_ADDRESS_NO_PORT: case IP_MTU_DISCOVER: case IP_RECVERR: @@ -710,6 +711,14 @@ static int mptcp_setsockopt_sol_ip_set(struct mptcp_sock *msk, int optname, inet_assign_bit(TRANSPARENT, ssk, inet_test_bit(TRANSPARENT, sk)); break; + case IP_BIND_ADDRESS_NO_PORT: + inet_assign_bit(BIND_ADDRESS_NO_PORT, ssk, + inet_test_bit(BIND_ADDRESS_NO_PORT, sk)); + break; + case IP_LOCAL_PORT_RANGE: + WRITE_ONCE(inet_sk(ssk)->local_port_range, + READ_ONCE(inet_sk(sk)->local_port_range)); + break; default: release_sock(sk); WARN_ON_ONCE(1); @@ -755,6 +764,8 @@ static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, switch (optname) { case IP_FREEBIND: case IP_TRANSPARENT: + case IP_BIND_ADDRESS_NO_PORT: + case IP_LOCAL_PORT_RANGE: return mptcp_setsockopt_sol_ip_set(msk, optname, optval, optlen); case IP_TOS: return mptcp_setsockopt_v4_set_tos(msk, optname, optval, optlen); @@ -1350,6 +1361,12 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, switch (optname) { case IP_TOS: return mptcp_put_int_option(msk, optval, optlen, READ_ONCE(inet_sk(sk)->tos)); + case IP_BIND_ADDRESS_NO_PORT: + return mptcp_put_int_option(msk, optval, optlen, + inet_test_bit(BIND_ADDRESS_NO_PORT, sk)); + case IP_LOCAL_PORT_RANGE: + return mptcp_put_int_option(msk, optval, optlen, + READ_ONCE(inet_sk(sk)->local_port_range)); } return -EOPNOTSUPP; @@ -1450,6 +1467,8 @@ static void sync_socket_options(struct mptcp_sock *msk, struct sock *ssk) inet_assign_bit(TRANSPARENT, ssk, inet_test_bit(TRANSPARENT, sk)); inet_assign_bit(FREEBIND, ssk, inet_test_bit(FREEBIND, sk)); + inet_assign_bit(BIND_ADDRESS_NO_PORT, ssk, inet_test_bit(BIND_ADDRESS_NO_PORT, sk)); + WRITE_ONCE(inet_sk(ssk)->local_port_range, READ_ONCE(inet_sk(sk)->local_port_range)); } void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk) From patchwork Tue Dec 19 21:31:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 181273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2243210dyi; Tue, 19 Dec 2023 13:40:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeLg7Fj8whqRs0o481Bl3e1kxQ8cf+BUhrax0WxZNXkgsdEzJDoT3zmxv5gvge6Uej5fM2 X-Received: by 2002:a17:906:5184:b0:a23:2762:e48b with SMTP id y4-20020a170906518400b00a232762e48bmr2405251ejk.63.1703022013540; Tue, 19 Dec 2023 13:40:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703022013; cv=none; d=google.com; s=arc-20160816; b=qqYbM0k1qA/ZvkZQ4HaBouP8kAw0PZU/D8Dy7/l+JckzhpmzV2AHwDw5WDJL1Rze4G huPIJqgISZiPmi+n3l4ahLnqLqOWe6pjdakbHcquAUS4ZUor5e5IfPyQXdnipNjdiuBx 0kER44fcAR4fc+38CJgokGecn1nEpTaPwA9bq3aWjS9V6ykPsYBO/LlFprZnwh7M2yzd evlfXg07h7gYWs32EOt/aKg1eYezGhYsnaWjqJo7MlKhQAIxoDKyMYv5tCgd7S43tn4x EPPcTWBbImrgZhD+DXRWRnJuw4BonYLeHw1YB+iHLYqLFx/62+S+23HOSnbliKduRE0J 76bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=NRofVFURhd5B5q9/4PD1N6zZL7+UYWqm0a/TEOmUVwE=; fh=aOwBygz+wKB3128x8oB/xLQze0DGN0/RLCJBUjfqRNQ=; b=hMKl4fTVMvCJZQERj8zsUb0kPu+ETFd1+PKXBvqRaSFHqFfmM+cRgP/Ini9zlbf4NO 2D/OlWDTXLquSR0YpfbhIeOVq2U3V2icQMexZNv1dDy+p5mecxtoOaOK2SBtgLqX/3kE 0KIifmcZ+dgDXFQ9qpvGInnNeCadAqi7vo/gFPLmkNaZtvguAMRWQolI2ez97+G5vtTV hNZlhtcBH5nnyuP0DK4+80lYNqbLquddUsULqD4PBnbRHe66E4IUWcpdQXtJF0ndXXyx Y2B+CQ+PrU8F1xj2JUTiNP3vWUs1+tmXFzvyJ6xELYJoMfhFvgNfD+Kt2IElcw3+7ovj vWRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S0Ry5sMV; spf=pass (google.com: domain of linux-kernel+bounces-5979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5979-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w7-20020a170906480700b00a236b8004d2si1375558ejq.193.2023.12.19.13.40.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 13:40:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S0Ry5sMV; spf=pass (google.com: domain of linux-kernel+bounces-5979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5979-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2AE221F26039 for ; Tue, 19 Dec 2023 21:40:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D45DD40BF9; Tue, 19 Dec 2023 21:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S0Ry5sMV" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1BB90405DA; Tue, 19 Dec 2023 21:38:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B71D5C43391; Tue, 19 Dec 2023 21:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703021911; bh=f2gvC7w8UKri1c32TAYRYmZfycGTKFEwGDAv7yV/QLQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=S0Ry5sMVLnzW9pfp5OOWzLtrq2lcFYBDkGnWaWhIjb7vvdmk3FiP0tm1rxUkZverp q4jbOfBaymVSztcy7QBqDgi0jxV+u5Vh2O5bH0yCs0lOviTxRDe75bbU+VfRnlnqUP sGcSQSuMyXispGjJyyoynNdSuPLW5iTpYCQZ0CrLvflAkFZtRMTbLL/qs8TPYnixKI jglBDy7OFaJAbElv9eCKTw8k0i8Xla+DpEBvwJlYl7319mtD5nC8iD67IpZrhmwtim ViaKR6nh2f+sXbP6uyKGqAtklvCO6ZjqU6+81WboqQ+wVI/J0uUHM97gH6Xii6JJxN rxLa5yCTq1DNg== From: Matthieu Baerts Date: Tue, 19 Dec 2023 22:31:07 +0100 Subject: [PATCH net-next 4/4] selftests/net: add MPTCP coverage for IP_LOCAL_PORT_RANGE Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-4-2b13bedfcaf8@kernel.org> References: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> In-Reply-To: <20231219-upstream-net-next-20231219-mptcp-sockopts-ephemeral-ports-v1-0-2b13bedfcaf8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Maxim Galaganov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1494; i=matttbe@kernel.org; h=from:subject:message-id; bh=fbNXZmS3qdsPsilwuM1H+dJAdECITs25qe5pVmz8Lns=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlgg1GFZH7w/nEOkP6mdB5g8NK5fxpSdj5RXrmW 2XtMy/upC6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZYINRgAKCRD2t4JPQmmg c8NTD/4t4jyh509SjqZKZ8C+OeSKDHHfwQbtZPaRhfzX6i3eG8MFzJIoSYM4KleCc090f+b90uc +KjaK5eCRueP7R6jxZLwVynQjlvikIJRllhTeTUEJNTy6NJmNsS2PPZPaxkRARcyPHr0ty7Se+Z 4N3IIBbZzIjaa0COKK4uzvcPNQpDjZZvyweEKWOb6J+rMYJjVnfr0gDYjg49/sWCelsdswXS/XP JcGyYv5my09XipqrpNFwPGtJgmbV5yz3AziF8gGEZlBZj8k7ANSJ0TaMaW+d4JtBG8BDyd535bZ 7UBv8e8QZBT5ukVEFb9y6Epdp44xEhvAEyNT8ECMnxopATc6L/+Uj30pCQ5kmHFFDQ+ogZCFwkI 8frd+F3amLVX/4Tm5hVFmGyBVwpvKczuBdBobCBpW8S2iTfJD7guBCE5HEKZwb7HMDuFaY6q9s0 41rKsdFtLtCRGCZTR+aSkdGmGqsWXZP0X/vCTYwnLDjcMWqFO8E1PjAh/5fdr6X+30wsL6Vt2DT sx6C1UR6StmZP0+eCnv0nv1OORPnWwITowgBkDr+OcEDJT2i/DSshKBPotSjd7L5xwSLQ8blFj+ vFBrGTTGjC1S9t9D5KMp7XT2Qv7818reel2WYzIo+v91qi7inseuHV/D6zdGkFzfW9zZr9XMf3E g+AXCkavMVLUhSg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785748011104581350 X-GMAIL-MSGID: 1785748011104581350 From: Maxim Galaganov Since previous commit, MPTCP has support for IP_BIND_ADDRESS_NO_PORT and IP_LOCAL_PORT_RANGE sockopts. Add ip4_mptcp and ip6_mptcp fixture variants to ip_local_port_range selftest to provide selftest coverage for these sockopts. Acked-by: Mat Martineau Signed-off-by: Maxim Galaganov Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/ip_local_port_range.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/net/ip_local_port_range.c b/tools/testing/selftests/net/ip_local_port_range.c index 75e3fdacdf73..0f217a1cc837 100644 --- a/tools/testing/selftests/net/ip_local_port_range.c +++ b/tools/testing/selftests/net/ip_local_port_range.c @@ -146,6 +146,12 @@ FIXTURE_VARIANT_ADD(ip_local_port_range, ip4_stcp) { .so_protocol = IPPROTO_SCTP, }; +FIXTURE_VARIANT_ADD(ip_local_port_range, ip4_mptcp) { + .so_domain = AF_INET, + .so_type = SOCK_STREAM, + .so_protocol = IPPROTO_MPTCP, +}; + FIXTURE_VARIANT_ADD(ip_local_port_range, ip6_tcp) { .so_domain = AF_INET6, .so_type = SOCK_STREAM, @@ -164,6 +170,12 @@ FIXTURE_VARIANT_ADD(ip_local_port_range, ip6_stcp) { .so_protocol = IPPROTO_SCTP, }; +FIXTURE_VARIANT_ADD(ip_local_port_range, ip6_mptcp) { + .so_domain = AF_INET6, + .so_type = SOCK_STREAM, + .so_protocol = IPPROTO_MPTCP, +}; + TEST_F(ip_local_port_range, invalid_option_value) { __u16 val16;