From nobody Sun Dec 14 06:34:47 2025 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 1420623505E for ; Wed, 10 Dec 2025 08:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765354364; cv=none; b=tiArzmKkcl2lDuARTTDwMYQzIxOqiGyzrTRXQzSQp0SylKmSrAEsCZHoHpoDL3zQglWG/nWE79bu2bLJiemQePPACZrqAKL1RgaeK+lgBv5aB9L5L6b37QC/A3jRfGNGfoD48/HMsewz30kS978oDhFmvp0TmX6K1Rbtz7j0ryo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765354364; c=relaxed/simple; bh=ZeyCxId4knqELJNFu2u5cEEYTNvx0kHT/JwXrL0AXOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qSQZ2NJ5CkORaXdqoOIujnED3/JPy5r34UjDoOOsSqiY01XlCdN6tkvXnkXL9CuyX4lKVSGGQ761/ptHPNPZyrrqJTGGHLgG256RZlbsLCzXT1UgrFsuMJdoDwQa6i5b8uxI/hKYcsWTHNq/0FEC/jXjaiq2nbsat+M4Cks7Mio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pDbnJsdN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pDbnJsdN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61D3AC4CEF1; Wed, 10 Dec 2025 08:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765354363; bh=ZeyCxId4knqELJNFu2u5cEEYTNvx0kHT/JwXrL0AXOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pDbnJsdNLySmDDWhMeTTMvDkRQvKx4jfM7J6SgXzFj+6C4Qq5YFzFOfgcHKnkI3EO jO/sG0jHBts3NubtDwj9B4Tuhg0EUb+DaHsI6BDqU2VUtUr4lQkcGA6zlxJSSBGeIu C7fdHVUAEFl5BEQR1c0K7xMxuNEimiBfv+BYWJjqvkn6LYs3fp1GmQTf2CFIbK3r/5 nKJdNOYFfsp7zl4gqlgfgoGGzKiqK6C67jVsPEE+oM2uN6EHYHR1+KjGfhCRAfeMJ/ OByNulJvIEmP77fLSxnLUof52qDq2CEwcQtd28B1PLknibbZcJvQoMpnbqerdWNd9H J0f+CZxAbimAQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 1/2] mptcp: use sk_is_tcp helper Date: Wed, 10 Dec 2025 16:12:35 +0800 Message-ID: X-Mailer: git-send-email 2.51.0 In-Reply-To: References: 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: Geliang Tang This patch enhances the validation by using sk_is_tcp to determine whether the socket is a TCP socket. This approach is more rigorous than simply checking if sk_protocol equals IPPROTO_TCP, as the helper also verifies sk_family and sk_type. Note: The modifications in the bpf_sk_stream_memory_free section should be squashed into the commit "bpf: Export mptcp packet scheduler helpers". Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 4 ++-- net/mptcp/protocol.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index b261551f5d1b..372a21b96495 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -193,7 +193,7 @@ static struct bpf_struct_ops bpf_mptcp_sched_ops =3D { =20 struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) { - if (sk && sk_fullsock(sk) && sk->sk_protocol =3D=3D IPPROTO_TCP && sk_is_= mptcp(sk)) + if (sk && sk_fullsock(sk) && sk_is_tcp(sk) && sk_is_mptcp(sk)) return mptcp_sk(mptcp_subflow_ctx(sk)->conn); =20 return NULL; @@ -294,7 +294,7 @@ __bpf_kfunc static bool bpf_sk_stream_memory_free(const= struct sock *sk__ign) const struct sock *sk =3D sk__ign; =20 if (sk && sk_fullsock(sk) && - sk->sk_protocol =3D=3D IPPROTO_TCP && sk_is_mptcp(sk)) + sk_is_tcp(sk) && sk_is_mptcp(sk)) return sk_stream_memory_free(sk); =20 return NULL; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index cd5266099993..f418a0a0fa51 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -399,7 +399,7 @@ static inline void msk_owned_by_me(const struct mptcp_s= ock *msk) #undef tcp_sk #define tcp_sk(ptr) ({ \ typeof(ptr) _ptr =3D (ptr); \ - WARN_ON(_ptr->sk_protocol !=3D IPPROTO_TCP); \ + WARN_ON(!sk_is_tcp(_ptr)); \ container_of_const(_ptr, struct tcp_sock, inet_conn.icsk_inet.sk); \ }) #define mptcp_sk(ptr) ({ \ --=20 2.51.0 From nobody Sun Dec 14 06:34:47 2025 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 D3E792C237C for ; Wed, 10 Dec 2025 08:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765354365; cv=none; b=SaOfKvX/hY3dJH0iZ1rnsEn9Z9Blmr150kTKrSj9X3egvUQiWa+vPcL44opSEGWi+MdjTO4eOcyb19zRTylFjTTvhTxB+uxxLddXJpwyoUOWIvGGmkELAeQvZIrhZ3LPMZAvd8iI5cDkYh1xYw0Hrs91QuZi69mtLKDG/4z+Wyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765354365; c=relaxed/simple; bh=YwmXZ7kZpzEThkXjZLoQzKFSok6yeQOEjh0RQ/8M3es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R0oQKq9qS4txflTRx9wmlXACqLmlAi09IdhZRFOIo0eXFCa/TnGZPUmQhZEEpyvCj83wMvLeY0bcz843Dv0WMmsw3CTRCINwX+Gyk0NJ+8uzLjExO3wsMhlOnquEJJDvzf//Vt0iM8m+NqkuJtrTpKulDlKUSl/jRkgu9sTlrKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q6AjZ8WA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q6AjZ8WA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C0F0C4CEF1; Wed, 10 Dec 2025 08:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765354365; bh=YwmXZ7kZpzEThkXjZLoQzKFSok6yeQOEjh0RQ/8M3es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6AjZ8WAYVD5zo6OLi/ytql0OQVmLr41uUROayp/vwOsxRc3iuvv6zt8Qb/vAeGFf xhAGJY8lhqOVBXsh9VjZ7xwbSJmalWnJXJrDmklKdv9dHSUDVFhwGQ9Xdtbm1d8jJg tDCs/3OCEQaHYqAB46hqwLQa+UCjq4T5MHrnGHuSGFee9jbs/mQF0PJ5y/GlBZ58Pu WTUqhriS2qoSxcQgefATZp3zZ9SySlEbcf0Y2wLFOJgfuqI1RFOZW9h2P3fuMxARSP q9cuNVrVzMekWWFWdZgnkR1PUKsjIyceYdCVsnHTfWJRwqZHpHWTQYnQXDDbGH6luA LCgWUd+TVzGIw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 2/2] mptcp: add sk_is_msk helper Date: Wed, 10 Dec 2025 16:12:36 +0800 Message-ID: <1c8e8e95896e6f34a677eec690bc9edf493fd4fe.1765354225.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: 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: Geliang Tang This patch introduces a sk_is_msk() helper modeled after sk_is_tcp() to determine whether the socket is an MPTCP one. Unlike sk_is_mptcp(), which accepts a subflow socket as its parameter, this new helper specifically accepts an MPTCP socket parameter. Note: This helper will be useful in the subsequent "MPTCP KTLS support" series. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 12 ++++++++++++ net/mptcp/protocol.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 4cf59e83c1c5..82660374859a 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -150,6 +150,13 @@ static inline bool rsk_drop_req(const struct request_s= ock *req) return tcp_rsk(req)->is_mptcp && tcp_rsk(req)->drop_req; } =20 +static inline bool sk_is_msk(const struct sock *sk) +{ + return sk_is_inet(sk) && + sk->sk_type =3D=3D SOCK_STREAM && + sk->sk_protocol =3D=3D IPPROTO_MPTCP; +} + void mptcp_space(const struct sock *ssk, int *space, int *full_space); bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, unsigned int *size, struct mptcp_out_options *opts); @@ -258,6 +265,11 @@ static inline bool rsk_drop_req(const struct request_s= ock *req) return false; } =20 +static inline bool sk_is_msk(const struct sock *sk) +{ + return false; +} + static inline bool mptcp_syn_options(struct sock *sk, const struct sk_buff= *skb, unsigned int *size, struct mptcp_out_options *opts) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f418a0a0fa51..8f1fd74ecaa3 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -404,7 +404,7 @@ static inline void msk_owned_by_me(const struct mptcp_s= ock *msk) }) #define mptcp_sk(ptr) ({ \ typeof(ptr) _ptr =3D (ptr); \ - WARN_ON(_ptr->sk_protocol !=3D IPPROTO_MPTCP); \ + WARN_ON(!sk_is_msk(_ptr)); \ container_of_const(_ptr, struct mptcp_sock, sk.icsk_inet.sk); \ }) =20 --=20 2.51.0