From nobody Mon Sep 16 18:54:22 2024 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 8803710F1 for ; Sat, 7 Jan 2023 01:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673056004; x=1704592004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LaWSAGD1LoOBS5f/EQBtGcxsZ/H1Mi/K5mfqwVKmmaU=; b=g8Ittf4RpBSVZdPJHu9pfksJxmh3xJelNRx7witIEgEprYGlEeoUHv0H 5JP3qNUD5kAscyyp++rEEtOEjgbW7yjW08+J9kTx5b3saZocVXMng6Sih vT3Ww6uPwrttlI8zmWJI37p/+4yOrOYgzu7xiaPWwDHLh0TrhW8AgPVZU WlZr+pj3OfZGbJyXAs9UOS0g4ZoM24jqL/e/UVlUp9h9+gEAF123gDU8G sW+8lsceXUsbem8hcZTjK1XahRRjfT4sJZ8z94dwgvb7Fd+lgUFFLhORG 4tWoogck+ZVq20PbbV+bjAaD6Go8DQf5sD+9lxZ8CrSmpIeSsUI7tvfuU g==; X-IronPort-AV: E=McAfee;i="6500,9779,10582"; a="310393559" X-IronPort-AV: E=Sophos;i="5.96,307,1665471600"; d="scan'208";a="310393559" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 17:46:42 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10582"; a="606066135" X-IronPort-AV: E=Sophos;i="5.96,307,1665471600"; d="scan'208";a="606066135" Received: from mechevar-mobl.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.66.63]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2023 17:46:42 -0800 From: Mat Martineau To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: Matthieu Baerts , pabeni@redhat.com, mptcp@lists.linux.dev, Mat Martineau , Jakub Kicinski Subject: [PATCH 5.10 2/4] mptcp: remove MPTCP 'ifdef' in TCP SYN cookies Date: Fri, 6 Jan 2023 17:46:29 -0800 Message-Id: <20230107014631.449550-3-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230107014631.449550-1-mathew.j.martineau@linux.intel.com> References: <20230107014631.449550-1-mathew.j.martineau@linux.intel.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matthieu Baerts commit 3fff88186f047627bb128d65155f42517f8e448f upstream. To ease the maintenance, it is often recommended to avoid having #ifdef preprocessor conditions. Here the section related to CONFIG_MPTCP was quite short but the next commit needs to add more code around. It is then cleaner to move specific MPTCP code to functions located in net/mptcp directory. Now that mptcp_subflow_request_sock_ops structure can be static, it can also be marked as "read only after init". Suggested-by: Paolo Abeni Reviewed-by: Mat Martineau Cc: stable@vger.kernel.org # 5.10 Signed-off-by: Matthieu Baerts Signed-off-by: Mat Martineau Signed-off-by: Jakub Kicinski --- include/net/mptcp.h | 12 ++++++++++-- net/ipv4/syncookies.c | 7 +++---- net/mptcp/subflow.c | 12 +++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 753ba7e755d6..3e529d8fce73 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -58,8 +58,6 @@ struct mptcp_out_options { }; =20 #ifdef CONFIG_MPTCP -extern struct request_sock_ops mptcp_subflow_request_sock_ops; - void mptcp_init(void); =20 static inline bool sk_is_mptcp(const struct sock *sk) @@ -133,6 +131,9 @@ void mptcp_seq_show(struct seq_file *seq); int mptcp_subflow_init_cookie_req(struct request_sock *req, const struct sock *sk_listener, struct sk_buff *skb); +struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_o= ps *ops, + struct sock *sk_listener, + bool attach_listener); #else =20 static inline void mptcp_init(void) @@ -208,6 +209,13 @@ static inline int mptcp_subflow_init_cookie_req(struct= request_sock *req, { return 0; /* TCP fallback */ } + +static inline struct request_sock *mptcp_subflow_reqsk_alloc(const struct = request_sock_ops *ops, + struct sock *sk_listener, + bool attach_listener) +{ + return NULL; +} #endif /* CONFIG_MPTCP */ =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 41afc9155f31..542b66783493 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -290,12 +290,11 @@ struct request_sock *cookie_tcp_reqsk_alloc(const str= uct request_sock_ops *ops, struct tcp_request_sock *treq; struct request_sock *req; =20 -#ifdef CONFIG_MPTCP if (sk_is_mptcp(sk)) - ops =3D &mptcp_subflow_request_sock_ops; -#endif + req =3D mptcp_subflow_reqsk_alloc(ops, sk, false); + else + req =3D inet_reqsk_alloc(ops, sk, false); =20 - req =3D inet_reqsk_alloc(ops, sk, false); if (!req) return NULL; =20 diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 61919e2499e7..6a149da3a4d9 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -359,7 +359,7 @@ static void subflow_finish_connect(struct sock *sk, con= st struct sk_buff *skb) mptcp_subflow_reset(sk); } =20 -struct request_sock_ops mptcp_subflow_request_sock_ops; +static struct request_sock_ops mptcp_subflow_request_sock_ops __ro_after_i= nit; static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops __ro_afte= r_init; =20 static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb) @@ -411,6 +411,16 @@ static int subflow_v6_conn_request(struct sock *sk, st= ruct sk_buff *skb) } #endif =20 +struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_o= ps *ops, + struct sock *sk_listener, + bool attach_listener) +{ + ops =3D &mptcp_subflow_request_sock_ops; + + return inet_reqsk_alloc(ops, sk_listener, attach_listener); +} +EXPORT_SYMBOL(mptcp_subflow_reqsk_alloc); + /* validate hmac received in third ACK */ static bool subflow_hmac_valid(const struct request_sock *req, const struct mptcp_options_received *mp_opt) --=20 2.39.0