From patchwork Fri Jan 24 10:28:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13949233 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 AC450219A90 for ; Fri, 24 Jan 2025 10:28:50 +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=1737714530; cv=none; b=uslR4iURIX9qna+8ckrOKDRv54s6keKQPzEjxW94dQCyMlKXsgmXsrGFJqcmJu+UaQE/zUSP2YydADspcIfkmTZQqUCW2FjwfEFxRnEoaQlJcGy8cbDLJgerNRsG5paUJ+9QZYNbM/L682cho0lreSDf+QKIr8WZSdpR+b2n/Hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737714530; c=relaxed/simple; bh=KOure61nZXVuhZQUsemR0zq/2S631J/op6/b8PjoEfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IV8WiY/mUWelVlxQaYoxUZSlOsa6InaD652yIlynqU4HKeE0XW5jWtu/9mIHcWyLsqLEQk+K2ckFxfQOIPvJtFWE+/uAVcJIagVfzRiDGSN5KMlfFbm09l8ipm4460czTPK8ybxhuu3SyW7sZKq6QUX0KHoS/xZ5AZnHJ0C2YuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o1tt2n67; 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="o1tt2n67" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 068A0C4CEDD; Fri, 24 Jan 2025 10:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737714530; bh=KOure61nZXVuhZQUsemR0zq/2S631J/op6/b8PjoEfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o1tt2n67mYvSfGmw8dedFGecemf7yQt3iy0kdM1fMgSensLVdyGP7POf0iZXTCdXL OgWXn/VERUiGsxXDYXFpR1/FqPfJrwfugO107SJaCyhb2986vnIBtrvceEUG+V/HoO kNdRRyRy4eS+U2oFqq4ou6anaFx6vubFlVtzw5Kd95oIIdYd/kPwngYwCJ4l3Wqras 0vhzCDkBFEq+KlxC+G4lmUwAUR3KQZxSPUBF5OPO/DLkhsU1W1GkemBA4XqgfdSNPo cP/uPL+D9mrmL2uHgd/U5WPu6dgNz4XEeiuSHlQIdOGmC0JgZjBYmD0zD9vZZPqbzk UOv9QsZF01I8w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 1/3] Squash to "bpf: Add mptcp_subflow bpf_iter" Date: Fri, 24 Jan 2025 18:28:39 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Drop the NULL check as Martin suggested. Use the "struct sock *sk" instead of "struct mptcp-sock *msk" as the argument in the bpf_iter_mptcp_subflow_new as Martin suggested. Use msk_owned_by_me(). Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 923895322b2c..def4de34666d 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -234,24 +234,27 @@ bpf_mptcp_subflow_ctx(const struct sock *sk) __bpf_kfunc static int bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it, - struct mptcp_sock *msk) + struct sock *sk) { struct bpf_iter_mptcp_subflow_kern *kit = (void *)it; - struct sock *sk = (struct sock *)msk; + struct mptcp_sock *msk; BUILD_BUG_ON(sizeof(struct bpf_iter_mptcp_subflow_kern) > sizeof(struct bpf_iter_mptcp_subflow)); BUILD_BUG_ON(__alignof__(struct bpf_iter_mptcp_subflow_kern) != __alignof__(struct bpf_iter_mptcp_subflow)); - kit->msk = msk; - if (!msk) + if (unlikely(!sk || !sk_fullsock(sk))) return -EINVAL; - if (!sock_owned_by_user_nocheck(sk) && - !spin_is_locked(&sk->sk_lock.slock)) + if (sk->sk_protocol != IPPROTO_MPTCP) return -EINVAL; + msk = mptcp_sk(sk); + kit->msk = msk; + + msk_owned_by_me(msk); + kit->pos = &msk->conn_list; return 0; } From patchwork Fri Jan 24 10:28:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13949234 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 20B081B21AD for ; Fri, 24 Jan 2025 10:28:52 +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=1737714532; cv=none; b=ERIUMPBZ8dkKW5dCiHKj9iqxt+HHww+VMnQYjxhWpCzjMR8DHozoRrEJqf8pCsguXIw70liBlRFf3hnPZTAtXPWf2vbdx3lzSvD3jmo5wqAgOrF0wYrwHcsq23qeC7qiETCzDbs6S8+lG/pXr3+/fA8VQ5lEqNgK9QS9N1hkVJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737714532; c=relaxed/simple; bh=oGmxM4LXDzvIY8eA8PSBTT06Nl1iB7C2qKIoOM3mW4s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p0Z6zM0QiLZ3jKp1YK/NkHGtYcA20Z3wHGx7AxNkbODPuV9mlUoUHCwbProwAnxRoXg7FlKXTBgNN8wfPgN7QYBUnXZcPkaDYNawY6/lleXgDPgPLql46tnIb8+wCf6AYTRTLDDAxD+Iwt7n2Q3INURarI6iiaXTH3sknenfcPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GBQiVSr2; 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="GBQiVSr2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C87F9C4CED2; Fri, 24 Jan 2025 10:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737714532; bh=oGmxM4LXDzvIY8eA8PSBTT06Nl1iB7C2qKIoOM3mW4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBQiVSr26Z+M+OEDv6w68UZbOleV/TvYzvVGl8C4Swyy3L8yk7bN3Uec/JHea33lA /bIK1Apq5pHIQMEvYfGlz+TB2LJh5LipTxhQh8/zOJzQ3dGDz0C4juR39JTAdZGFKu rL6Jvohsk91mTTxfJKC4uuWe4uNXQ3dtOTcjriTFZQd8i2cN2CIh8HNp2B5uBQEfp/ ATEih9p2exsoYjtHAmWODDk4bKkVpwydlIMootbdsrajYjLzmdKO9fFz20jb3M0OvK QakXWCtUldxDcwzicDFM3TIqXNDnG0P9bYZ71g1PCm9gkZvCYEauCbdjyF83zgYiVs SYTwMCbIjDJrw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 2/3] Revert "bpf: Acquire and release mptcp socket" Date: Fri, 24 Jan 2025 18:28:40 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Drop this patch as Martin suggested. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index def4de34666d..27a8c2e9ca2b 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -276,23 +276,6 @@ bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it) { } -__bpf_kfunc static struct -mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) -{ - struct sock *sk = (struct sock *)msk; - - if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) - return msk; - return NULL; -} - -__bpf_kfunc static void bpf_mptcp_sock_release(struct mptcp_sock *msk) -{ - struct sock *sk = (struct sock *)msk; - - WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); -} - __bpf_kfunc struct mptcp_subflow_context * bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) { @@ -313,8 +296,6 @@ BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL) BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS) BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY) -BTF_ID_FLAGS(func, bpf_mptcp_sock_acquire, KF_ACQUIRE | KF_RET_NULL) -BTF_ID_FLAGS(func, bpf_mptcp_sock_release, KF_RELEASE) BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids) static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { From patchwork Fri Jan 24 10:28:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13949235 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 DDC661D7E57 for ; Fri, 24 Jan 2025 10:28:53 +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=1737714534; cv=none; b=YQ3JRVOEsYFPil9tB8S+6kG8xWtHfIv/4PE/2o3+RZtfE13XVL5zkd1h9aHbBHgzu+4cpwW9S/oadGT18UqkeRDbNCnZT68OG6r18EUnuZeUq3uZb7j1NhWgpdOQRdTlbLRRFbsjCakxfczPmgfND1PxgduC86t4N5VM3XhXEJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737714534; c=relaxed/simple; bh=h2n87wCU2BBgP3HSC8BIpxpCqxLNz3114U8TmdaBA/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j2E29lNHsK3QdkaPD92oEaa6Xl5Fhn3ejTLxzUO5heO2+qQN6VdhoFGPT9Xn7ma/XkDaj3cDAdqTflqwRP/pL+/UF7vHL9UTCjoQo5iWygyZ7T3Qh+eRE3PTb/OZuijkgTFohIRJQ/gkQRb7wAny3BrAB4Ei3hTKa7nS4/eC+WM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vk72zNt+; 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="Vk72zNt+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88D79C4CED2; Fri, 24 Jan 2025 10:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737714533; bh=h2n87wCU2BBgP3HSC8BIpxpCqxLNz3114U8TmdaBA/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vk72zNt+rL1F8vnGgl1wTwS87Zp6L9ajjWF+J4DdwU+tJGI4aBU4KF5TOMsJMHLyN vW8RQUFfU1eNAGDoCfNjVdnoAtO4pyV0cl3lPmeWYf3gt338FRUJuMxip/zDZ3fSGX tR60Zy2Hkdhjj2BXE+mV9B+XocekAuQPr6SJqowvJQForTLeYk7d+8WJ68PH3pTlUq LCqkV5O+ApfWxZtEIY2sHSfUa+3Bmx0rFSi97AaQNjMwZs6UZ/gNy9jFTmeM9Xa7iX RXff1aCCNxL8Xr7G+S++oVeeu6LsHrMrf+iELK40sgQLBV6sxnL9ZKF8rBAclaHo/5 lYrS9oZw6AVog== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 3/3] Squash to "selftests/bpf: Add mptcp_subflow bpf_iter subtest" Date: Fri, 24 Jan 2025 18:28:41 +0800 Message-ID: <19d3e15f4f32c29c4c3ba5049b123f96ac0fde5c.1737714424.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Drop bpf_mptcp_sock_acquire/release. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/bpf_experimental.h | 2 +- tools/testing/selftests/bpf/progs/mptcp_bpf.h | 3 --- tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c | 6 +----- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h index 2ab3f0063c0f..6a96c56f0725 100644 --- a/tools/testing/selftests/bpf/bpf_experimental.h +++ b/tools/testing/selftests/bpf/bpf_experimental.h @@ -577,7 +577,7 @@ extern void bpf_iter_css_destroy(struct bpf_iter_css *it) __weak __ksym; struct bpf_iter_mptcp_subflow; extern int bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it, - struct mptcp_sock *msk) __weak __ksym; + struct sock *sk) __weak __ksym; extern struct mptcp_subflow_context * bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) __weak __ksym; extern void diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/selftests/bpf/progs/mptcp_bpf.h index b1f6e1fb467e..ede9111ee597 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -43,9 +43,6 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) } /* ksym */ -extern struct mptcp_sock *bpf_mptcp_sock_acquire(struct mptcp_sock *msk) __ksym; -extern void bpf_mptcp_sock_release(struct mptcp_sock *msk) __ksym; - extern struct mptcp_subflow_context * bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym; extern struct sock * diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c index fd5691a4073b..6124c484efe3 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_iters.c @@ -28,10 +28,7 @@ int iters_subflow(struct bpf_sockopt *ctx) if (!msk || msk->pm.server_side || !msk->pm.subflows) return 1; - msk = bpf_mptcp_sock_acquire(msk); - if (!msk) - return 1; - bpf_for_each(mptcp_subflow, subflow, msk) { + bpf_for_each(mptcp_subflow, subflow, (struct sock *)sk) { /* Here MPTCP-specific packet scheduler kfunc can be called: * this test is not doing anything really useful, only to * verify the iteration works. @@ -58,6 +55,5 @@ int iters_subflow(struct bpf_sockopt *ctx) ids = local_ids; out: - bpf_mptcp_sock_release(msk); return 1; }