From patchwork Sat Oct 12 13:42:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833579 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 2E1821E511 for ; Sat, 12 Oct 2024 13:42: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=1728740555; cv=none; b=esuXQfyMHLS/Pg0GA10n7R8+zJWhDWVBZJQHuEN1inE+SmpNCuTmhm4qNHsNnp4TFZy8/zmLac6enxRNrk+dYZV+/Bt4MnhNuNH2OpiP3dMe4DnuOSgkDOPfzpLsEpeVtPHBXJIdjz7EFiFCyiU4hraYmGMfvu+ZZKtCF/R//EU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740555; c=relaxed/simple; bh=Gz6HbhDzNQZ8VvZImuhA0bSkF4NjHsir9HNmr/KM86k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i7BRZ/yJnAxTE9sX0wbGvj55SYfok/nD+8Kq4zvbwrLiYkmoaoVBoHmBPNLATQ8pxK9sk6TC1xbZNcA0a/Fl9nOubUU3sYqQ8Q7h7fdIGcvkXzC+Jcj3WUYTIS5/zyMqSEe/ENzeSs2f6fQtOZbYbkGBTvxGyoSBdpZFOiNBbP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jU7m2COb; 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="jU7m2COb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0439BC4CECE; Sat, 12 Oct 2024 13:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740554; bh=Gz6HbhDzNQZ8VvZImuhA0bSkF4NjHsir9HNmr/KM86k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jU7m2CObMddHak64qchaBGvufVO9N0Bbm8dMOgBRvf7t0jP+NMnJKVnF5vRk4ZPUq dCJaeHIy9wsLxDkDa4JCIcOm0gMCKx+4Y/ePA1v3QP5WWsqVA4RypWkTVpDFm3olW2 Am+2VHI/DpXNxH8lpwS9SBiTRU2TrgxSuOAMQhEGne2UnBz+oFRy0t+la106g1jn35 oHIEebrUqBMTQzcbizVD1bsfWEN4KnktFC1mk+lb7YqgYBRGtkq2eItlEqEF9d1TqR AJgZ4CmL8tOLWJAblgI/Z5tG/ye2pcs5eqUn0/6cvR+MgpftpYGDKP4ko36zJW8sSG Cr5ictDQfHJvg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 01/11] Revert "mptcp: add sched_data helpers" Date: Sat, 12 Oct 2024 21:42:06 +0800 Message-ID: <29e13e7fb70f446ec82e9a53341719d11475fa01.1728738219.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 Sat Oct 12 13:42:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833580 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 3D46F1865E5 for ; Sat, 12 Oct 2024 13:42: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=1728740556; cv=none; b=eX379By8oFbVpEm8kUoBr2ALoi+xXyW7mZhdyAv31xdlZPX7VOfL6ALFVf3MSs1UPDw1fZxd7uZuh7EyFN8UrgD3Gbl3nEvKDanBG8IufTV2T3UmeehI2Vume4XqCuAT4WqxH4RXiTvav21qDXQFL7AOoTdrJBPoCJHgJ2WAE+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740556; c=relaxed/simple; bh=tLz3h6JC/9VO1Qru+mk3weujBMDZhxQqWeB1BJ6+7LU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ObgQT8JCNEICQVbzH9+ZLaCQzqduyStpGmtm85DFf7C8ftH/nSrzm8gE5E5UvFenJ8DSQfBWCSvzwHPEMXJ5LvTM19o/hYiHC8WscDtMDBiZNwgifmWKCWtnftEsk1hU8egQeZ5fcot+mYQ114zWFYBktAeosZbdBewjpSXju3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cw3y8nvJ; 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="Cw3y8nvJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54BB9C4CEC6; Sat, 12 Oct 2024 13:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740556; bh=tLz3h6JC/9VO1Qru+mk3weujBMDZhxQqWeB1BJ6+7LU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cw3y8nvJEnOnsLzPFGYXr4zQqWskfy/+1ugiuS9MajXVWS/tuVxZGYC02+TmIaUGk NbhNiIcIdXjP3KE37g7X33Y5lydirLGEsafoDPrzgNUGpsaph+kr210RNvsqnqLmQQ SYmgnjTz2RTaUpa8sxg71R7QsyW6K168nHVW8hbCBTtFItIm1b5YrSxac0j/jweuw/ R12zDJjOoyXNxZfAefr2eEwk7YLWCvoUTwlv+mFvST2I5j4PJGgorM6GeTpFDzBt47 eGpD2AGQfM6U0ax/S6BBB3CcjXibfojB3Io4CBrdc1XIDijElPCdHBbmiBlDA7IeEa 5Os/+6pOPtmvw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 02/11] Squash to "bpf: Add bpf_mptcp_sched_ops" Date: Sat, 12 Oct 2024 21:42:07 +0800 Message-ID: <648049ee03650e648cd0426c2430ebe1f191aa0b.1728738220.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 Drop mptcp_sock_type and mptcp_subflow_type. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 681a76f7c6a8..3be587c7b21e 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -18,9 +18,10 @@ #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 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) @@ -43,12 +44,10 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log, const struct bpf_reg_state *reg, int off, int size) { - const struct btf_type *t; + u32 id = reg->btf_id; size_t end; - t = btf_type_by_id(reg->btf, reg->btf_id); - - if (t == mptcp_sock_type) { + if (id == mptcp_sock_id) { switch (off) { case offsetof(struct mptcp_sock, snd_burst): end = offsetofend(struct mptcp_sock, snd_burst); @@ -58,7 +57,7 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log, off); return -EACCES; } - } else if (t == mptcp_subflow_type) { + } else if (id == mptcp_subflow_id) { switch (off) { case offsetof(struct mptcp_subflow_context, avg_pacing_rate): end = offsetofend(struct mptcp_subflow_context, avg_pacing_rate); @@ -75,7 +74,7 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log, if (off + size > end) { bpf_log(log, "access beyond %s at off %u size %u ended at %zu", - t == mptcp_sock_type ? "mptcp_sock" : "mptcp_subflow_context", + id == mptcp_sock_id ? "mptcp_sock" : "mptcp_subflow_context", off, size, end); return -EACCES; } @@ -140,14 +139,12 @@ static int bpf_mptcp_sched_init(struct btf *btf) if (type_id < 0) return -EINVAL; mptcp_sock_id = type_id; - mptcp_sock_type = btf_type_by_id(btf, mptcp_sock_id); type_id = btf_find_by_name_kind(btf, "mptcp_subflow_context", BTF_KIND_STRUCT); if (type_id < 0) return -EINVAL; mptcp_subflow_id = type_id; - mptcp_subflow_type = btf_type_by_id(btf, mptcp_subflow_id); return 0; } From patchwork Sat Oct 12 13:42:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833581 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 CE9311891B2 for ; Sat, 12 Oct 2024 13:42:37 +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=1728740557; cv=none; b=AEZY3D06iNmMX4R7I3b7Edo6kHf7zwJ58PpGw7IBEsAUv0GEgHzts4fvKkxLPBzXrdRpLCRHocTs6d9rF7yyYxJJmach9NrSXXNHRMESblGwmCggpcWQ7bsQum8w8JFIrsDVNJYTwSslDFLK5lFtxmI+sPt5OmrrrfNUCmsc9sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740557; c=relaxed/simple; bh=efrgzvFmXp/p3PDPiPF/b3P1G1kO5oQ0XJgaCKadQSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8ET9rEGeBi4rMHn/9egE3gZGssYSyIJY1UdlB+I+2496OAziV0zA/BklZZfGudaw9gcETLe3jldUi4AXQ8KTeAeapW5sL5+jE86DDziflKOy6qFpUzKfz04fSk9Sm40t485RSig62xT+mWUDq7RnmDP5NX8HpatDIXA6yA0U2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LW2fU8FS; 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="LW2fU8FS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5762C4CEC6; Sat, 12 Oct 2024 13:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740557; bh=efrgzvFmXp/p3PDPiPF/b3P1G1kO5oQ0XJgaCKadQSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LW2fU8FSXIrZv/nIFQLZge7OL5YcHRjtCDFotpxe7L0bp19zzZcmRpMCsGcelyxsC aui9KqK5dMt5zsOLlcqmjcHLJOhuWfJUNb+6D/wDsjOrStH2cwpSwCcV8ZIIfs41DM XhDHbsWM+NHiAw82audqIXuNyN4KchjqjMovhwCHC0XPRn14kATj6KJcav0I1cV2lq vkDnQu8xkNVS8+XvEQ+uvWYzhbaSpCpUXZvQca5ihyIzhGoLtUVOcGs+yxVe5rnycd fR/YcCUqMQ6MiMgp1qDv9ByHp4YAgRJClErHRNHrkSlg3P9/+SuWQxLkZRiAWyqHCT 5IfRTykp62xDg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 03/11] Revert "bpf: Export more bpf_burst related functions" Date: Sat, 12 Oct 2024 21:42:08 +0800 Message-ID: <59e45a04c0bfd578bf10b4b1159a961a154fa33c.1728738220.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 This reverts commit d0f5ca7a98fea075d60fb88f1c2b29a6f5f04d68. --- net/mptcp/bpf.c | 10 ---------- net/mptcp/protocol.c | 4 ++-- net/mptcp/protocol.h | 3 --- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 3be587c7b21e..627839383b29 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -268,11 +268,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 bool bpf_mptcp_subflow_queues_empty(struct sock *sk) -{ - return tcp_rtx_queue_empty(sk); -} - __bpf_kfunc_end_defs(); BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids) @@ -294,11 +289,6 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { 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 = { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e420ce9bbfb6..e978e05ec8d1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -50,7 +50,7 @@ DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions); static struct net_device mptcp_napi_dev; /* Returns end sequence number of the receiver's advertised window */ -u64 mptcp_wnd_end(const struct mptcp_sock *msk) +static u64 mptcp_wnd_end(const struct mptcp_sock *msk) { return READ_ONCE(msk->wnd_end); } @@ -489,7 +489,7 @@ static long mptcp_timeout_from_subflow(const struct mptcp_subflow_context *subfl inet_csk(ssk)->icsk_timeout - jiffies : 0; } -void mptcp_set_timeout(struct sock *sk) +static void mptcp_set_timeout(struct sock *sk) { struct mptcp_subflow_context *subflow; long tout = 0; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e774f28a6f8d..a93e661ef5c4 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -720,9 +720,6 @@ void __mptcp_subflow_send_ack(struct sock *ssk); void mptcp_subflow_reset(struct sock *ssk); 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 Sat Oct 12 13:42:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833582 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 1DE8B131E38 for ; Sat, 12 Oct 2024 13:42: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=1728740559; cv=none; b=BmpQ4LwFCbs5Ix83FiOj99TG12iIGxH/fv4Y6/a9kZHPZshn9sHDawzlStY/bb/SzE9pxIa0IharGt2/RPQEp+4iOFrDUOSt8sOPLRONWx5/XpeGREioV/6zB91aarhsyox6xxhIUrkpF5lnQJ7dAoKlQpZ1uQTkBCMAl8TK90Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740559; c=relaxed/simple; bh=8atzrbDfqZidyNnlDwL9XU+IIOzeh/9RLqX8outzcQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y5f7MoVX0mStQVBZZ21Nwfgbh9XaEQxbCPsJwt9KRti9W2SkiPzFgf08qS3JyDpldqQsvifPuGistslUQ7LMW1NNfDduGPMaZBUwbhdtsdLzKQ+USZ/aKSZGGrmgYfWD0o0QStmVcCdf/7hzfeg0KhVPQvi0qOQoq4eweVsKbb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=inz9vkeh; 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="inz9vkeh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02B5BC4CEC6; Sat, 12 Oct 2024 13:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740558; bh=8atzrbDfqZidyNnlDwL9XU+IIOzeh/9RLqX8outzcQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=inz9vkeh54hMb6I1oCmht31jUg4fRueSPzbLkYga4IczigXAROHa0UlOarzQKuFfY jHKXefMMLLZeMi1emVn4yLxwIejBAK17UxOAYyL5I+Rveu+iWdLAZFJqWfe7HqFmy4 Etwwn6KqLyFz4F6et11QAnLSkzU+vtppDzbNg+hCr06J6MG38Aj89jXhorK3UL72st BXC6NRF+tRPduHD35lOdiarIaFOpcuLQgTTCF9ouiNnE/9U+9S9VYIyH7x241fu7dL 0IXJPrNc7DmZCde7KB647VypQ9WTMe6v0JfMUQT7rjs+1E4+ZKVXOC2FrKSAkbyv41 9pFmNqINT/VJg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 04/11] Squash to "bpf: Add bpf_mptcp_sched_kfunc_set" Date: Sat, 12 Oct 2024 21:42:09 +0800 Message-ID: <12824111063f027ed49b3d0c4cce285716959d6c.1728738220.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: Export mptcp packet scheduler helpers" Remove bpf_mptcp_subflow_ctx_by_pos from BPF kfunc set. Merge "bpf: Export more bpf_burst related functions" into this patch. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 11 ++++++++++- net/mptcp/protocol.c | 4 ++-- net/mptcp/protocol.h | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 627839383b29..38034d3f28f8 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -268,6 +268,11 @@ __bpf_kfunc void bpf_mptcp_sock_release(struct mptcp_sock *msk) WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); } +__bpf_kfunc bool bpf_mptcp_subflow_queues_empty(struct sock *sk) +{ + return tcp_rtx_queue_empty(sk); +} + __bpf_kfunc_end_defs(); BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids) @@ -288,7 +293,11 @@ static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = { }; 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 = { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e978e05ec8d1..e420ce9bbfb6 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -50,7 +50,7 @@ DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions); static struct net_device mptcp_napi_dev; /* Returns end sequence number of the receiver's advertised window */ -static u64 mptcp_wnd_end(const struct mptcp_sock *msk) +u64 mptcp_wnd_end(const struct mptcp_sock *msk) { return READ_ONCE(msk->wnd_end); } @@ -489,7 +489,7 @@ static long mptcp_timeout_from_subflow(const struct mptcp_subflow_context *subfl inet_csk(ssk)->icsk_timeout - jiffies : 0; } -static void mptcp_set_timeout(struct sock *sk) +void mptcp_set_timeout(struct sock *sk) { struct mptcp_subflow_context *subflow; long tout = 0; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a93e661ef5c4..7848a1989d17 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -720,6 +720,8 @@ void __mptcp_subflow_send_ack(struct sock *ssk); void mptcp_subflow_reset(struct sock *ssk); 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 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 Sat Oct 12 13:42:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833583 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 885D41E511 for ; Sat, 12 Oct 2024 13:42:40 +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=1728740560; cv=none; b=p+peYVd8AszsX8EWSL70TZli7eVu38xWVrh6atyyMS3oQcrFGhgQ48Mc/i6ai/RzifWiZCt2hBZKdT1dg6GiFrwpg6ZYEismpb91rstJyuVZxpBZcPiiq800vUbUYr+40RDNkUjR9ezICeLRQqw6SxXJ1uToeLsTsdqVc3vEsFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740560; c=relaxed/simple; bh=LBbhZRE7O7iOP8AKfoYUNWYs3cuAD5rsHQ/AU3RUl5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tAvgEGdv0KZxSfJUl9kwrh5O5lb9CkBVgSo6bK8l9IqadkzKvEe9tVlGefcVQA4HLwdfP2rIKbtK2WziO9Y+TR4cW7uBbh6VJznaJz+HQ9qtgNlw2eBX5K7vtHkN/5Z8nLJ6j6zfBSjjfuGSxfuvwo0gIizVlxmoWv6X0TOthzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iYh7YuKD; 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="iYh7YuKD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5361AC4CEC6; Sat, 12 Oct 2024 13:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740560; bh=LBbhZRE7O7iOP8AKfoYUNWYs3cuAD5rsHQ/AU3RUl5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iYh7YuKDEg+BxD6gZhKChIi2DA7ozA/kplcbwf68uog2Pb5AIJx58JH2MnBc3sCsk 97nArHAfVhTizuewTrT4yIcrK/sih/oWgZo3zns8yJIz+7AQU9bUgftb9XiNZ88s7G Y3Y5vXncwUB8bagVPqZ9Thfo0dLMX8KBpdsmEbRuXCgH+vg+OQHZq7prh5O6D9JFqI KbvE700hkTEwk3pbG1a2jzU3zNsi3dEIDCXJkQJTfwp7l0QAB1fAxYb+lSfnfCY8Gz AiaY1vyO2FrN9Gh/sFyTS+5UC0FMQPMpjzlZY5LBt7dScKjB+xQtd6NZJwuUAzQ5FV OVVl5cOlYMHvQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 05/11] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Sat, 12 Oct 2024 21:42:10 +0800 Message-ID: <1e5c4f6e9ca1bb672aa6a77f64f9519bc84ab811.1728738220.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 Sat Oct 12 13:42:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833584 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 C20441E511 for ; Sat, 12 Oct 2024 13:42: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=1728740561; cv=none; b=fhQWW7JLtIes3YUVB2m6VBIJKMcsMu/ze7GQXUiqWrhdcBYoIdhYsQIwmbwXpuXLvoRZY646kIC1iHKZJTQ5sMgm3VC/CLrvVN7rEMRWUqipPqZr0a7lVCLlJaWqegpFc5yjbEucCOMxwQmCskjNcg3ziZ5NJ37FITK9vwtZ+eI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740561; c=relaxed/simple; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pqUsG3Hk96yaEO0Xzpy80woB25qOHVLK+1QVenbMbO/zrun3K9vFg+Mmy+TdOrJab8fuWc9x/LwhyALPvzOIajjovW3di38VrOVxgtPVTvteabGPvBkKGvnH+85dHBnvT45uPPxbF09yfVDtr0JRsLOxqicUZUCkczgEDG+aiaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kLggZToi; 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="kLggZToi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4BDEC4CECD; Sat, 12 Oct 2024 13:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740561; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kLggZToihN7LBc8LlWFVXpk0N6gs0KlibOxE2b8OXDKqg8ovmaIUauEvAjmoAzWbS hEiW2lMc8oDhUeQN+O4ArN68K4tUS846KKr5UfNLXfdBBAHRaqVpUmvKSbzQFHwAJJ yLOhwE/FSsscuEZV+MauYCJaWUpnPJbcwuDTNRs9IgreM1KVkTzYE8PrC7ZyBYmMZv +jSU7fUwabz2G56bSHfzpWK+w67yznXbW594ZK9K6Eq9LzpoXQOXDCowttXJ/pF/Vx k44Zf8T9kodczI/18kd35cVmQWkMB2kQNupVk0cLhAsKDElNw1pRIF4OjAtg1Z5Weq WfxiyLCwdtk0w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 06/11] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Sat, 12 Oct 2024 21:42:11 +0800 Message-ID: <626fcee030e50e5cf9063f8f9660e944b5b635a2.1728738220.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 Sat Oct 12 13:42:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13833585 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 DD54A1E511 for ; Sat, 12 Oct 2024 13:42:42 +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=1728740562; cv=none; b=cRL3AKCmEpnSqudusGoVC2KvV+ISZqPR1YeDKrgljefgNgmDThLM9ZkLXy5yks5oxdt+gE22jhbviNoIgZqqyFt527Z+T5Li4WuESHRqjVwy/OGeE2k9ww9twd6iBScWjyT99ir6z8SlUoHtux02x2rftcwbdM3qfPUES1m+p3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740562; c=relaxed/simple; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CO0yvz+IqBQh+mL23UeoJlO6Tz8Blb8JkMr/ku5bsrUiBhrTsJwazwhW0pWBhxz2I4uuDUSg4BzYb4YcbgOkTnESCO3Bj2Q1HL0rbYebQw59qTm0iYwaJR9nseK+zOWTcaN/TbeTC2XCiFp2CN59f9i3uujqlhIT4Ro5eFDhMhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qaUk6lqG; 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="qaUk6lqG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 015A6C4CEC6; Sat, 12 Oct 2024 13:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740562; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qaUk6lqGrOO9odqH0BuGF+F1INtbzb6isQvxROnA8+KwrB7mO6cvXZC6vc41Sm/L6 rK4B+GzXIlXSVn6Mucz50WrakjiIz7pDBPt5zsfSZMJSZ+jKjw+WrMY2nFR9AzPYp6 AdUJVfYEDqiv1AMuljdokLVLomFgEgkJxauC9Z9BYYr/vNeuZGY76h8jTEFnlp+aVG BQyTCPyFVhEGSZyY+xxZ/8MIqRUlt4uEZ18lDL+QwfBPk0C9FgzVd3FyYgTZEt20Fn WKdRhIrkPAXRy0G3BBKSix+/DioF18LoXszo+AtDLBFcB6K0izUq+YXDnOTuth2S1g jW6MVn+Aw/4VQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 07/11] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Sat, 12 Oct 2024 21:42:12 +0800 Message-ID: <5cebb011be66d4ea383b457fb212c7e5ce4eeea0.1728738220.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 --- .../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 Sat Oct 12 13:42: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: 13833586 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 5D2811E511 for ; Sat, 12 Oct 2024 13:42:44 +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=1728740564; cv=none; b=qt/HBY7vlfIfTB3PrONhua32M113nqYVRXEQLAsRujkwB2OGIQ0MBI9WQCBloKk5+aSDnwMxsBoMpvvVROVFrLY+symg/reBYBMLK/Uqcuw/nSKM5B2sR6m3Un3DXnPkkMCJzYwFue9nmdgXi0G1AQZ3Z4SUJMec0WLpotksEjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740564; c=relaxed/simple; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ny6glvo+yvlH3Z6OWNQWkTggNnSi6INsF2Y2TVIJ+wgyXmPJ/3zIO0Euu1T5GicoIEDvqMcynHCpGeEnJvUhFz0uifHjmJDNVRsjetVpBSUydKgy233EmJQEmYevc0UnX3++8UEMa/Rg/T3e5rapvPYkZeerz6Xe0L8i+DtguUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a9aUr6cI; 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="a9aUr6cI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 520FEC4CEC6; Sat, 12 Oct 2024 13:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740564; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9aUr6cI/alKhbWYFL1O8HMCIjIjr/C2eKJlBkv+mWOdK6viQQluvh0IGfddNxZFQ +O0TfM15knpy/8w//37IAGLrMIq/j+XCWDs+RStQVaEOxMKkINqhZU9Cyrifq3VpL1 rh6wGo4w/uiL+qNxgfyexMe61wUmMt1QDDXGQZSWtKNKE1F6/tdzPcPDtFkXO4WFsW /p6WfjnE0eax5iodyp96l/Jt70axdksHF8raMXbGWYn7fMcw9DooR8i30ncXTldQBj F7pjf8vwAUWhxPWjU8/USLZKsUyPwSUPArTq8z5pcWKfRSTlKevUW3H+Clg3jo9FLJ h0ZaRI8HshxZQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 08/11] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Sat, 12 Oct 2024 21:42:13 +0800 Message-ID: <5099187f3e53ca11d81f3ce0d59a657d8ad52bf1.1728738220.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 Sat Oct 12 13:42: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: 13833587 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 56CEE1E511 for ; Sat, 12 Oct 2024 13:42: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=1728740565; cv=none; b=AQ5tw+bCuw37v/3OE+LKahSnLuUABx7Jy9pdekCiPe8/eI8ta2B5fYcVjBM/pKEec7Iix7pSG+n9vfB2mH22Jq65bZo2Ss0UboV1TNgUNqiHcrvG20WH3dOILTNwuVRCCZ7KRha9vC6HX3A7jHwDu8Ijy/psxiaVGXTSQjEems4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740565; c=relaxed/simple; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=spHrPuA4hCKVf6tKAIiamESz86vtstxKvGuhkIbwTmoHnTTlDx0/w/XH6Dusiw7WgAo1z5+ampqPkGvERifVc+/Miml+vLVFJR+21o9BsqPPodb3B7VxeXA6LWaziFG3c7mF7lFGTloEfmKWAoxIQZG3wKiz2vxs5VCeq8/Ff70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LObI3UGg; 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="LObI3UGg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F79DC4CECD; Sat, 12 Oct 2024 13:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740565; bh=BuOgDD+bm6N14m3sIF4M6yO0GJOC3GY4OAJjbWNeIp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LObI3UGgWKWPHzCCvMlqe/j0tRDi4Gf5rmnfsXOHF488hE3LPQOGOBpSRvgys3qM9 Tbtr+1Pyh1Lvh2F6qGT5pgPQNmWDGoMJ2W/gSHQ4cQiG1fgvqege6dz9FAOqv5iJsg 63cxF2DeewhKm0+Vi2trcMHC/wbBPv5SCwlu5Rg0Y/GMwt9K8xl1KJJ3By9p+uEmBO A4ssT73OdEiPEhXGFuKrL/NGBO+T26FOXFPzNN38JG7rdReRIoYFWXs6g+SBPSjqY1 LVpRC4D5eIiisZ8ddiq8bvmBAmEN35DUP6SVn8VWIRJ9kI0Rmbse1IgXUIFm8zKNGc XUpBjhjqE6a4g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 09/11] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Sat, 12 Oct 2024 21:42:14 +0800 Message-ID: <5561b5bb2ff9688c8311f7f9af450a56e71c7a4e.1728738220.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 Sat Oct 12 13:42: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: 13833588 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 A7DDA1E511 for ; Sat, 12 Oct 2024 13:42:46 +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=1728740566; cv=none; b=lns94j02e04NHXM5oSgwQ7Xp2tud1o/90/fe8ZIQLnLe0fcF4lbL6r50v5MU+HlfWZFWBYV2gW+8nKdNonih3orMQBrwY+2ewFeEKtGu3TXu0r1kIfjoiRt6liXkQSRqY6EC1cjwuaCeYQynGkfedh5cZdqCNLz+mvTrdxIWSrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740566; c=relaxed/simple; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g/pThD5+xm2PTG/MUw62RkZBvlHUBKPm6vAYqsp6J3P9DVHHn5SZdqaRoDG0bfDNk+rpkk3w1Oo/b1aZiB3rGV9C5FhZDuJ2ZQsw29eZtWiernMwQQaRj7i2v5WkZYagNEkyyNWTR8BfzMSii7p+xC15YYcEfE+I6PyXEbqZflI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ou8y3aGm; 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="Ou8y3aGm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1A3CC4CEC6; Sat, 12 Oct 2024 13:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740566; bh=hN3agyD3X5i/gzavJ94nZKXl6iKgXdKHAjxn48A3d+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ou8y3aGmD3O009eO+udB0+2uYqnUBrzGlkU58f/pP9qiCBNci+LpkwIproM428Xr8 O2AHYKJqdRN9xxarGvDG20zkFJmdts84re0QPJDxoNq/yqCqxjM++/RZ/sMRegDhOn YSORFCyiTD/43iFIEYFMwdXJkjm+1ncZ3uzfhMh0/epybidZJ343RSeEH8c/yRN0XN gBPReh6Iap4tBYYvaT/lmpKe+khbu9lmcnAOAjT0ALxTfDT0zAtiOfgP+lMuBHUAPs zcuRqoeXUF8WSzEQYqEy/DpimaJOcbsB9XD/pEneVIODwFzkkCXCt+EgU5ICyOmEsQ QIHhAoQL+9rmA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 10/11] mptcp: drop subflow contexts in mptcp_sched_data Date: Sat, 12 Oct 2024 21:42: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 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 Sat Oct 12 13:42: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: 13833589 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 6B36C1E511 for ; Sat, 12 Oct 2024 13:42:48 +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=1728740568; cv=none; b=pC7HYMiePlk28ki/A38PrqhbpI1vFCcN+u6ynYfu7ya3pHrOSSBm1cqZDFIizUTuxMuwIfPk3DnGbBohijZBgiXZmaN8q8J2VLcClKjw42zISUwfNT6Ql5MhituDZyVMyQ7XFYfA4KswrDwEgUoqMPJBWei2CvUIhhiuc3cAsyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728740568; c=relaxed/simple; bh=VIVEwNvERqY60UURI9H4hBSdCZTchsvxsrk48ITuZgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SqubG9sGe73b2guTrM1kCKGZDfZiLfifwSdL7xsgE7GBRu3u55M11IVj2M+0xeEtj02vccMzpqY79duzmUFtO9MDFxvctwijisWd1l329w0dO5tiWlgT9x3oZDs5gd7bLMFixP0RgGb85cqBq8JyoOKf9mPQGA7ecAEL98VxCkg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZGsSjiaj; 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="ZGsSjiaj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EBB7C4CEC6; Sat, 12 Oct 2024 13:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728740568; bh=VIVEwNvERqY60UURI9H4hBSdCZTchsvxsrk48ITuZgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZGsSjiajpo0kxzswshWARs4SjuKo5TtrDg2xLjxK3dFJJpjf64poQbg2qMKaaOhBU vhkk43P5l8sf+9ObBds3e9FDiTDmNaJ74BuzSa/D3MhFPfOIPDOcjV0TP3nx2bUpPP 9bZcpAZaD5rJv21VNRtpqyf3fR3yjEauVnFwPAiS9nPC+nB5T0ci7YgafZwh2CtYc2 ZFD2vHlYyGjYqyvPautVc3F18IHeFzOKR2YWx5OApFDkBVyibSJw2ohzqOU+pesvef k699TMppiiq1bQwdFsX8/DePLnh0/Wdt50S1kFNxzwX3XD2Y40PNE7K1Fa4eWdQEd2 BtLIvHaHRPlZw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 11/11] Squash to "selftests/bpf: Add bpf scheduler test" - drop has_bytes_sent Date: Sat, 12 Oct 2024 21:42:16 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Drop 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; +}