From patchwork Fri Oct 11 09:27:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832272 X-Patchwork-Delegate: mat@martineau.name 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 120A5804 for ; Fri, 11 Oct 2024 09:27:30 +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=1728638851; cv=none; b=Dw9pi3bNYKQwIdbyH2gUMnUOEzBPQstIjS8yJbSP5qpi6VAeidIMaGLMtegMuJ7Hqkxq44DcbvSFj+3o5+K0JcDIeweiIFD/9KPkQzRHahahOzAlrpW32CQGjtoCPf16oMp0AoZPKs7lgl/h7yLA6VKVH5g+R0mEkk3nJ6XDxQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638851; c=relaxed/simple; bh=Gz6HbhDzNQZ8VvZImuhA0bSkF4NjHsir9HNmr/KM86k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OWdFin4raBt43tgXQ+oi0WrGxch4G9jO3igX1hJJTcmGKeL+H1Z9Z5U9yigev7NrAwN2s2C6cF3dDebEY+xziVF2dcF9f+yO/N4Jzbem7oHmj8XPFiC7kjlTnTjZgPbhizGiNNlYm9OjoVJgSR41dAkhNZQftvHookydqkN84P0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aS/D7SyF; 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="aS/D7SyF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F37AC4CEC3; Fri, 11 Oct 2024 09:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638850; bh=Gz6HbhDzNQZ8VvZImuhA0bSkF4NjHsir9HNmr/KM86k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aS/D7SyFeCq4v520yEviSiWBzAZ/QyNLMsjSodHqZHt5bnAprovVFIStAx+EhPA+P Sda2oHYTU8diG6fd516oKeiee0rQeO2y5q1b+Mmne+65qNZvCHYqbkKoRGeWn6HWyw sR+U32QnsvgXr861ZNvuWMhw8Ar2Dc0+cnpyIRukKcEZtLCwie5t6iqFawhSTTHb6j aEXUb+Tp9RjNf40O7NTgsgU6G+HYinYahau4TpmDEJcb73QngEPrGeOGr77Av9gIJ6 OPQlSgcjjP5MuvGCSM4URViaUB2ycVxfnUdc00HGsTqUwFkrw4GqAbmdlViVDoAKvJ w5bXrpAe1pwZQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 01/11] Revert "mptcp: add sched_data helpers" Date: Fri, 11 Oct 2024 17:27:13 +0800 Message-ID: <29e13e7fb70f446ec82e9a53341719d11475fa01.1728638310.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 this patch. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 8 -------- net/mptcp/protocol.h | 2 -- net/mptcp/sched.c | 22 ---------------------- 3 files changed, 32 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 9b87eee13955..681a76f7c6a8 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -271,14 +271,6 @@ __bpf_kfunc void bpf_mptcp_sock_release(struct mptcp_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) -{ - if (pos >= MPTCP_SUBFLOWS_MAX) - return NULL; - return data->contexts[pos]; -} - __bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk) { return tcp_rtx_queue_empty(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b963e68451b1..e774f28a6f8d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -723,8 +723,6 @@ void mptcp_sock_graft(struct sock *sk, struct socket *parent); u64 mptcp_wnd_end(const struct mptcp_sock *msk); void mptcp_set_timeout(struct sock *sk); bool bpf_mptcp_subflow_queues_empty(struct sock *sk); -struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos); struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 5257bc6c8cd6..78ed508ebc1b 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -143,26 +143,6 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, WRITE_ONCE(subflow->scheduled, scheduled); } -static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data) -{ - struct mptcp_subflow_context *subflow; - int i = 0; - - mptcp_for_each_subflow(msk, subflow) { - if (i == MPTCP_SUBFLOWS_MAX) { - pr_warn_once("too many subflows"); - break; - } - mptcp_subflow_set_scheduled(subflow, false); - data->contexts[i++] = subflow; - } - data->subflows = i; - - for (; i < MPTCP_SUBFLOWS_MAX; i++) - data->contexts[i] = NULL; -} - int mptcp_sched_get_send(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; @@ -189,7 +169,6 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) data.reinject = false; if (msk->sched == &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_subflow(msk, &data); - mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_subflow(msk, &data); } @@ -212,6 +191,5 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) data.reinject = true; if (msk->sched == &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_subflow(msk, &data); - mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_subflow(msk, &data); } From patchwork Fri Oct 11 09:27:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832273 X-Patchwork-Delegate: mat@martineau.name 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 EE0AB804 for ; Fri, 11 Oct 2024 09:27:32 +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=1728638853; cv=none; b=fIMJp2I/9ZwhOFp2Zi8hU9zJUrOOgGi2TTomw+/PZj8AHBhhtmj61t1r3Zb2FIDk4PBjidNRInY/BlOcg+HffCrvT/33NTIeZuNTrITe3enNXRI4WTj5zYyDDtLCxmH4QuQRKj5Kpay40WgbqZSUHizX1GvLGB+UwO6HK/omwxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638853; c=relaxed/simple; bh=MPz5NGp6KSHo+FNsG1J/2SvyUNxvLsebcp3fNO2e0Hs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DO2DL8J54fCvyEMy9zEyE+25jzkLCL2yqbiWVRSWsEJSgHycSxwWWQ1N0tR+nBCTxvN5XhsW3oGaZpFNO5GCfuyGMwybkjuQQQvM5Z2nlcUSljgXyOaD8znCHXNBuOMuCrPddjLeFatRWW5773mT6FWpPtcCgfw3Zv+vVmc5UAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SQBiM9Xl; 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="SQBiM9Xl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F40AC4CEC3; Fri, 11 Oct 2024 09:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638852; bh=MPz5NGp6KSHo+FNsG1J/2SvyUNxvLsebcp3fNO2e0Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SQBiM9XlMOYbuQf49/npFSlvAprEHOQzWumE+187h7E54mwj4KpyIXDANEutyWK8e UhHsm6WagB01cWHtEzoz8w8gme/Sg+MBaHzafr0omXY75KkHay0iZBfvwZOqziVjxW DahxDRufUFB3dxEl5rLeiTEsy+EAVNCGJzuEasNg1rqw3igX7WmbLH3U34w0sRVWGg BiuluJ8l07//U0ZpSc5OiK1w5uNrEivdF+jt+ff1zNuM5Oq/ffjThEIT5ylE+jJ0+c HRUJRNUADgduSdwhK2iXXUJ+roDPYCgJ9LGBPwJg6rNSkNrrSCkVQ6boIRDivPZkgh 1J/4hAet6U+Ow== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 02/11] Squash to "bpf: Add bpf_mptcp_sched_ops" Date: Fri, 11 Oct 2024 17:27:14 +0800 Message-ID: <80944f1737be11dede7bd842f5121c6a0e14dd69.1728638310.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 Please update the subject to bpf: Add mptcp packet scheduler struct_ops A small cleanup. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 681a76f7c6a8..d0758479318c 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -18,9 +18,12 @@ #ifdef CONFIG_BPF_JIT static struct bpf_struct_ops bpf_mptcp_sched_ops; -static const struct btf_type *mptcp_sock_type, *mptcp_subflow_type __read_mostly; +static const struct btf_type *mptcp_sock_type, + *mptcp_subflow_type __read_mostly; static u32 mptcp_sock_id, mptcp_subflow_id; +/* MPTCP BPF packet scheduler */ + static const struct bpf_func_proto * bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) From patchwork Fri Oct 11 09:27:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832274 X-Patchwork-Delegate: mat@martineau.name 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 D4DEA804 for ; Fri, 11 Oct 2024 09:27:34 +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=1728638854; cv=none; b=Ey1tezY47olB/z9kwPLpUi+s02+yNA2OiZL+hEAsx7SeEz1GlIMLAb2osaU9JrdBGgzT8cXV8ZBunbK21ioXk7EYRqVLNoaAJTbBCpheQtlWC0wATA/HiVqXk4rsA5YyTYD4/3ckicJ8KJmoBNx6EC5GpRkEYJwNJYVcA8p2OAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638854; c=relaxed/simple; bh=dqyKSa2X/SjqFL0EQzoi2GNrNFplqJmrTVD+PETjlsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TxBhMF2PsRa54koqOgqeGzZ+yZp+OGidVvvlZK4pRlEUWFVtRT2f6pXHy8TQkRSse+/Q9a1ZLeGO5tIJ9T4Szv2tYgRtoYwBfG6Bnykd4a5f7yMZiClk8jJoTgqRUoUz1Qo8DgMufVhh9fChN05g3Si+JdrdE/nmZwKTihXrgRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rLOJVb1n; 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="rLOJVb1n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29669C4CEC3; Fri, 11 Oct 2024 09:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638854; bh=dqyKSa2X/SjqFL0EQzoi2GNrNFplqJmrTVD+PETjlsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLOJVb1nZuHWKJHh+tpz8DfdV5W47RNu30ZfuzXg8GEhzXY8ze44pgDaIHm6gnRxk MSv8Yt+/2qCIUGB/cxwQa2ULxXhvzAZ/oDhZAAf6uFHL2hmKBcqMzuJSoh7hkMwElF TaJ8QIY+XWU2PdTvL5PodE+WbVNxirbj/pkU8ETAww8LumCxQsF9X2Vuaj8VMfYtu3 ktn/1Xm3jnRl5vP4fhBmdoRkQWIrWZDuxBVyaC/eCvd/s/gV4kSvh9cQ5B3H09wk9Q THLo5v30lXyW97OjYROIlyv/7Csjko0WSoQjvkPgfsb+IlnOYG4FY1h4fYDBD6AnYn rtdUqIRfSCOtg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 03/11] Revert "bpf: Add bpf_mptcp_sched_kfunc_set" Date: Fri, 11 Oct 2024 17:27:15 +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 Remove bpf_mptcp_subflow_ctx_by_pos from kfunc_set, it becomes empty now. Drop this patch. It should be registered in the commit "bpf: Export more bpf_burst related functions" Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index d0758479318c..22caff1d4dc2 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -298,19 +298,13 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { .set = &bpf_mptcp_common_kfunc_ids, }; -BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids) -BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) +/* BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) BTF_ID_FLAGS(func, tcp_stream_memory_free) BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty) BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale) -BTF_KFUNCS_END(bpf_mptcp_sched_kfunc_ids) - -static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = { - .owner = THIS_MODULE, - .set = &bpf_mptcp_sched_kfunc_ids, -}; +*/ static int __init bpf_mptcp_kfunc_init(void) { @@ -319,8 +313,6 @@ static int __init bpf_mptcp_kfunc_init(void) ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set); ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_mptcp_common_kfunc_set); - ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, - &bpf_mptcp_sched_kfunc_set); #ifdef CONFIG_BPF_JIT ret = ret ?: register_bpf_struct_ops(&bpf_mptcp_sched_ops, mptcp_sched_ops); #endif From patchwork Fri Oct 11 09:27:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832275 X-Patchwork-Delegate: mat@martineau.name 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 A516220C476 for ; Fri, 11 Oct 2024 09:27:36 +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=1728638856; cv=none; b=jzSw3/gsU9kELuU2niQ4DDenVfm6XJJgkwRVALK8Gn27bOZUmrhQqQAMG8PsRR1h1jGxLqwO8fqDP0XST+DUuXSha8bB4Ne3CMaz3v4cq57CNVYa2BOw2V6mblliK6jjhvbQD6L66tqvLKZ6HMJENpHywM/Kw/6ZfO0QFoQEBrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638856; c=relaxed/simple; bh=LBbhZRE7O7iOP8AKfoYUNWYs3cuAD5rsHQ/AU3RUl5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eK4o5zf2WwVphyQF59dtUN/GlRceckithjYAZiIdI3HD+i8oyN+mOuxaPnbrMFMvXtpFtOeh1/YjKCxgDouOvk7SLMDpANQxtmZXMKDeNXFEKO1rUAB3WoY6IYRfzU3aiTRp8+WjXl8S4Md3C15ZZoorn6ilMPhuTe1ljkdGOzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFUuTKHj; 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="jFUuTKHj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02F91C4CECD; Fri, 11 Oct 2024 09:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638856; bh=LBbhZRE7O7iOP8AKfoYUNWYs3cuAD5rsHQ/AU3RUl5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFUuTKHjROqcTTfJz9RNSZKn1cUh7ysQGHaJSizyKnw/LihcCQ67xViK47dfYnuyb WN4PAraT9vKssB3zV0430SpgP2Wi984yzgG0767CVlKR3Jdgq/72JH2aihsu+aKOZc Kl1whKCl2W/EU1JEvgChX4aDh8LBPV8PkFkU7dyMSPoaW7Gz0WYCNB0GX5VKGUOorD J4zhoCn/NAtPvyLxXp74PeYl47+7DQBabaHLJpyvZeZj+RB999w2BKxlaEgj/uM7HQ I1dB4xILtN+GYoTcaFJIKdui2WRCEKwc1MxIwxlBjDcWoxMd9rHaWhqcTl0b/VFLDn aPcqyYvzJeprg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 04/11] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Fri, 11 Oct 2024 17:27:16 +0800 Message-ID: <97864eb1d930372274275801a85dd674549931bc.1728638310.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 Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf.h | 3 --- tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/selftests/bpf/progs/mptcp_bpf.h index e18796361394..260bc239655a 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -55,7 +55,4 @@ bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym; extern struct sock * bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym; -extern struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos) __ksym; - #endif diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c index d57399b407a7..807685b3ab97 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c @@ -20,7 +20,13 @@ SEC("struct_ops") int BPF_PROG(bpf_first_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, 0), true); + struct mptcp_subflow_context *subflow; + + bpf_for_each(mptcp_subflow, subflow, msk) { + mptcp_subflow_set_scheduled(subflow, true); + break; + } + return 0; } From patchwork Fri Oct 11 09:27:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832276 X-Patchwork-Delegate: mat@martineau.name 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 7934B1F942F for ; Fri, 11 Oct 2024 09:27:38 +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=1728638858; cv=none; b=PjRTNMobFmn7h2mpTU1/+/ceaJ2nfGL9xSXjhLRXcxr15cqD9DVpLj6WbmpoH/UMMQU0fUI1nQgz/ckDdbzsGejqQHGMGkL/yDVKbFEZcozwgEM7ZAQJn8hJ7Hcc05RO/sp7FEFQaYDNV6zPmhHJK9zSNmpKudetkuzM6BMpnqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638858; c=relaxed/simple; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M9OEil99tkKftk3WEqPVrkQ22+XVYCK0m/D07wpChpTH0DucwYdJyQ5pgS7buR/zyfvSU67xZP9L2ZxZJO/we5wcR3mQkFUO0WeSM69CVxFfdGQVwOGp3tsSWvpe8yW58hFiNLuPUQt3bQwFAA6P7YqDfb3PA6LpIy2P4oq0gu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AZgM/JmZ; 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="AZgM/JmZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1957C4CEC3; Fri, 11 Oct 2024 09:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638858; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZgM/JmZdGew6ilMrrMLUN8Lipr0MF/aHkIofphr3H53Iwas8pDvoTfTxT7l50axR HIkor/5r2RZ2Srg+U7hM2N9Xdk6yjl4c2LS1124psoyvQoZcrfcHEHEIaZXCTgWalk Hin1yL1shkM8oL7D2ts3FCOhzD+BN9ocJ1i0hRklg1Sg7Qb+TPDmDBGtDDNccVS3ps J6z5qhhY6SmnCltbp76F2XY9AH7Io40CSw1Up9bgJdI/PVO//+Ft1F6e10ZWFgDH6J NA5/VtHX0oRvMZlXWa98cklX5KuJPANLiDP4x/4uy3rYRnxLC4LGWnUQ2eoxZFXYyx 0P3bI4vczQhwQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 05/11] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Fri, 11 Oct 2024 17:27:17 +0800 Message-ID: <035577c49107a9a76c8d1f509743c22c0d33514d.1728638310.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 Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c index 296f0318d843..70c3a69d4a47 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c @@ -20,26 +20,16 @@ SEC("struct_ops") int BPF_PROG(bpf_bkup_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - int nr = -1; - - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - struct mptcp_subflow_context *subflow; - - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + struct mptcp_subflow_context *subflow; + bpf_for_each(mptcp_subflow, subflow, msk) { if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) || !BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) { - nr = i; + mptcp_subflow_set_scheduled(subflow, true); break; } } - if (nr != -1) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, nr), true); - return -1; - } return 0; } From patchwork Fri Oct 11 09:27:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832277 X-Patchwork-Delegate: mat@martineau.name 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 4FB83804 for ; Fri, 11 Oct 2024 09:27:39 +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=1728638861; cv=none; b=A2NMFwjxoT1jGz103mvZuhFjX00kBpLH1OnuyP5h2CNYTyIvNrvHJ92aiWyEUuyM4KVPwpgEaCgfyMVtTKwejeo0YisnUOL/XLM4F6742zB8uBh4fkbHprykSGg1lkXYKdiu/W9oybZ44UACAHq0P4WE8Sh5MWEfLUxDUfHky+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638861; c=relaxed/simple; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ssX2hb0TUbx9oNSbTOjkV8mfP3MLe2DOo9GRjLoxRAmk5Zikg7asJ2p8je0WPID1+VolsbiAKumbFKF5i/RQtzYTxD2orW7G4g49RA0s0GfKtwbzbrEopwGnsW1JQn9CUc/hcElfeevjnaa/RDyuKLM4fExmqfj2OUvpKB9T4vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LzmKKxZn; 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="LzmKKxZn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC239C4CEC3; Fri, 11 Oct 2024 09:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638859; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LzmKKxZnJ2mYegez/LQdDDlkdzxOlqi624g8uxumoj91mG5DlFACa7n8VrSG2wMp2 ceoZXIjK7ad7zcmEYHZLRrLezcrMmH7uODnnvvQXv6cVdD8NO7vGIFrXcLEDWJPPlE FpXzi4Dm2UZThkECeYh50EXq6ZGDH3rk5ODQ2xQGeTULTlFGzDBsygPDQbqZUCP34l kEmHY+FrW0Ls1aLizAvOYrKMb08ObBdIpMatv65Oz0OJ3AalXkx3bWt38s4keNitJS vCqvr4IYSIoFTO4ksauDg8xLcGv1R7XLYpW7sN/ciOwvU5GwiBVecVdNgNoISsgiYM Q71LnmW2rm7WA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 06/11] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Fri, 11 Oct 2024 17:27:18 +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 Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_rr.c | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c index 638ea6aa63b7..0e806caa10df 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -34,10 +34,9 @@ SEC("struct_ops") int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - struct mptcp_subflow_context *subflow; + struct mptcp_subflow_context *subflow, *next; struct mptcp_rr_storage *ptr; struct sock *last_snd = NULL; - int nr = 0; ptr = bpf_sk_storage_get(&mptcp_rr_map, msk, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); @@ -45,27 +44,24 @@ int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk, return -1; last_snd = ptr->last_snd; + next = bpf_mptcp_subflow_ctx(msk->first); - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!last_snd || !subflow) + bpf_for_each(mptcp_subflow, subflow, msk) { + if (!last_snd) break; - if (mptcp_subflow_tcp_sock(subflow) == last_snd) { - if (i + 1 == MPTCP_SUBFLOWS_MAX || - !bpf_mptcp_subflow_ctx_by_pos(data, i + 1)) + if (bpf_mptcp_subflow_tcp_sock(subflow) == last_snd) { + subflow = bpf_iter_mptcp_subflow_next(&___it); + if (!subflow) break; - nr = i + 1; + next = subflow; break; } } - subflow = bpf_mptcp_subflow_ctx_by_pos(data, nr); - if (!subflow) - return -1; - mptcp_subflow_set_scheduled(subflow, true); - ptr->last_snd = mptcp_subflow_tcp_sock(subflow); + mptcp_subflow_set_scheduled(next, true); + ptr->last_snd = bpf_mptcp_subflow_tcp_sock(next); return 0; } From patchwork Fri Oct 11 09:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832278 X-Patchwork-Delegate: mat@martineau.name 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 1D96B804 for ; Fri, 11 Oct 2024 09:27:41 +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=1728638862; cv=none; b=naoPHZhpTj674vRpsC0n+7sGlhibeoss9uWz6FUStpZu0O3NTMoVT9v77Pbd8se06+Olb6TPwQWcBoq6GW/bSzBOcThHuwKFK1E+YJK6yAfLU84aKja/Q80Sualtq3I9ogSzQ1U37YKliTJn5T0gtgjhQKXTZguAp4ODcSlZBKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638862; c=relaxed/simple; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qAF/iX6fsoMlwOtplgLo08slRv3CWUXpzTZIUeXvCXEamZ1F1zThU0mM74E8HGSmvqELq/zG2/5yJEYfSO2y8RoBzk5FOAsSrrtzZzFRqCdRJtbmD/+WUSPGrVBHNTsieudaUn1EXffr/ABMtdMABT40NFE02xthaI9PdK2V7GA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YOn1jhtd; 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="YOn1jhtd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BACFC4CECC; Fri, 11 Oct 2024 09:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638861; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOn1jhtdfGqUO2fwplNJuoa1R2Bge06iHJbQeFCXK0ri4EIU7QUztnmZSqU9ZncXP bZEvne0nI3MwNlNGombppnpmTRhS9cuc38jBD0Q3SYzmxK6BH5NCZOjheYmBlmXj4P TxG9augyKxWPpmXlr0UjR20nwU/WrWOSsEIuChvOMEGHk24g4MfMlLOWGVNDJwQV5/ czmbh7Kkdje6WlEuhCpr0FW5dmMH3YauG9Eekcyj9PJdFHaB8GhPpQmiHnBbxB749J XEONfYqgDkQGpI4/STuglxHdQ5iDF2qNIWTgv9c68xE03BSJQEUk7I98rA3DSnkqHz O7wjWRpPX9G4Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 07/11] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Fri, 11 Oct 2024 17:27:19 +0800 Message-ID: <1a0868a3750d11e7055f8a39103ec0ede4a66918.1728638310.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 Use the newly added bpf_for_each() helper to walk the conn_list. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf_red.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c index cc0aab732fc4..ce19d604b898 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c @@ -20,12 +20,10 @@ SEC("struct_ops") int BPF_PROG(bpf_red_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - if (!bpf_mptcp_subflow_ctx_by_pos(data, i)) - break; + struct mptcp_subflow_context *subflow; - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, i), true); - } + bpf_for_each(mptcp_subflow, subflow, msk) + mptcp_subflow_set_scheduled(subflow, true); return 0; } From patchwork Fri Oct 11 09:27:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832279 X-Patchwork-Delegate: mat@martineau.name 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 BC555804 for ; Fri, 11 Oct 2024 09:27: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=1728638863; cv=none; b=fJZi8zjhzLIObrs0IcqCccjyMgXYmlXSsZrQqHPW13B9Kc8C7PYeAuv9HdGb/tehyOPfXbAL0rRDz94dS3H/G14XOy9wunr082lRbmjt3JTAg+Cd/2ZXQZR2HRTE0l/T2BZNIjE0fgalHsgVccAJI2oZNcTSi0DiE+CAxyIL2vI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638863; c=relaxed/simple; bh=YE5itFl4lhTWViAjN4W4BCvpGpKDQjjty5wErEoFtO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c0ONtHh0QeZuZ5cQpGLohDK5XT3MeX6u4BDL+bPxIa7F5E/uTL2LSWpl7QZs7cz8zn9VKsPA1vh+1OM5Zgtb9Wg2mK3hNI9ptvTaq2jrshwLtbb5hCmQ4zUgMsTzyr9QutHjDkaP8IKUQt4orkzL7lElk3z8j1uvBA/ek1Uue+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f/Encg0N; 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="f/Encg0N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45B41C4CEC3; Fri, 11 Oct 2024 09:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638863; bh=YE5itFl4lhTWViAjN4W4BCvpGpKDQjjty5wErEoFtO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/Encg0NpNcTVybK6JFcGJpv4vIiyd50wLMNawOfJnAveKIoaUfNPl67X3UozTk5e jktdst2zeYf8cXGRgIkjbyjtqclQUdwrJfmdt1BBQaXOO2Uis21LX+e9A0X9v4wJZE 4u0a3hgTGRQgwxdnD07q3uRANvmy3nb50ZDmMdGOFPPPumzFxao/S6M/ZI5TzQzjUD DxG+D8/Dnznf3hGeg5dMRqPqDs4ZvZXmedLkM74Xh2H+tie/WfphX7stuUy4UOg9hf rC2ahLOgkG87fv+z1tPxvkD+0iuVP4ldNBpS2sNb6RwPLT/r6daZ3WGdhmozPNHDQX fe3GFngVE8Ovw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 08/11] Squash to "bpf: Export more bpf_burst related functions" Date: Fri, 11 Oct 2024 17:27:20 +0800 Message-ID: <4975c10ed967386a8281166b1482d5539777f0ee.1728638310.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_subflow_queues_empty declaration. Register kfunc set again. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 11 +++++++++-- net/mptcp/protocol.h | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 22caff1d4dc2..6893d908d3c7 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -298,13 +298,18 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { .set = &bpf_mptcp_common_kfunc_ids, }; -/* +BTF_KFUNCS_START(bpf_mptcp_sched_kfunc_ids) BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) BTF_ID_FLAGS(func, tcp_stream_memory_free) BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty) BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale) -*/ +BTF_KFUNCS_END(bpf_mptcp_sched_kfunc_ids) + +static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = { + .owner = THIS_MODULE, + .set = &bpf_mptcp_sched_kfunc_ids, +}; static int __init bpf_mptcp_kfunc_init(void) { @@ -313,6 +318,8 @@ static int __init bpf_mptcp_kfunc_init(void) ret = register_btf_fmodret_id_set(&bpf_mptcp_fmodret_set); ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_mptcp_common_kfunc_set); + ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, + &bpf_mptcp_sched_kfunc_set); #ifdef CONFIG_BPF_JIT ret = ret ?: register_bpf_struct_ops(&bpf_mptcp_sched_ops, mptcp_sched_ops); #endif diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e774f28a6f8d..7848a1989d17 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -722,7 +722,6 @@ void mptcp_subflow_queue_clean(struct sock *sk, struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); u64 mptcp_wnd_end(const struct mptcp_sock *msk); void mptcp_set_timeout(struct sock *sk); -bool bpf_mptcp_subflow_queues_empty(struct sock *sk); struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); From patchwork Fri Oct 11 09:27:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832280 X-Patchwork-Delegate: mat@martineau.name 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 51781804 for ; Fri, 11 Oct 2024 09:27: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=1728638865; cv=none; b=CTfsjGDcHJNUWqWjEjSZ8YrLlsdYiCFaMzep1aC3wiP+PFNUHKcBWm9tluiyG2fHO84KASBNgAlQ4G4pqtAJbIUZR6SE7/gQzOO5nCRyV/w6ANfLGxgMQ4+wVq8oNyQtvLr+0Dk62Bxrjof4Cq52vcIOSAECXVAtdeoiPjf6Ma8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638865; c=relaxed/simple; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WqtdsfQDSfPeKo48JupKZlzk9ErZ/0kuc1bNgpA6VtEbgqFmDi7B32Zdy5Mx6BsDW50YvVODL9UWtf3BGs76wwih8coyT1c67uzcrvd/SiNbXayDMNL1ftEN6FophTNFq6xPJMT5EdRRcL9uMPWn7Re/ZALK2GkRVU8i7y2+sL8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N4ViUa1u; 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="N4ViUa1u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0671EC4CEC3; Fri, 11 Oct 2024 09:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638865; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4ViUa1uu4exl1MmQkfS0iq4Gwowdg37g52CBkBYZlcFOeIdL4UyoSWR/CLrEosmr wOSSN1ArOFcWhjpbgO4XD6sF6To6fC4F0AMc65MqX1jSvrSm8g4R6enzERHY7kKDJ3 s+28T42eLZ4Xyu0CC+Gey2DbR7oWXPuUp7aE11uaztayiDZuqYnqNUMayHNC7xGjqz arYJW18Z+baTiVUGLuzufqFjPof4V/rBO3VQakFDEgmvOYZSB8hZmxpKZFP4Qjizx1 1CxYJfbrgLINsyczBxpcpjKuG16+xtlS+H0La0FbLMBicWSpv5C2xBpi0mN6HB1BjH FMKM/RWZLs0ZQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 09/11] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Fri, 11 Oct 2024 17:27:21 +0800 Message-ID: <2237ddff8cae3683817284f57ee98f491f01cabc.1728638310.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 Use the newly added bpf_for_each() helper to walk the conn_list. Drop mptcp_subflow_active declaration. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_burst.c | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c index eb21119aa8f7..87b6d9dc876b 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -11,22 +11,21 @@ char _license[] SEC("license") = "GPL"; #define min(a, b) ((a) < (b) ? (a) : (b)) +#define SSK_MODE_ACTIVE 0 +#define SSK_MODE_BACKUP 1 +#define SSK_MODE_MAX 2 + struct bpf_subflow_send_info { __u8 subflow_id; __u64 linger_time; }; -extern bool mptcp_subflow_active(struct mptcp_subflow_context *subflow) __ksym; extern void mptcp_set_timeout(struct sock *sk) __ksym; extern __u64 mptcp_wnd_end(const struct mptcp_sock *msk) __ksym; extern bool tcp_stream_memory_free(const struct sock *sk, int wake) __ksym; extern bool bpf_mptcp_subflow_queues_empty(struct sock *sk) __ksym; extern void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) __ksym; -#define SSK_MODE_ACTIVE 0 -#define SSK_MODE_BACKUP 1 -#define SSK_MODE_MAX 2 - static __always_inline __u64 div_u64(__u64 dividend, __u32 divisor) { return dividend / divisor; @@ -57,6 +56,19 @@ static __always_inline bool sk_stream_memory_free(const struct sock *sk) return __sk_stream_memory_free(sk, 0); } +static struct mptcp_subflow_context * +mptcp_lookup_subflow_by_id(struct mptcp_sock *msk, unsigned int id) +{ + struct mptcp_subflow_context *subflow; + + bpf_for_each(mptcp_subflow, subflow, msk) { + if (subflow->subflow_id == id) + return subflow; + } + + return NULL; +} + SEC("struct_ops") void BPF_PROG(mptcp_sched_burst_init, struct mptcp_sock *msk) { @@ -67,8 +79,7 @@ void BPF_PROG(mptcp_sched_burst_release, struct mptcp_sock *msk) { } -static int bpf_burst_get_send(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int bpf_burst_get_send(struct mptcp_sock *msk) { struct bpf_subflow_send_info send_info[SSK_MODE_MAX]; struct mptcp_subflow_context *subflow; @@ -84,16 +95,10 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, send_info[i].linger_time = -1; } - for (i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - bool backup; + bpf_for_each(mptcp_subflow, subflow, msk) { + bool backup = subflow->backup || subflow->request_bkup; - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; - - backup = subflow->backup || subflow->request_bkup; - - ssk = mptcp_subflow_tcp_sock(subflow); + ssk = bpf_mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) continue; @@ -109,7 +114,7 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, linger_time = div_u64((__u64)ssk->sk_wmem_queued << 32, pace); if (linger_time < send_info[backup].linger_time) { - send_info[backup].subflow_id = i; + send_info[backup].subflow_id = subflow->subflow_id; send_info[backup].linger_time = linger_time; } } @@ -119,10 +124,10 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, if (!nr_active) send_info[SSK_MODE_ACTIVE].subflow_id = send_info[SSK_MODE_BACKUP].subflow_id; - subflow = bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE].subflow_id); + subflow = mptcp_lookup_subflow_by_id(msk, send_info[SSK_MODE_ACTIVE].subflow_id); if (!subflow) return -1; - ssk = mptcp_subflow_tcp_sock(subflow); + ssk = bpf_mptcp_subflow_tcp_sock(subflow); if (!ssk || !sk_stream_memory_free(ssk)) return -1; @@ -141,23 +146,18 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, return 0; } -static int bpf_burst_get_retrans(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int bpf_burst_get_retrans(struct mptcp_sock *msk) { - int backup = MPTCP_SUBFLOWS_MAX, pick = MPTCP_SUBFLOWS_MAX, subflow_id; + struct sock *backup = NULL, *pick = NULL; struct mptcp_subflow_context *subflow; int min_stale_count = INT_MAX; - struct sock *ssk; - for (int i = 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow = bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + bpf_for_each(mptcp_subflow, subflow, msk) { + struct sock *ssk = bpf_mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) continue; - ssk = mptcp_subflow_tcp_sock(subflow); /* still data outstanding at TCP level? skip this */ if (!tcp_rtx_and_write_queues_empty(ssk)) { mptcp_pm_subflow_chk_stale(msk, ssk); @@ -166,23 +166,23 @@ static int bpf_burst_get_retrans(struct mptcp_sock *msk, } if (subflow->backup || subflow->request_bkup) { - if (backup == MPTCP_SUBFLOWS_MAX) - backup = i; + if (!backup) + backup = ssk; continue; } - if (pick == MPTCP_SUBFLOWS_MAX) - pick = i; + if (!pick) + pick = ssk; } - if (pick < MPTCP_SUBFLOWS_MAX) { - subflow_id = pick; + if (pick) goto out; - } - subflow_id = min_stale_count > 1 ? backup : MPTCP_SUBFLOWS_MAX; + pick = min_stale_count > 1 ? backup : NULL; out: - subflow = bpf_mptcp_subflow_ctx_by_pos(data, subflow_id); + if (!pick) + return -1; + subflow = bpf_mptcp_subflow_ctx(pick); if (!subflow) return -1; mptcp_subflow_set_scheduled(subflow, true); @@ -194,8 +194,8 @@ int BPF_PROG(bpf_burst_get_subflow, struct mptcp_sock *msk, struct mptcp_sched_data *data) { if (data->reinject) - return bpf_burst_get_retrans(msk, data); - return bpf_burst_get_send(msk, data); + return bpf_burst_get_retrans(msk); + return bpf_burst_get_send(msk); } SEC(".struct_ops") From patchwork Fri Oct 11 09:27:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832281 X-Patchwork-Delegate: mat@martineau.name 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 82CAE804 for ; Fri, 11 Oct 2024 09:27:47 +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=1728638867; cv=none; b=Jl7prsf7O8rSceQQHuNdUQ5mpexxT6IyWw/o1w//uhnzMIAhRnZxNnXHmE1yZfUUeUOOSdwFPiVrONbRykj3vt8EKDlboEr2f9Qbm6z7wgywU+BT3BLAPcbqS238BLWRqLzS9+uWs0ES3pJl7P0+/XDHYzlGEq1LHKsuxkgZ9X4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638867; c=relaxed/simple; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ad7Z5agCM0mnPgQjFf7uwjqtW433YRJaOzeXgxO/olwDUkK+Oe4611ABr2OAedK9b4u5mIUUZd7rdgqEWzrZbpkL2X6SZ1Uu6hfaoTrkG90D7IpzgmSLYSCb0Rw/flqUGvf7JgqAJKdUIk9NIZcf0aAO6Y0uoaaPxodo6Ffg9mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=umX+85QU; 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="umX+85QU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D465BC4CEC3; Fri, 11 Oct 2024 09:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638867; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=umX+85QUxec6rRDkPcWITBLBE1pZQFteeuHIhrFFx/5wF9pmOK0XQmZgTbzUh3Rlh vgzAuTpHrkO6Y/0iJftAt0QyaNISJIk7WgqvkZjd6X4AotwhotOQ1P6YBkH9Y4w6rE ck81v0giqF9Z8cIYf9yDVbL3MPu2vb5OmPEfqhiwGSz8UNAfnemYS/uKO+woFiBBX8 cdBoge7hvdvsuyvX/NXbx6gpKmzn9g4oWW8nSf5o1NFw+5tzJq0mtjfjmq+5/c8qsP 6IqsWxYoIl+lwSd5Fe5WQ5yLoZ6KKRmDertA3YMTTIfPB4lQ+mEJD5gWHIvPpKZ5gW 48G/QIBFg9r9Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 10/11] mptcp: drop subflow contexts in mptcp_sched_data Date: Fri, 11 Oct 2024 17:27:22 +0800 Message-ID: <6542c05c6e5f2d18b9a4845900b716a075bdbcbe.1728638310.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 The mptcp_subflow bpf_iter is added now, it's better to use the helper bpf_for_each(mptcp_subflow) to traverse all subflows on the conn_list of an MPTCP socket and then call kfunc to modify the fields of each subflow in the WIP MPTCP BPF packet scheduler examples, instead of converting them to a fixed array. With this helper, we can get rid of this subflow array "contexts" and the size of it "subflows" in struct mptcp_sched_data. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 814b5f2e3ed5..84d67947a517 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -104,8 +104,6 @@ struct mptcp_out_options { struct mptcp_sched_data { bool reinject; - u8 subflows; - struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX]; }; struct mptcp_sched_ops { From patchwork Fri Oct 11 09:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13832282 X-Patchwork-Delegate: mat@martineau.name 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 4FDDD20C476 for ; Fri, 11 Oct 2024 09:27:49 +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=1728638869; cv=none; b=fGDraJpsNECFDx+qyguD5iIRfMiktXqPUQYqoyrcG3XDOSJxdlHoa93B9b9hefjfK8pVKGOVpStq7UknSw5SqUrbWlKK+4oXqIVlKUzkv9P8nXJ5Mv8crzrjQtDpfnB+xx4mmTo02J1cJu+KT4PjvpJw6VJmfxyETv1mWeGUUvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728638869; c=relaxed/simple; bh=VIVEwNvERqY60UURI9H4hBSdCZTchsvxsrk48ITuZgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aAyd92f+1aS0OFOyvGHDGJAmIFl8VvElz4/+IxUcVuWBjOpM8MEVhakHjPOGaj0skNO9z77y4jFc2ExsLaa5QeSznR2dYcNSAGfc8KMu5SglrU6kr0yftSv1XlGI/INtSQu83GYx2krNdQpk6/PorEyWl7CCXBQ41PKHcWW8ors= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rK5dTSEX; 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="rK5dTSEX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADB95C4CEC3; Fri, 11 Oct 2024 09:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728638868; bh=VIVEwNvERqY60UURI9H4hBSdCZTchsvxsrk48ITuZgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rK5dTSEXr5yukIPD7rayMIbZeMXxW5JJGqMynVwXrHUut3iknxo/5Uw4Hh+K9IRfp 8KM2EhOqQROare/yVkF6Tazif7sORSDbW2ngLVbXjLpih6iF1BFTFplPeJ8N+dkOS3 Ns6BbJXqZS8zv5Oly1e/J9c4aBZUJz5eXqtt9XwaLsEfA0MwBMK1ODJ7KYE3aLbTr7 3Pya7AAk/E/o1PJ+faVmQFSBDY0z79A0NBrskN8VO9Qn9N4siRuBURx2zUhlyjNhOb +mL+eKnyQVfiKEFVTEPNggVE3MdR4qMkNdHmkiqCJCMz9C3AQ5fYi6CDV+NugOKTLR JCKEXFAABszqg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v4 11/11] Squash to "selftests/bpf: Add bpf scheduler test" - drop has_bytes_sent Date: Fri, 11 Oct 2024 17:27:23 +0800 Message-ID: <04df0caa392166278d9fa1f3900ddc27433467c5.1728638310.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 ss_search() and has_bytes_sent(), add a new bpf program to check the bytes_sent. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 48 ++++++++++--------- .../selftests/bpf/progs/mptcp_bpf_bytes.c | 39 +++++++++++++++ 2 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_bytes.c diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 2738951842f6..cb0511e62df8 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -12,6 +12,7 @@ #include "mptcpify.skel.h" #include "mptcp_subflow.skel.h" #include "mptcp_bpf_iters_subflow.skel.h" +#include "mptcp_bpf_bytes.skel.h" #include "mptcp_bpf_first.skel.h" #include "mptcp_bpf_bkup.skel.h" #include "mptcp_bpf_rr.skel.h" @@ -603,56 +604,59 @@ static struct nstoken *sched_init(char *flags, char *sched) return NULL; } -static int ss_search(char *src, char *dst, char *port, char *keyword) -{ - return SYS_NOFAIL("ip netns exec %s ss -enita src %s dst %s %s %d | grep -q '%s'", - NS_TEST, src, dst, port, PORT_1, keyword); -} - -static int has_bytes_sent(char *dst) -{ - return ss_search(ADDR_1, dst, "sport", "bytes_sent:"); -} - static void send_data_and_verify(char *sched, bool addr1, bool addr2) { + int server_fd, client_fd, err; + struct mptcp_bpf_bytes *skel; struct timespec start, end; - int server_fd, client_fd; unsigned int delta_ms; + skel = mptcp_bpf_bytes__open_and_load(); + if (!ASSERT_OK_PTR(skel, "open_and_load: bytes")) + return; + + skel->bss->pid = getpid(); + + err = mptcp_bpf_bytes__attach(skel); + if (!ASSERT_OK(err, "skel_attach: bytes")) + goto skel_destroy; + server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); if (!ASSERT_OK_FD(server_fd, "start_mptcp_server")) - return; + goto skel_destroy; client_fd = connect_to_fd(server_fd, 0); if (!ASSERT_OK_FD(client_fd, "connect_to_fd")) - goto fail; + goto close_server; if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) - goto fail; + goto close_client; if (!ASSERT_OK(send_recv_data(server_fd, client_fd, total_bytes), "send_recv_data")) - goto fail; + goto close_client; if (clock_gettime(CLOCK_MONOTONIC, &end) < 0) - goto fail; + goto close_client; delta_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000; printf("%s: %u ms\n", sched, delta_ms); if (addr1) - CHECK(has_bytes_sent(ADDR_1), sched, "should have bytes_sent on addr1\n"); + ASSERT_GT(skel->bss->bytes_sent_1, 0, "should have bytes_sent on addr1"); else - CHECK(!has_bytes_sent(ADDR_1), sched, "shouldn't have bytes_sent on addr1\n"); + ASSERT_EQ(skel->bss->bytes_sent_1, 0, "shouldn't have bytes_sent on addr1"); if (addr2) - CHECK(has_bytes_sent(ADDR_2), sched, "should have bytes_sent on addr2\n"); + ASSERT_GT(skel->bss->bytes_sent_2, 0, "should have bytes_sent on addr2"); else - CHECK(!has_bytes_sent(ADDR_2), sched, "shouldn't have bytes_sent on addr2\n"); + ASSERT_EQ(skel->bss->bytes_sent_2, 0, "shouldn't have bytes_sent on addr2"); +close_client: close(client_fd); -fail: +close_server: close(server_fd); +skel_destroy: + mptcp_bpf_bytes__destroy(skel); } static void test_default(void) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bytes.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_bytes.c new file mode 100644 index 000000000000..95770b0ebcf0 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bytes.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024, Kylin Software */ + +/* vmlinux.h, bpf_helpers.h and other 'define' */ +#include "bpf_tracing_net.h" +#include "mptcp_bpf.h" + +char _license[] SEC("license") = "GPL"; +u64 bytes_sent_1 = 0; +u64 bytes_sent_2 = 0; +int pid; + +SEC("fexit/mptcp_sched_get_send") +int BPF_PROG(trace_mptcp_sched_get_send, struct mptcp_sock *msk) +{ + struct mptcp_subflow_context *subflow; + + if (bpf_get_current_pid_tgid() >> 32 != pid) + return 0; + + if (!msk->pm.server_side) + return 0; + + mptcp_for_each_subflow(msk, subflow) { + struct tcp_sock *tp; + struct sock *ssk; + + subflow = bpf_core_cast(subflow, struct mptcp_subflow_context); + ssk = mptcp_subflow_tcp_sock(subflow); + tp = bpf_core_cast(ssk, struct tcp_sock); + + if (subflow->subflow_id == 1) + bytes_sent_1 = tp->bytes_sent; + else if (subflow->subflow_id == 2) + bytes_sent_2 = tp->bytes_sent; + } + + return 0; +}