From patchwork Wed Oct 16 09:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13838024 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 A63231C07E7 for ; Wed, 16 Oct 2024 09:33: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=1729071239; cv=none; b=jqao9yMmhGuYhnot89AGWC1y25Fg7GgeyL7SF9JLyI0V6a5xq5jOFUsjYIdIi2wsOQUUEI9mPpRfInBQkJwIkRYBjJAA5S0RBMVmeAyTw1BH2HaaAstS0LB1IU46ds+5f8jcMRZcJ3XwaWVsIzs2zezlmGzn+W2dp22TlGGl9Ag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071239; c=relaxed/simple; bh=1UQflbaRWbUGF0gq1UCMSZllwZAKny3U8udYKTwqYf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mg87/L7v5VjJZ/x59WQ3fsPeglj4Kew5CGdFTFASGEIRXLcq9CCIxpvaaAx1m5u9eknIB8mwHetdw288RYA8c8mEUduvM76wAEo1elNAdmZBXgSrm0wpCjKTg43ZR1dC+YTDy52VtgRp2WljpZnpwfiNG6NTFD5kdTxfNMCAehk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AKkJr/TY; 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="AKkJr/TY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75A6EC4CEC5; Wed, 16 Oct 2024 09:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071239; bh=1UQflbaRWbUGF0gq1UCMSZllwZAKny3U8udYKTwqYf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKkJr/TYSUSJC4yWE7yG8yOB+9GEOL6s6yM2VgKHPaXBeW7X/nuYE7pj22RCzJZRA 6r3BXQkZFm3ANwyTlzl+wi7v+J7fnaN7tGXlv5SzhCP79pWyw2+Zjy5ACM7kmOc+q1 GFlnjGTpUk2o1CnDdG7Fq4Bf/r2hXlHR6ctzp0EgMJO6Hb8vVhMQyxnqf9A+XDBqE+ BD9+os0iImHMbOpc9nGl22QGVD/mWZrekRG/geH1okDZY0Hce5AtX5ijuDJZmd/p4U X2rh+U7MxAWlvHTK7L6pJ9gLZUKvX4mvQ0ghSnDm8n1Bk/6jjWfgHPhv9UTFx3LA6y BRK9pEpR1s5Tg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 01/10] Revert "mptcp: add sched_data helpers" Date: Wed, 16 Oct 2024 17:33:37 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Drop this patch. 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 0a14cc45d240..bca8b5332737 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -271,14 +271,6 @@ __bpf_kfunc static 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 static 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 8079dc7a6507..c81fe379b0f8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -736,8 +736,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 16 09:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13838025 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 8906A1C07E7 for ; Wed, 16 Oct 2024 09:34:02 +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=1729071242; cv=none; b=HKPv+KTaSlPPH9bWuyIIyzrEY6tT8NWiTsTwIMMhZxeY0AEFuHBPLgP2BdHe3hQeCny/WQaCU19sPnf6rS3WapjKMJi+8gAGZh8bddkOKdrWuP1tFIUb2kZa1tjy/o9corgO9Qeqrf58bs1+tPRQoXWd2K8m0UH6nnqFbpXCGiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071242; c=relaxed/simple; bh=Utn5Dy0UyeKR/dvlbz7Vc2G7oDOPq7AWnlJpMCXlohk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bjCOMZwEGvAjAgUO2+Wv1ApQD2DXA1Wr8kFNQeQbEvvwaz/1OeApIn2TdOyMxytiaRy7hXJMTjzKhtxejsi6m8zhsmAG0BpUXtC/DKJkhsfv91cl8ufHVuDww/pfTUmHVjFe4J4IcBqkJ4N4R397F7kYTYwZPm62THgyOJA2Ue0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O6lcEFJA; 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="O6lcEFJA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF439C4CEC5; Wed, 16 Oct 2024 09:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071242; bh=Utn5Dy0UyeKR/dvlbz7Vc2G7oDOPq7AWnlJpMCXlohk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6lcEFJAeyGqrDrFfLVnEOVlcewqXwsKBJSCo1GRIgSCOY2og7IjdhLkVr7onXoLJ PeDIqss+PLiMoZtXMoLbbEXkoZk1OnAnS9u3Cpwmix3hR2a8JHUOFs22JjHQJLmM/D QLxQdZs2UKjiNmgIYTUT2J5CpynfTviwof5CtYdc2PsdUXDbk6mCk5aG7yjMQTHBqS IcuO3L5GIUd21m0ceL5rgqHeXDqZ6fNjJbomSsHzJq5g+Ts2PasmHzefqc1ckWWQPu 7OSOhLWG2CQRb45gFSXrqiG10Si1P2jbWMHv7Ij0qMv92R5PpKOTbYv/abmsm7Q95h c2qiNUlLFGmag== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 02/10] Squash to "bpf: Add bpf_mptcp_sched_ops" Date: Wed, 16 Oct 2024 17:33:38 +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 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 bca8b5332737..9f264b37ca94 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 Wed Oct 16 09:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13838026 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 7CC191C07E7 for ; Wed, 16 Oct 2024 09:34: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=1729071245; cv=none; b=XX4T5ZlJQl21s+RB9lditlO+edhu2Ge4zmDZpGOw415a9hIMckNyouG6P4VRTvQ7fv2jPv1Zj1s7UcRd2x6nCCvxsMAU7g/rGSma8XpeHJWf6qLR3pF45shiNYrl4CM9Cdcb9Ab4r/SC7GZxRli+hvo/bE1wWBpdFoFrjdO4ixU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071245; c=relaxed/simple; bh=u2R+HeIVIPP5vQ9bQJlNHgd4TqYBFJQZ0/PAz1R4RKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oge1pf9RuVudv/6QcQItb5PmDg5SAxKcRAFmnN05YHLvRwUMkPhapFCtOP0aVixzDx0qaeyco/njrKsw5LjjSQlahtcvgXEmqvZDzNLgpyn9+09uP1apUuRzQmaixlqT8SL9CgCPUvPzFonkuykMUFpb6B9gcA3vKFjocwJxtQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i2DZ83Br; 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="i2DZ83Br" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 568EFC4CEC5; Wed, 16 Oct 2024 09:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071244; bh=u2R+HeIVIPP5vQ9bQJlNHgd4TqYBFJQZ0/PAz1R4RKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i2DZ83BrilQWRBIQEoT/rWJJdLoDRJO5gTfchMwqUA8LemGTzbFE7PmtGsJgdvHal XbIT4ft1JwMnE10kocHunBGN0jnLfrjc+8/vPZrboTRSSKRtkZn7GVvMoA0czvm5oq FeyU+Qiri809vHx4+nG+J3In10k2IvBoUf9Tky/7N/2I6OS2a2nmYiWIpvnouy1UQH 0r2ZxjNm+t/4H52sXDZlB9FdvI6bnzT+MHIi8hw1bqAoGV9CrUrKCjnGoClVeXYZlf tA1W0OSFtTbmf+yJagDlKVdYz0xQr5zogUSgk3l2ZVoz6SfUROb2n4uI6wJQdkz8UL /7MRJXnmSZZlQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 03/10] Squash to "bpf: Add bpf_mptcp_sched_kfunc_set" Date: Wed, 16 Oct 2024 17:33:39 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Please update the subject to "bpf: Export mptcp packet scheduler helpers" Remove bpf_mptcp_subflow_ctx_by_pos from BPF kfunc set. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 9f264b37ca94..ba36d624671d 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -292,7 +292,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, mptcp_subflow_set_scheduled) -BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx_by_pos) BTF_ID_FLAGS(func, mptcp_subflow_active) BTF_ID_FLAGS(func, mptcp_set_timeout) BTF_ID_FLAGS(func, mptcp_wnd_end) From patchwork Wed Oct 16 09:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13838027 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 858E31C07E7 for ; Wed, 16 Oct 2024 09:34: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=1729071248; cv=none; b=jzAOrlzLZ2YoIyM+vOgMcrqOLIeh2VXzKgbTCBGfTlFxzaD8VCyjnXwnnn6IH26fRj8O6Zo02Tr8i/WaXkQac5egl+oW5vgt8XRj+TNxtMB9h4kCYVfGN6y/4oJrfD6JN0O6NwPlEeOU91J+cTm6XVRYcSmJMexn7s+1dDAvw/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071248; c=relaxed/simple; bh=y5brf6Qmo4gol2jcfhDBgHOkERtdBFQuNuYp6mvq1AE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EtHiyNi97VtiteePOKFY1wtvFDZF8usAAT027o/LNOilTAzFbfzxq4pu+4AOlnto4qphmeOE1Ypxb4qNlCtKz458PfGCYppNzWpvcL47RxTuHsn+NHmRGcSJ3AwnVzvMkpOIsSfO5y058y+ZKkv3hKFmRPi9u+nGIpkLcb61uHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cxqMziMa; 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="cxqMziMa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF908C4CEC5; Wed, 16 Oct 2024 09:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071248; bh=y5brf6Qmo4gol2jcfhDBgHOkERtdBFQuNuYp6mvq1AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cxqMziMaZP/mn9801IEMl28La0WfbGPBtl6RuR0yVZdAqo/pfWEQ65KMwyEhXkwFc A2ziCmfS8CBsJE1QDbPUdMHM7yj9s73gEcVuetZY15B0Cp92lq64SZKByn17fi+sDX G2AtLRnNPW8fbZ/QACwhgcrYOzGPLBFWYkIcJVfSgv4EXHqBmoMpvrRbB0n7LZFn+1 v/JB9XzY16ZntqjAP1NrQfzm0h/xxaVyCmL5HxWirUB9MmDiY2/P8Ou02jgT/UJj+b UaXwxAq7T0U5skN240a2ewUHPE972FV/uE9E2LNZr8M7r/rWG/r0fjgjqCphWjAPhB 03CiqZAcGDjyg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 04/10] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Wed, 16 Oct 2024 17:33:40 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang 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 b1f6e1fb467e..72516ba10ea2 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -54,7 +54,4 @@ bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym; extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, bool scheduled) __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 16 09:33:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13838028 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 1AB091C07E7 for ; Wed, 16 Oct 2024 09:34:10 +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=1729071251; cv=none; b=Jd7w7+24yF6j4J/4U/Dsn+mBLExrxyJ02coRW+AgZU3lkx0Ux8TIgN7Vi/ffIQbIty7jPpvUhx0mi63niEXawhVlqn54BudFEE+XEvMuPcltlzud+YRjK5CvJ1PWlevs7SEF4dJjUVgakPd2dvsHMkpqi8lXHrvY6UebXtQwcY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071251; c=relaxed/simple; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fz/PeEzsDU28jkS/q5TjBJr9LF024KfLLPK1N5NFDVClWkPjUnDrbp4jWpata+1dWW7HN4T1+FFw4kHhv0XdIuPhHh2QeAHDES71molhzkPJUQShzSnU2WgRxxozNOGw6jpyCIueBFyZ29TUWfr9lhajuEYSB4oYaeQtY6zrLSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LIrWrw0q; 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="LIrWrw0q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43016C4CEC5; Wed, 16 Oct 2024 09:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071250; bh=+Ns9vcAYflyNwdX3DkGpNegQAHdxvHGggo6htLg093M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIrWrw0qaVSrVV9Whk+swGiP3+bNX6dgp8tLzvn6G1K3/c4GNAn9WekxLWGBqQK8Q +KTzi2g8zipOrfYsyAKzJzzzGGoRSyR4K2RLDAgpzgu4uh2P08DvsyVNz+q+24sOkZ JaBbcSZ5uI+IEY/8EPYxPbL5zTLP7IzwJGB+CYBgMsqwaMkfTmUL0KaaJm7g+LeT+u az0DnhrAFQDkANwOMvH59yA2mnl6f4pEI1VzaSsXguGHiR5V0QWWtiRspqT9VAr4Z8 2ypGiU7/brMFK7QwLUOi79+WRW2pPckI9Q6C7kR7MU4p1sJgdkARlcoSfGjZV13ddf k5Z/e9RLlG84A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 05/10] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Wed, 16 Oct 2024 17:33:41 +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 16 09:33: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: 13838029 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 EFF041C07E7 for ; Wed, 16 Oct 2024 09:34: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=1729071255; cv=none; b=fRrcRJYbQjsQEeYtxZ/Axw1887hjuMix3vBfHP9jkYrKb92r5sMgq2t+CFeTLuXd4rQmeSYfe99JeFvm3aXPq03Xcs1BF0jX9nTBNRkTnyv21KID2FFKiIhhFltI69u54FrmLK0oDKhow7/5aPt21jduIKFrZrS28gOT2nsTsrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071255; c=relaxed/simple; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pfoKJUzTy2FXT9ezU/VZ/yavdjyseMxkGMkGmv6EG+PqJYrpwHee6eJS0HdNCzfcjoBPPr0q7ivNJVAtfdnbqEsKXvFiIr5j6s4d051jx8z0+2NW3G3sqLS5eK04pJ/MjIOqo4tEcGwemysquCPWdtjnN0imGH7bKa6ZPviCJps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z+5MAHaS; 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="Z+5MAHaS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBEC4C4CEC5; Wed, 16 Oct 2024 09:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071254; bh=GWK8Emu7Xenj6RbjmBgCMLp8+y4zcVDWsQH+sR0uMj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+5MAHaSplilkRFF4wwu2IEhrNcSNrw5cHQddEpPiXXDM42IBUgo3xmA6jiMaz2T/ WCpYpGbxRr7PaK8lpAxNRplFaRA4jy8SZY98q39G/zA+scXCMt3a70BoHRI9Uic2I6 jRqSop1qjXEgjXUVyj6yRLYPyOXtzvZePjZqQYNnbM9FyxWzjG6a4O9B5E6d89SywG m3alQ1akT8DrbPzIOmMXq/fGSxQ7QjRSY7DXZjh2NkinjqQsBmquszi9JGA33iLOHl 7bPP50Kr4syfwuHtuCYL8OblB+A4JfWrpbUHse7pYmUsexMe0JxN1eQUzfWq90GGxV 9lHN8CLpEm5hA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 06/10] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Wed, 16 Oct 2024 17:33:42 +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 16 09:33: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: 13838030 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 262A21C07E7 for ; Wed, 16 Oct 2024 09:34:19 +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=1729071260; cv=none; b=dObbSem789WryJL4clBCMu52sS8yo3VoGfPlPjGoygi29YR6FcSGKUkdK+nToQu+nLu118yske/tJA+W3kLo4d/K0Lmcr2qEGoH7Ueq2rNgOqNVY9oMZkcbqWMAtPK9BPVNDemOIazfdERLAbcRUfUxX83MRkeS3B7JEVV2si/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071260; c=relaxed/simple; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jflLVob81Nb/z/BnsYVGgN1/PFI8S9pX3zbJyeXs0wOcWVXxSA8qK2MiRTkJrp/2DpOUnUVzdiWQ83qEKdbUwLUyF455k6h23QhdAVoB83MeVakrBwui6Y8OOs33Xv1DJWGf1H+s0PwH2wxj46IEV4yWXP4D2LWuFcYxbg6rf6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PADZr10J; 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="PADZr10J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA5C1C4CEC5; Wed, 16 Oct 2024 09:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071259; bh=vAGk2SNZxJ2K0XaAAadSTnWA8wtWMYR0tx03ZiqDhLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PADZr10JOdeV2qUk4jETB2AE7kwtDiC6CjHwdqtzkU/aIGSMR27gua8pCMFsr7rhr mZ5dLMw7jVWX8c2S2q5bLy3ujUiB/DzyjYbO1lNlcxji9RE3Wvi2eLvmkF2k0SM+FQ ETDYylzih8n0bRTzrwtyr2okSoCSM4i6YIdgmjYrJUsf5cFwSr33ndUpJENRXPr5SC XWtD0D0LClaRO0ozqcfPsMruJEzsYhBh+VJ7zOHATtFvO1UqAZBNznRc5XyD08llUT 0ksz/8YINTm4UalriOj+z9sq76pqe8Nu0agy5pZw8/ufmJZ5SwVZrdL9UzNKVz9WuF 7cbPE9Xpo203g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 07/10] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Wed, 16 Oct 2024 17:33:43 +0800 Message-ID: <5759901a2d71c40328253911dd9827d80c7c5c9a.1729070999.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 16 09:33: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: 13838031 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 C89151C07E7 for ; Wed, 16 Oct 2024 09:34:21 +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=1729071261; cv=none; b=e+hDyVQTmnM+m9bt3I+uCxG7stg5E7UwDD4tuWViY3XhYIujR/JpsO3MSpTYV9Cs53xfSLee7rruA0Pnws+ygNikeO24UFoPM5CSkdhJt4H5pqj177FLRYONRq/qO9P72cm3fG7ofBO0o0z97rG23czSsRLw2hmwUuT3xKSuCmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071261; c=relaxed/simple; bh=vcsChg8Zx7puE/i+PPig8eRAVK7A6UTQxj0/MaAo9sU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bXSsBfSWImLD9LJslzkuPocYCQKfnClLaj0wce5Dhk8bJZrwK7qb4pGFZCObLzTsyIdiJ6gRDfPC8JM6vUDn4QHobt3mf5RFcPRwRqYCtYufX3tvuEU6CJiXxFi2g84oO+9I4pVmGbpp0ST+t3kU6BvHReEHu8EvtxxxoZEgCZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H2ZiGXMi; 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="H2ZiGXMi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82EA8C4CECE; Wed, 16 Oct 2024 09:34:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071261; bh=vcsChg8Zx7puE/i+PPig8eRAVK7A6UTQxj0/MaAo9sU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H2ZiGXMiPZs9zih8+rFaxl4kEeZMEDXs/lrZNmhRR4MRhKBPlY8P3Sp44Y1REvran nj3+cjZoWSkVUxgO/zWumdQM5CgayYxzqRwiY5y4IS+7ScS4MdQgUVvxNReMMM/5dN WGdo3AF8IwcolirSC6zs/K5wCGsxJ80F9GBrv2P8V3Lnx4o2IHD1AodYszbju23xqV iw2/I9EiVjZnpasRCIsZY+qPN4yfrfjeM5gLwPL3DxyJKEgtHzDm6NlzK848j3vdnJ Tkg3qGZ0KpWpgEe9hhiUQCIhxGUKvmFHKAJylDfacu+dIxbGUWCN7ecMmfebI9PeY3 CqN4bFK51DeAg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 08/10] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Wed, 16 Oct 2024 17:33: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. Drop mptcp_subflow_active declaration. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_burst.c | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 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..fe6a9f9984f2 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -11,6 +11,10 @@ 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; @@ -23,10 +27,6 @@ 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 +57,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 +80,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 +96,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 +115,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 +125,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 +147,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 +167,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 +195,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 16 09:33: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: 13838032 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 118C21C07E7 for ; Wed, 16 Oct 2024 09:34:24 +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=1729071265; cv=none; b=i3kEjq/YfJKEeqJyKX1aGGXf3j7oJP6sLeMG7v0omBHP/rhMIj3Pj93DsTjWluR0E8hX75XECvIfuebQlnjqUzWVWMHWtlAEMyKHiEmRhQ2vLOBLZ5ttSyRyeT6tfp1C0ZCLnKbp/q8DV3NBDMHEggZEfliAGNyjymWHAusyG8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071265; c=relaxed/simple; bh=R9abq5MrN5JgwgyXDWpWO92k7yl2m/bHYSJvLML+GSo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jWH8YZpsB3LGGhjkv81J0cU5VTKoztNgnUan8/itRAHt/9T90cFrbVOcuTUcr/kWXHMQWNnQZmy05inLWR3v2hnvg6rnly95Wn+rmBgkXD0aAJzCLx4gUtVGVXPV8m6DayL80DYKOwiP6TH7fVSCD78UCOfEQeJjAAN66HAWkgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jg58SpPG; 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="jg58SpPG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAC15C4CECE; Wed, 16 Oct 2024 09:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071264; bh=R9abq5MrN5JgwgyXDWpWO92k7yl2m/bHYSJvLML+GSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jg58SpPGeSnbTMEogK5QFt49OR6CAx/b5G0wRm06hAU00wDrZXhxvSm+fnzsVqipV +e8y4GISW+ZP2zPJLvirCsedwKU09tUrdsWmG6gNXK2TutrymAiPMM2B7992aD6+lc uECj+eweFp4wgv6xEKMhJIOiBqmOiSgpZ1i3ZRmaYFnjfg830WBYn7ZqFzmeZpCaTE cToBnDjygMGSBLEDc6PdMAgBX/ndDQI9meT50hZnwIEvRp3NBIDtQjA8JnryfHQGts /jjsxciMFybKx6ACMLF3rgIzm4pGhdyWf8QL7jEJOkx5W2ZqgEfJRgi/9k4Vf24+Au PEfsRgfNOIsAw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 09/10] mptcp: drop subflow contexts in mptcp_sched_data Date: Wed, 16 Oct 2024 17:33:45 +0800 Message-ID: <59944b2b9b03fb211cfadf3b4e0a6ec7082ba508.1729070999.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 38b5862f6d98..b00ad7665d71 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -106,8 +106,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 16 09:33: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: 13838033 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 8F8251C07E7 for ; Wed, 16 Oct 2024 09:34:27 +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=1729071267; cv=none; b=Ypzq0884eK8vCGte7m4b36wY+BET6ZQyn91qdDk/4AociEYsWwt5xqdBl0U2DRCZm8ZP7bLOOqYQI7gnjlaXRoaA6n7Rtex1d2nUMiQeejK7RaVwW4Q3nYiOy4GQM5aHeK06lKoIl7pb70J/3pnaJI3TF0y3P+D67ZDC69Wwqt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729071267; c=relaxed/simple; bh=sMmLuEbCM1Sf55vle1yIBoPO8ZosmwAZ67dE8QAinAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IQjpFXCkxXMBs2VM+v6+ioajCXLCyMaFjMCuz/efxOCuAsgVP1Mj/2gL2i1CR/X7OE9cYD/x077WqOHcnaRltdroiDZJ5i2PBXDVUScXIM0NAcX6bsP88p4OftGl+zS7ioEKZDc/LF7pItUGBroUtOqk/AF4Q884pKTwM4qGC+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IMN1pffd; 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="IMN1pffd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42E9BC4CEC5; Wed, 16 Oct 2024 09:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729071267; bh=sMmLuEbCM1Sf55vle1yIBoPO8ZosmwAZ67dE8QAinAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMN1pffdhXLfWOyoZst7Ov1E5Z7t+mWy/lddGnJxQw5ua8rN/hgDEF9X42UhU24P3 iw4Ty6kZXOFVzUtZsHq5j+hs6hKFxs8atM6k+AsMBIIyFv52c3UNmuq6TbLesBBq0Q RWh/HQwwSoSROQP8zlZrBpdoFBEP2P2ty/kdjrG+gfptAw8uegR9y3J3xWLx7txlXP 9rkczGt90GVrHDLEZ+fr6ec6V40v/UsyWCLkH/X8ZuMm2l0E4IXID/dhVfVZs+CSfd oA/fiABGf+iyRn10q58lgCmjDPFG39YrIga3wy31cwJjZEH4bsAwL6JyRn8CX/p5T9 ajICVLCYCWLCw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 10/10] Squash to "selftests/bpf: Add bpf scheduler test" - drop has_bytes_sent Date: Wed, 16 Oct 2024 17:33:46 +0800 Message-ID: <8c3d8ebd5037a1367757f0749b7b0f4509e4ef49.1729070999.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 ae08be388b84..1850872a9504 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.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; +}