From patchwork Wed Oct 9 10:29:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828126 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 467AB18E379 for ; Wed, 9 Oct 2024 10:29:59 +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=1728469800; cv=none; b=AKgMilGcOzqQmjtjWUqg8ia8KxxxLiWJMQIhwxnvnH/kwN+le/arVDP2BH07+h/VRzBT32a75xccsaCTv5x4fv1wIRP38ITgqBq85FKPXrr6Z6bNl4RqwRxa4BO7oMRChA1pratQSVESghIyoKlGP4RDI1gouCOpchjkBn00EWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469800; c=relaxed/simple; bh=BYLxj6HL1RF/l2Xs2VVebQy5sbOBtOhVuu61yZVtQDc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y/onG/kKi38o0jkAssAPYG2z0muJS1XBgWhmaZqUo5pZtA6PWHveCUrrH0DkC2tjcpcxXhUzy3iL6kwUeGh5hocJAfAI422qDLXIwyuGqBCr/Av0lcuZRFfShhJg4U77bmg3y5itYn4D1mUpuawoMJzX0D8RVamtLLIwDuimuRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=INhFN/p5; 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="INhFN/p5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E7F9C4CEC5; Wed, 9 Oct 2024 10:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469799; bh=BYLxj6HL1RF/l2Xs2VVebQy5sbOBtOhVuu61yZVtQDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INhFN/p5msgqXutHnNvH6Lm6o3hLJ4OP7m7x36EnwlLdolZD3XpuUXt2vHRkJXklm kZLWwlS6QARWeYhk6Ta38YcNgOk4PFk3Lz04GkJGa0HVHhTnVJ2Na6EUfvM7bPKysu JsJMLZ6Bpi5ZNPKSCKut7Gs5uTYypDhMUJHNOBq5aLM5sPfcdvg4tKPdZ2LZCpPJlt SDJ50NOo4pJ9ocdZoSwYgszKP2XrTL3iU79DoZKAW030D2sCzG3SrfuX7MW/r0DfXU fdeN9F7ScMxR1+aUe4zErtKi+HNBvFOiLHWYjzQjnDsBmtmwowYnBwCcq1msgNNyv2 iyiig58XTsVZA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 01/10] Squash to "bpf: Add bpf_mptcp_sched_kfunc_set" Date: Wed, 9 Oct 2024 18:29:42 +0800 Message-ID: <0d009264ed09e2988eadae3c98a1926dd981a353.1728469555.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: Register mptcp struct_ops kfunc set" Rename bpf_mptcp_sched_kfunc_set to bpf_mptcp_struct_ops_kfunc_set, since this kfunc set will not only use in bpf packet schedulers, but also in other struct_ops like bpf path managers. Rename bpf_mptcp_subflow_ctx_by_pos to bpf_mptcp_lookup_subflow_by_id. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 9b87eee13955..c9aefe9eec14 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -303,18 +303,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_KFUNCS_START(bpf_mptcp_struct_ops_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) +BTF_KFUNCS_END(bpf_mptcp_struct_ops_kfunc_ids) -static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = { +static const struct btf_kfunc_id_set bpf_mptcp_struct_ops_kfunc_set = { .owner = THIS_MODULE, - .set = &bpf_mptcp_sched_kfunc_ids, + .set = &bpf_mptcp_struct_ops_kfunc_ids, }; static int __init bpf_mptcp_kfunc_init(void) @@ -325,7 +325,7 @@ static int __init bpf_mptcp_kfunc_init(void) 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); + &bpf_mptcp_struct_ops_kfunc_set); #ifdef CONFIG_BPF_JIT ret = ret ?: register_bpf_struct_ops(&bpf_mptcp_sched_ops, mptcp_sched_ops); #endif From patchwork Wed Oct 9 10:29:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828127 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 23F7118EFD6 for ; Wed, 9 Oct 2024 10:30:01 +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=1728469802; cv=none; b=n5s4o+AUxOB8mpRGrSQfDhBSDApQkLxWwqD/aZnzIomcWUcnZ1GBKNmZha5IJcCOMYRdz3iqPMCdlmh2PwJMrRswcY2uwAlSLXSInxYkQJpI2mFPOBe4v52/CtrfpQ3e8PwSVznvGWriG10G6yxTqNS3TqZbOnraGguum3JXEIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469802; c=relaxed/simple; bh=LBbhZRE7O7iOP8AKfoYUNWYs3cuAD5rsHQ/AU3RUl5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hS9nzTLDUIpF5NJPS8YZCpWiZVsBAPRYNCFWQ6fyY2DORF6f110YUnFmI7DnrbaFaZnPNjpj36w9a3/p5Y7ujSjH/Wo5J0H18f1yaas4lBR+yXNH1vlyvsx9nAtJY1rj2cucBH4ODfe0fcHw8LqIru24AlPTVJDNAxmgPFzLAaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i4qeH45g; 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="i4qeH45g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82037C4CEC5; Wed, 9 Oct 2024 10:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469801; bh=LBbhZRE7O7iOP8AKfoYUNWYs3cuAD5rsHQ/AU3RUl5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4qeH45gsBthlPVXhkB2iX3W1CjsW2h3WI61GrRySE2Vg6wsVkpE5FbV/D8aQjJ5F PV3eyPGVV1r5f+wz80GxZ7updiOMvgGig/frfjClmunVh8tVZZxon92s7xJQljeBAO j3OWafDFs68KAX+I46boI4pG0gU6jGE4awfrNc5KdxX1KdpJYSXC0OYI1zA+AVmiz+ gDz9J8NHVJ3LAuIixcLsg2K5YYjH9kS89+RAjDwh0hA2wBdBF8xDtbRLf6jQduivp6 xpMy4uvV92QseNyEoIKpuDSrm8AxcS0sekL2HkcYPGRsbgxP+VrNYwmOlY4pMTElUN 0M873HpaSReRg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 02/10] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Wed, 9 Oct 2024 18:29:43 +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 --- 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 Wed Oct 9 10:29:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828128 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 B0E4C18EFE0 for ; Wed, 9 Oct 2024 10:30:03 +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=1728469803; cv=none; b=UTfC3wQ5tzNwf1a1WbEywoXiTm5Kk+kFCsPrlyloarrshcD20djLDM/H9hEugE43ownvoIdT1h5RYmlnR8jzbsbOynAsFx+k71nV4bCEKP2bfUpm7b0HH7fsTvQjEzULYkjvqAQxbAq78cBpClFX6gwqdj5rmbCt1q7alCTtWng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469803; c=relaxed/simple; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RONKklk7LH1QaPmzEd7EMHDOScUM4wstRCtQdVgHS8vul4yVNne/n2356FYGq2I2bVmemIPLgj8ogXBI3RSTapqmeKC7xj6DlBfX6a376+MaHQho2NoQF4meNoPmSBVagC/yX3UViPlR440AwlvHTxBjvmVEUaDkyl1JZCSWYRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qx6WLqTT; 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="Qx6WLqTT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 420A8C4CECF; Wed, 9 Oct 2024 10:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469803; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qx6WLqTTZfJR8iRv161KoKRUrF+KcFQDf6o/TFw3ERx2IkLtJaN3foc/ooe6IYuXJ hV63DT4na9HWayQvIabEvoPGDFLhjE7HhpE3Y2mlIl4JKBTzTnt4MM+GpAIqiyzc2K 1x/s4TA4fFELOezwPglY29wOqdvBuNEvxSCS8CaXrZv9qaUP16gswDhNvleFHcV231 O86v9qa0k1GwzJ5c2+jz93fAa98S2kf5BWPd1TI7NvIcolPr4TZUjfBPSFzmfEuViP SFM9bKpdINwtQjn8jxe8pG9qAnbecM//+VcU5NO0pUwlTljkYapxk2y4oJy8z/JV6y PF8BmjrwQ07bg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 03/10] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Wed, 9 Oct 2024 18:29:44 +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 --- .../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 Wed Oct 9 10:29:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828129 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 5365E18EFEB for ; Wed, 9 Oct 2024 10:30:05 +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=1728469805; cv=none; b=RaczV3x3RdRGktZ5OUcdAYBT89GHc0+D+f7WZJl3W3vKPjRgOCTtYcCtZFHRIiDoYvv19A9ciyS+1CrGntSkbl+9RdpAdS0sZlse8nJAvttr9KKB/WRl73KnMpnkVjihER1/TI7ldNR85ha3kflfYyuUA8O+ywR8mJl8VNFGs1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469805; c=relaxed/simple; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=niWs9nr6/+UHRwiXw3GTIaruEmeb49crzk5MzeRypQrhXJ8RR/xdXrkm3pZuquNwuALhTn5fp+EGAQdZxWhz0dI5IqOGe5YkSIBesOJGBGyyaXKUlrwvkVw6Nh5c37864XwUywnhhorWEmfbAoPW/9pexpa8U2zo3YDj8wbkbGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=parVqNtI; 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="parVqNtI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4637C4CED4; Wed, 9 Oct 2024 10:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469805; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=parVqNtIm6AROjkh3dPQXKaZ7w9rfmig9cDYPG+tElgyCSzFCLOBcYyJWg9m0KPXp c9i9v4nDExQvKLYkqyf9m4kkH7d2oVuRTH/kaD9Drei+Nz48piaJKyQ/LfIF9USRcq MmaAncdafj6Mh4731AoJMDu7k7rpGZRrTDAYuDbFZvgEsRZ4ecWXJKnBuIzwWvdrfe KHmur9daXNIQpUtuRJoaataU5yNk4z3SdkCv8xCLRykBZOA7tcwOMM/RNNEMNeZqEI Iq0kHl/9FUNbTcRU5ar/2C8LK1i48bTMd48piNLNGah6T55rN7Ko5dPvrTQDEhrkPq Gk+1/tza6ZUSw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 04/10] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Wed, 9 Oct 2024 18:29:45 +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 Wed Oct 9 10:29:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828130 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 D932B18F2C4 for ; Wed, 9 Oct 2024 10:30:06 +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=1728469806; cv=none; b=GPFyyGn255FpXHnBb+wAfXJXvnpWPpCXwIMe5Qq/TdS4vQhe5Mu5fLKWNk9715b0f+uYX8EE20gJdpVP6Kw2/n3YL0VDoObOjXYeDauNJAaYw0pGPSNmWUzp3zXJCRO72FqewlSoW9YC+Suog3O4G6EdDbf+LTLM9C3r4TkOvsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469806; c=relaxed/simple; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QgqX+H7WnSanOKcLx3c9IOwkmKixKcURniMUhPbmljhIE8VdQj+zWqqGkSB0qhQoXgu4tmR7OTBcBYlJFNxM/zzzMuXK2kMGqoE6OQ8+i9/ufx1dW99SfksESFfgTf3QSXHGaOxgKj0Stdm0plV+hF+9AwpTxOzZ/yzp0beFwbg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sqoESUCq; 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="sqoESUCq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84648C4CEC5; Wed, 9 Oct 2024 10:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469806; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sqoESUCqpfPlEU26mmdKfaFb/lM1os3fGM85yi1aU4MFRiBwYJJ4LgR87qf1L2IST HTVZTYF1Ijn+JRa0Bqi4MYw5akJmfnYTIMFI0YhUthU9Yn/PCph9LegJtT1pmtnHjD neRY/KPTdlLI4DZQMGMr4gV4rqEGPmBM+rU9KOzP4/tiwt4pkEKFBFMVzbpdfT3VvQ 9G/By/slgPG/mNhfN7WwPNe0usggfACxfvIJwJFUC1o4y8p8fj1ouNMn8DnAoUyL1t aJDVE11lrCuMwWlaZv0ioJvR89quSW/g4vUb14IEasHNPjWVH9sHVIKJsKdT5Keysb qkp2qF9S1o2Nw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 05/10] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Wed, 9 Oct 2024 18:29:46 +0800 Message-ID: <44c4097b4a3714d81f9a9cbc6f2bbf0393576014.1728469555.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 Wed Oct 9 10:29:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828131 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 3E6D018BC36 for ; Wed, 9 Oct 2024 10:30:08 +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=1728469808; cv=none; b=DigzuPi0VpckDazj2tD5UIx7DlluhlNNk1BKBcoZe1OsdRxVYYg1XjdCkvsxs/C9MtbmdzhBXcOraGHQiIvE1tLIdX5cGZ0PDk6cNXKtcMDh8wWyK5WL8Zv1sBy8lqHqHTcIxc6Qd1Uz7aBbx5C8MlN/mu90ZM2e6IN/vAoqAfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469808; c=relaxed/simple; bh=2ViO1iohtQqu4Bsc+NY9ThkthovApoF3r8WYMnVx+R0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YkBQr2qFB6meRlku6N95bevgQ5r68I0exQygWnbez40ykXSJTSy2LzV2XgZDivVrhsouE7eoC0ShDOsUZtNiTrlizn1aDbd4J6Nx9RSI3brhY6TUYB94PigHX1VxUFC71JzrGxov1ccYB9gNIV1CuvHak+amUWCLL3UzZPAurlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NsR1qpHE; 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="NsR1qpHE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03109C4CECC; Wed, 9 Oct 2024 10:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469808; bh=2ViO1iohtQqu4Bsc+NY9ThkthovApoF3r8WYMnVx+R0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NsR1qpHEDS7nwv8d7klPO8rV8mnE4htMrJFhLZhqDU49rzHmZcUkfGRGrxdx5Iri6 r6pnW0iSEfS/GBVF/JqVoOYyocw3dzyy8HOdut6pYwP6UICm2sQQf8BSkJe77f8ChR vHrYxDR2xTHzhXyYeziUZRuELi3io+hUxQL7sryO6mudvkFxvSC+AQxgvu3lrhoSMy zsURd9HND15V7JjIHCQ8nH3W13rMzH3kq5tvmaxUTFeUcTEEEKzXPhUXdcZnImHgDO pu3+buoFPpsRQnJu35tohgpnKG2PmBV7CpR/2jWf00jF5wv1vwACBF3KRDZTTG7LSD yYbPmfjK5oR6w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 06/10] Squash to "bpf: Export more bpf_burst related functions" Date: Wed, 9 Oct 2024 18:29:47 +0800 Message-ID: <5b470d4495f55957e01c2e09cd8ce50c511e7923.1728469555.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. Signed-off-by: Geliang Tang --- net/mptcp/protocol.h | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c3942416fa3a..f1e90e7b2431 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -721,7 +721,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 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); From patchwork Wed Oct 9 10:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828132 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 060BA18F2C4 for ; Wed, 9 Oct 2024 10:30:09 +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=1728469810; cv=none; b=fbORxjcPOzv0R4NsJvKiH+dNMP063AP82N79IpUNHUzEFAotL9JQJjqucT007Dl5++sjtPymIfD+fRzGINkOOgFdb0nyhg7iE7j7KQTRBxP388pgYPmpFWc9XZLSPHUMGNl+dF5px/jHfkNGef7D4Nr0f+/mtjAQim2KXHXrleo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469810; c=relaxed/simple; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o1koOSvdP2kAC6lfemx5fz0RvcZkMbL5ToU02wYvzJwyl0lJiMWDSIRlvflTMy3e+Vk9z+SnTZPNgS6pXksOgyVvvxpygSB5VwA9JIAxwfKfpGEMUHG55yexnojPYYTFKl/zTBM1b2NmTzFwhyosst3upXbU/X+Ed03yqhsLtX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jc5YT/+z; 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="Jc5YT/+z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98703C4CECC; Wed, 9 Oct 2024 10:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469809; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jc5YT/+zEVYMYe+kDmGUUltBSDWeP0Lxol1Ovsszm4ncfrJnCnJHLb0x+0wW8FovM n2V/8sgoLSYPvQNtWBZhGZ5tPO/xCIak/ne3Heksc29GdwaXq7QkVFninsPUoz4OK1 kqZUBW0jRKKZQH/30AjaWsTKu0FVKoop+p8EU59mToJPFCNVKqL2FY83AqIlu83LUX TPskJBOXRHuPuLlg6jtMwUTXc4hvx1zNlVYX5LH8YOczswO6QyKfANj4IgXnxTDjZe E5ApAievgATlOEahhrV9xMw3u3yq/SinSVuVMNWzbW1upBf5ADKsFkvofWtgI7ZL2T lmVZB2iqBC7tQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 07/10] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Wed, 9 Oct 2024 18:29:48 +0800 Message-ID: <7a0ddf3c8f4fb2ab49a5075fb61ea087986f16bb.1728469555.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 Wed Oct 9 10:29:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828133 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 7328D18E351 for ; Wed, 9 Oct 2024 10:30:11 +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=1728469811; cv=none; b=FOufPnviAuMFHG692n8aHS2VKxVPsuDdunb3Ekfd/WGnXCdnyvqZ/4mBulwuWgiFxNaSnwDaQoRugnHMAGwdRaVxhDAlEtwTPtzSfNTJ7Vmv2ST57EYIRqIwZsVbsmSsePiXaxA/nYSgX4ByIBEUCvPmjgKeZzhZZ3DP7z10w+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469811; c=relaxed/simple; bh=WWtgYKOKxBp7nrH4PEuI6PQK+sKRIGaUVr1hgcjLieA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mDs5vvEKj0iFrqFaUnEJATghzTn81fPI7SlQCt0b6vGTYAUYNIV9Pr8kSit3yOZg/rs4HehusmxC65fjk1icZLEvo2cjck0TQYav1YV0WRUDjH+IXdBLchK4eMPJtyQHCcIHyUNfOAp5OMLptwPYSFim0hukFl64TfdQ4MseLAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=am7/o+Pi; 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="am7/o+Pi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57388C4CECC; Wed, 9 Oct 2024 10:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469811; bh=WWtgYKOKxBp7nrH4PEuI6PQK+sKRIGaUVr1hgcjLieA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=am7/o+PiwLwzhybgcq/YkKjXYstPPmnQ0ORcT++8Vc0einTPVZe88NtS4H/azGcj8 V+ZarLJiO/vSXD4JrLnSpkm17IO2edj+qbaPsnr6c938wFvnknXD17Z5SNwlsv1ngB sjjNDHyU+r5mNIb9PcS+KY+mwP32r/psg4oEoSXc+EPl4LLPUx4GmCh/xW+YAtFQkk wpovR3XPlZFPUFjpbP3YaZvx7HrmCEsg+7nv+sXyLrhP9JiEHwGvhGB2O03Nf9IFng EyUPhejtDPDqi9TDn3a6pKGIHb+WSGRzSiTGvE0PIvA/bRws4wzZ6a3IJbr+CmkuLm 97u2Q/XYxlRAw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 08/10] Revert "mptcp: add sched_data helpers" Date: Wed, 9 Oct 2024 18:29:49 +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 Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 9 --------- net/mptcp/protocol.h | 2 -- net/mptcp/sched.c | 22 ---------------------- 3 files changed, 33 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index c9aefe9eec14..03160ea280f6 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); @@ -304,7 +296,6 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { }; BTF_KFUNCS_START(bpf_mptcp_struct_ops_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) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f1e90e7b2431..9df56c21756d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -721,8 +721,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); -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 Wed Oct 9 10:29:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828134 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 46B0218FDAF for ; Wed, 9 Oct 2024 10:30:12 +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=1728469813; cv=none; b=AMrJGnJviDFxSnlIrkvfP3VCM3KRP79GG5zdhDpsFWfVP9i4lTIXyBQ+KMWp47Wn2i/w8IL5q0sEY+HuskoJxZpTz5j/7j5PlyHjsHipNwU3nzJbWOnzc5JPgcg71eEPutP8KX9gdsL9eFoMNpjtYSIhLzO+Uflfo2OXh7XyUvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469813; c=relaxed/simple; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=twj69AOxxv4Hr/DJY84t7P40cKrxdEj02vX6+BIVHnXG5UrP1zTkcrkBaUMpY849VhwAiVJo/F4tf14Wv8G+72xExI2iexSPOJ9u1tbys1NgM/985+O+IcozBPpMx4AuCE5MnScEZwGxsftAPItalopKq1STAz4v5++nhs/l3xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y8BgQlvJ; 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="Y8BgQlvJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA542C4CECC; Wed, 9 Oct 2024 10:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469812; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8BgQlvJZao0bp5TtonVXvh6DQ/mxHtHGYA60Pl4u9dA91ETkfn+yKDUSdBvQL0a0 j02YOWPVivBYB9g1SH4comrWmolq4M88ZizyKnzwUdyePO27FF+q9t7IgicyJ1Wm+B b3piJHqpQ0zZiWWpTd3DJ+3QBFCo3afL4bJWYnRitRuOyVIq/J/WZu48xEK+B5lLMi LT8mWb9iQgo41bWbrgqDze26V6CFap+S7amWHZIAQxofvZ/qGsIWG8MD/wsrnV/v6K 9Rtaaoele7uZ6d4Am1uPzjpA0tl0dGKNIapIF3eiRafvFwPJrDmblLpsHsrhy4P8Ms M2I806qVuwz4A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 09/10] mptcp: drop subflow contexts in mptcp_sched_data Date: Wed, 9 Oct 2024 18:29:50 +0800 Message-ID: <31e4d5218060cc1c8adb3971e5e0f39d899ad56f.1728469555.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 Wed Oct 9 10:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13828135 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 D396F18C91B for ; Wed, 9 Oct 2024 10:30:14 +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=1728469814; cv=none; b=jQuxpKlHRrNE3BrG/mgGwhhFbUdTAS0b13+INv1HN6dT89XtK4u8HPDF/g/VoKZEdLGeP5ba0vi300I0netSeUyV/UirRigiHhAtFG7hiYdwDaCWzGp3ADS0qkUWIszLfL/rv6zgQhVyAxpBC3vVtO84r9RkCTIMFAJ4n9dCwEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728469814; c=relaxed/simple; bh=7p3qLG+8FOxEQeowmflCjeq9LTjG9oH40FX5AUEKVWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NLE71CS2UZZO7Qc1sFas3W12Z6+4y9O72ePQC8QcZQNO/RpMKvksBYApA3mA7K/seM3t4FYEhBUifLvtB/ldVMAiYRjQq7agUeo80k/dmkDnb5XXuQoJpWImnGddAd8x8b9qel6qYMno4afrCApJms9KWZWk9DrRfKo5VCKEuLc= 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/T7q+TR; 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/T7q+TR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40797C4CEC5; Wed, 9 Oct 2024 10:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728469814; bh=7p3qLG+8FOxEQeowmflCjeq9LTjG9oH40FX5AUEKVWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/T7q+TRR1di5XpagwXjnaB0/HsH5gtKSwSP972s/BYfp7lPxTwOwOufpEJwKSuOz jLLhLPCINeuJ3/5PZT3Ffw/9aBxOnduK5m5YmVxca4BB7LCZiD9MI6/hxHyaTpBnOi G9NJmI6Hs2mDQyUAEa4kDTyw1t4yfaap9PEpcZNU5M4X3iycT4R8qEjH1dCR7bR8nK C73fBAW3S2zCa5/Zbbbbby9C02WxmeNPQyWHULkWtIijxpXpg/ueJg5za/utvxCfD5 FcSm9evkjdFM/K9mGNquLRaS/rxELhvW/B9EejxJq3T8LI3lslQ1wONpmBhaRIP4qt ZuHDyICfbAcfg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 10/10] Squash to "selftests/bpf: Add bpf scheduler test" - drop has_bytes_sent Date: Wed, 9 Oct 2024 18:29:51 +0800 Message-ID: <9e5717d59ca4aec2664160ecb32461f6c2ce0642.1728469555.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 589420f42845..56624f840aff 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" @@ -596,56 +597,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; +}