From nobody Sun Jan 5 00:26:45 2025 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 92BF03D561 for ; Mon, 23 Dec 2024 10:06: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=1734948365; cv=none; b=aWcuwd4G24KWowRFjxq8bc2sXZ2ihnMImsMzWczgdxgdHtj/CmKJCtd0kCF8jxmG7gyUlDZwCiPI9GfcRendWyc3LNXN1ycRmqsm2aDlXL8Qe7ejM30nfWTb+zxEGPD17gf+2xpfpyO1cAHVcwaOhaTfZMAIuXd59YEIz+gO3Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948365; c=relaxed/simple; bh=c5+t7/viVd0g8Ijz7wAtMjgXer1NOpoPFtAFazy8S2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PNbvXNBXA4Vxz7ucwBD9BS3hJxYJF4IXz9TEMpZA1skOK2q9oo4jPMK/kRJokl0o1594B8/A+jhGodUAwn1lknm/3mp+i97mnZ8vLSMq4Dx80yE8wwsg2ADJ+QK9BYXAxYd9m4Msymr6rsMZTfbMIp2cWd3p4Cp5ViZd2kE/PSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mASxVOGe; 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="mASxVOGe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC883C4CED3; Mon, 23 Dec 2024 10:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948365; bh=c5+t7/viVd0g8Ijz7wAtMjgXer1NOpoPFtAFazy8S2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mASxVOGe1LrHCfx2C7K05OSjTub7IlrQ9Vpj19oAN8Hns6XrMtG5S58ZZE6Q8PZZd cQ0abpkhTop614ydfNAbEWanbTKZj/Kf5ZGAdeb00buPS4tjVbxqqTYXjqbZwo/eV9 ZPPeNqhNZQoNg7kYO6MpKM/TnzttIOG/kz2b3t8BooH/efR+jIzQm8yPoTZ8V2vqQr QDGSTgcQn6b0B9XcX3LHXOuMpvqhmqnT7JybVAuHYmC7XGRb9+naWXz6V+m2d0jZNB hbp0XB0biUVAu/EaTV7d5pRwSkVaU5Hj8wt6PpiuxVCfCIW7b635J5yH8tjerghbRL g49LY/mlnCjFA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 01/10] bpf: Add bpf_mptcp_send_info_to_ssk Date: Mon, 23 Dec 2024 18:05:43 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Burst scheduler needs to allocate an array of struct subflow_send_info on the stack and then select a subflow to send data. In order to implement burst scheduler in BPF, this patch adds a new bpf_mptcp_send_info_to_ssk() helper to get ssk from subflow_send_info and sets its parameter type as ARG_PTR_TO_STACK. Signed-off-by: Geliang Tang --- include/uapi/linux/bpf.h | 7 +++++++ net/mptcp/bpf.c | 22 ++++++++++++++++++++++ net/mptcp/protocol.c | 5 ----- net/mptcp/protocol.h | 5 +++++ tools/include/uapi/linux/bpf.h | 7 +++++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 4162afc6b5d0..18106ecc9cee 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -5795,6 +5795,12 @@ union bpf_attr { * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. + * + * void *bpf_mptcp_send_info_to_ssk(void *info) + * Description + * Dynamically cast a *info* pointer to a *sock* pointer. + * Return + * *info* if casting is valid, or **NULL** otherwise. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \ @@ -6009,6 +6015,7 @@ union bpf_attr { FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ + FN(mptcp_send_info_to_ssk, 212, ##ctx) \ /* */ =20 /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index be222fa5f308..6fe3f7badba9 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -21,6 +21,26 @@ 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; =20 +BPF_CALL_1(bpf_mptcp_send_info_to_ssk, struct subflow_send_info *, info) +{ + BTF_TYPE_EMIT(struct sock); + + if (info && info->ssk && sk_fullsock(info->ssk) && + info->ssk->sk_protocol =3D=3D IPPROTO_TCP && + sk_is_mptcp(info->ssk)) + return (unsigned long)info->ssk; + + return (unsigned long)NULL; +} + +static const struct bpf_func_proto bpf_mptcp_send_info_to_ssk_proto =3D { + .func =3D bpf_mptcp_send_info_to_ssk, + .gpl_only =3D false, + .ret_type =3D RET_PTR_TO_BTF_ID_OR_NULL, + .arg1_type =3D ARG_PTR_TO_STACK, + .ret_btf_id =3D &btf_sock_ids[BTF_SOCK_TYPE_SOCK], +}; + static const struct bpf_func_proto * bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) @@ -34,6 +54,8 @@ bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id, return &bpf_skc_to_tcp6_sock_proto; case BPF_FUNC_skc_to_tcp_sock: return &bpf_skc_to_tcp_sock_proto; + case BPF_FUNC_mptcp_send_info_to_ssk: + return &bpf_mptcp_send_info_to_ssk_proto; default: return bpf_base_func_proto(func_id, prog); } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 398ab465c256..2786e603362c 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1284,11 +1284,6 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, sizeof(struct ipv6hdr) - \ sizeof(struct frag_hdr)) =20 -struct subflow_send_info { - struct sock *ssk; - u64 linger_time; -}; - void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow) { if (!subflow->stale) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 891ffcfd1088..05059603b21e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -591,6 +591,11 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *= subflow) WRITE_ONCE(subflow->local_id, -1); } =20 +struct subflow_send_info { + struct sock *ssk; + u64 linger_time; +}; + /* Convert reset reasons in MPTCP to enum sk_rst_reason type */ static inline enum sk_rst_reason sk_rst_convert_mptcp_reason(u32 reason) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 4162afc6b5d0..18106ecc9cee 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -5795,6 +5795,12 @@ union bpf_attr { * 0 on success. * * **-ENOENT** if the bpf_local_storage cannot be found. + * + * void *bpf_mptcp_send_info_to_ssk(void *info) + * Description + * Dynamically cast a *info* pointer to a *sock* pointer. + * Return + * *info* if casting is valid, or **NULL** otherwise. */ #define ___BPF_FUNC_MAPPER(FN, ctx...) \ FN(unspec, 0, ##ctx) \ @@ -6009,6 +6015,7 @@ union bpf_attr { FN(user_ringbuf_drain, 209, ##ctx) \ FN(cgrp_storage_get, 210, ##ctx) \ FN(cgrp_storage_delete, 211, ##ctx) \ + FN(mptcp_send_info_to_ssk, 212, ##ctx) \ /* */ =20 /* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 A0E8C3D561 for ; Mon, 23 Dec 2024 10:06:07 +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=1734948367; cv=none; b=jTdheYZu99jxc/LEaOHV6xJs6mDkogM0CLd6rh0nl6b1QzqobtOYGnVzoxHwmSmcs9GJzI7pzBFkSwyLo5dWOCbJ3e77ZVfQAhh3eAOfS+PU4Pv6APM5C7MHW8gTgNwjtI2Nl9fBPuW39foc4C9L9BIthkK+jqun4W9Ba3bMq5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948367; c=relaxed/simple; bh=lDgxUD+eZbZckV4TztOt+cR29DvGQP6ggkbOAgge/OQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uE1/IDfoW3qL6kwMY7Lp4/QQ05m9moAgp2X5DHSKB45JSumX1GSqiiRxZzLtwKV9N9uWujR3ky92+cZpeugNWOzLit8Kq9MBwhq8ewk2LSBDc8yraeWSadCyH1OP+Kf/CCA9kZht/M8oo+pUGCC3hhsEtDzPkG6A/teNtI5KaHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cGuiZmOO; 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="cGuiZmOO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4ED8C4CED3; Mon, 23 Dec 2024 10:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948367; bh=lDgxUD+eZbZckV4TztOt+cR29DvGQP6ggkbOAgge/OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cGuiZmOOhz/fp5og7LFfmwEd+xoUARxNRa0LANRuXPqWFq3zTCVAHMEdPAvHjhfxs vECniGzC3PVB8ak/NONdaDHdWFRnLoiV2kTOAZ+bbrPR7CMFnFxhkxM23v77dTjC3f BQ3m3tiXjKbPpmIrmkAaVi/y6yh2aSbugpCg3rlUgGYC8BttgdINy8be79R/xCL+OE wqYawGIvcEZCMy3EURdu1DO3hoFrr1vSFvQbYq+59gnL//JBiKmg0/Fkr+GPXBD+ZT yIEMrL9O5Y1TLG69JBo2deN4IAHdcKcr6z3MhQQOqfvi2eu9bFjnwcgKjeW0iKdymf 9s5N0tg1OU76Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 02/10] Revert "mptcp: add sched_data helpers" Date: Mon, 23 Dec 2024 18:05:44 +0800 Message-ID: <6d36db735da0536c9b151896173d551be6c0b569.1734947922.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Drop this patch. bpf_mptcp_subflow_ctx_by_pos and mptcp_sched_data_set_contexts are uesless now. 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 6fe3f7badba9..57c4606a26ab 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -319,14 +319,6 @@ __bpf_kfunc static void bpf_mptcp_sock_release(struct = mptcp_sock *msk) WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); } =20 -__bpf_kfunc struct mptcp_subflow_context * -bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned= int pos) -{ - if (pos >=3D 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 05059603b21e..68fc050154b9 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -720,8 +720,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 0b1e472e59a0..5d6c0582c473 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -154,26 +154,6 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_= context *subflow, WRITE_ONCE(subflow->scheduled, scheduled); } =20 -static void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk, - struct mptcp_sched_data *data) -{ - struct mptcp_subflow_context *subflow; - int i =3D 0; - - mptcp_for_each_subflow(msk, subflow) { - if (i =3D=3D MPTCP_SUBFLOWS_MAX) { - pr_warn_once("too many subflows"); - break; - } - mptcp_subflow_set_scheduled(subflow, false); - data->contexts[i++] =3D subflow; - } - data->subflows =3D i; - - for (; i < MPTCP_SUBFLOWS_MAX; i++) - data->contexts[i] =3D NULL; -} - int mptcp_sched_get_send(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; @@ -199,7 +179,6 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) =20 if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_send(msk, &data); - mptcp_sched_data_set_contexts(msk, &data); return msk->sched->get_send(msk, &data); } =20 @@ -221,7 +200,6 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) =20 if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_retrans(msk, &data); - mptcp_sched_data_set_contexts(msk, &data); if (!msk->sched->get_retrans) return msk->sched->get_send(msk, &data); return msk->sched->get_retrans(msk, &data); --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 B77633D561 for ; Mon, 23 Dec 2024 10:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948369; cv=none; b=hyVX2qe0odyB5WT5xfjv2NMuTT0F5tyEoX5oVWMZnlWq+kUGxIEyM+bkbqaQWs7WgzTEfg9FhxqlWH+t7wQ7KXqjffwK3ttD4FKTbvQr8Ai5InA7Bn4M+JvX4mqbbDd4MSZju1rnxCIJCddTHA+fvSkRuYuCU6L7ezN7r8CTDtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948369; c=relaxed/simple; bh=GUC6UPVEwg82H1HmUxNgqQYuhTbvqxd2UsBllTVVQOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PWLmkNJYqRZaHQXeLc486CMfr+vP7YDoMo/QlrVdO9sE4owfhEgvbGAKlwZ66aSo90BsSyg6+9yU2Ff+LunzmnkI6jxDfAe7Dw2wYbNnjJ7U+0Bg+bNoxj8BQ6lIEDriw1aIepK25q/QQzeNUd4bdBQFYHq/S2PHL3d/MXWBhzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gRiHqvLV; 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="gRiHqvLV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F27FC4CED3; Mon, 23 Dec 2024 10:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948369; bh=GUC6UPVEwg82H1HmUxNgqQYuhTbvqxd2UsBllTVVQOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gRiHqvLVY0pr0D85d6Rwyoyrj9sARmsBJW8Y7XmfATMSbDohBqMqkhw2ZTQ8elV3t ty/k639tsB/tbT7Z9gO3p7+s3E+ePw8n95dE6I8ukMW/oxysqYyy42P79VBrZI6/mL KWHpBFyQZULzycJYWFkogEdEimi6blY85eb0kXPOyfbC++dutXaKA04KSUOGfEvz2Z Ze3wZsSKln8xOfDGw9HlNETvD7khBepPk7YNBKZL6GdFYdcjx5NEC6vkdhOAiOKlA4 cLNy+PQSOtTfwChzd2ukOBskjfzQCXfpguT0OG+Bw23XsB/F2SRlQrcGCCq0ds/miQ Jd0L1Lnv5++lQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 03/10] mptcp: drop struct mptcp_sched_data Date: Mon, 23 Dec 2024 18:05:45 +0800 Message-ID: <96d9e097dcdea76f2a86946287de452f0694035b.1734947922.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Then the entire struct mptcp_sched_data can be dropped. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 13 ++----------- net/mptcp/sched.c | 18 +++++++----------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 72d6e6597add..5fc0187a3669 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -100,18 +100,9 @@ struct mptcp_out_options { #define MPTCP_SCHED_MAX 128 #define MPTCP_SCHED_BUF_MAX (MPTCP_SCHED_NAME_MAX * MPTCP_SCHED_MAX) =20 -#define MPTCP_SUBFLOWS_MAX 8 - -struct mptcp_sched_data { - u8 subflows; - struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX]; -}; - struct mptcp_sched_ops { - int (*get_send)(struct mptcp_sock *msk, - struct mptcp_sched_data *data); - int (*get_retrans)(struct mptcp_sock *msk, - struct mptcp_sched_data *data); + int (*get_send)(struct mptcp_sock *msk); + int (*get_retrans)(struct mptcp_sock *msk); =20 char name[MPTCP_SCHED_NAME_MAX]; struct module *owner; diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 5d6c0582c473..c84303202449 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -16,8 +16,7 @@ static DEFINE_SPINLOCK(mptcp_sched_list_lock); static LIST_HEAD(mptcp_sched_list); =20 -static int mptcp_sched_default_get_send(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int mptcp_sched_default_get_send(struct mptcp_sock *msk) { struct sock *ssk; =20 @@ -29,8 +28,7 @@ static int mptcp_sched_default_get_send(struct mptcp_sock= *msk, return 0; } =20 -static int mptcp_sched_default_get_retrans(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int mptcp_sched_default_get_retrans(struct mptcp_sock *msk) { struct sock *ssk; =20 @@ -157,7 +155,6 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_c= ontext *subflow, int mptcp_sched_get_send(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; - struct mptcp_sched_data data; =20 msk_owned_by_me(msk); =20 @@ -178,14 +175,13 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) } =20 if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) - return mptcp_sched_default_get_send(msk, &data); - return msk->sched->get_send(msk, &data); + return mptcp_sched_default_get_send(msk); + return msk->sched->get_send(msk); } =20 int mptcp_sched_get_retrans(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; - struct mptcp_sched_data data; =20 msk_owned_by_me(msk); =20 @@ -199,8 +195,8 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) } =20 if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) - return mptcp_sched_default_get_retrans(msk, &data); + return mptcp_sched_default_get_retrans(msk); if (!msk->sched->get_retrans) - return msk->sched->get_send(msk, &data); - return msk->sched->get_retrans(msk, &data); + return msk->sched->get_send(msk); + return msk->sched->get_retrans(msk); } --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 062843D561 for ; Mon, 23 Dec 2024 10:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948372; cv=none; b=lcv9xu6flsAXe+QsqyFN3B56JChhRphwtS+acaknlgBkytrCCmY2PL5kNINnp/UqMJuFv1W/CzvBaiR0RU6pCUamft2fYR6Vwg/raEXk8ujWAcZOYq6hrofK9BiM4ZQnKUlo+hXbWo5nKaWniJVvI/ApUwpOc5lSf7jIfdRa1p0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948372; c=relaxed/simple; bh=KJy1oD0rz8jZN/MiejM4nt6kCv65wYS5whGAj7X00Y8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=As3iw53aUC3WSzcBoOCv/iJ/zK8buTSTtKxEKS2twIwgAE1s98m5ia+TPoIAposyt7q+pHB2Ld+2Y2SW1YjWJRKifgAsdJ80Su/3AFZmgIiOjwK60U/Sl/XdbCfqTaWoViIGfPExmXDLBzRwqmqPXBAaERzF527eIwI3Aail4RA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UaCVtajN; 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="UaCVtajN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19092C4CED3; Mon, 23 Dec 2024 10:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948371; bh=KJy1oD0rz8jZN/MiejM4nt6kCv65wYS5whGAj7X00Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UaCVtajN3vqqhPBAOACJZ3VvwRrvKkZa3H91+ko5TMRphO4JqQM+t5wvWODHxgVLn gq/EEyTzspOQe1XpLd015umQmtcuvWTF0hB9exEO1y9qR7J7RQr2cFki4SkEb6s8E8 z9k+eaGG6HGOmjFZGZK6WlX2CUIIGMkIDDdIIiJ0hhbWGhcqwu7zf+vaGkweU+6fQ9 73pG0xbR/wdiMTg8S5hx8XlzjuYlY0eB7ikvWJ6VwLu8GZQ0S3t1Cpz6zjgo6Gsxrt MNFVCsuDA981BbnBtEfA05XfNV2HN41Yz48cmZcKYZYCBLGiwFz+UhiJPczKHRJrV7 hBzZ1KHQVdYXQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 04/10] Squash to "bpf: Add bpf_mptcp_sched_ops" Date: Mon, 23 Dec 2024 18:05:46 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Please update the subject to bpf: Add mptcp packet scheduler struct_ops Drop struct mptcp_sched_data. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 57c4606a26ab..ea8098c6add9 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -178,14 +178,12 @@ static int bpf_mptcp_sched_init(struct btf *btf) return 0; } =20 -static int __bpf_mptcp_sched_get_send(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int __bpf_mptcp_sched_get_send(struct mptcp_sock *msk) { return 0; } =20 -static int __bpf_mptcp_sched_get_retrans(struct mptcp_sock *msk, - struct mptcp_sched_data *data) +static int __bpf_mptcp_sched_get_retrans(struct mptcp_sock *msk) { return 0; } --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 CDF043D561 for ; Mon, 23 Dec 2024 10:06:13 +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=1734948373; cv=none; b=qXgTzAOYZwgm+EpNeB7o6DD+JX2+NwxNG9PL3uu8kGoUcZ2r+h0Jo2ejMvcxHGeJGXb8JzU2941fDLjntp1gP2GzktDDK805zgbj1jIzg6hLpyJxFC7lX+qeU4wkC39DTh3dbtLJTYEMJAUqHVZfqSDvIWD4siAmyMusMiOdAyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948373; c=relaxed/simple; bh=ZKed6Z6Ub38fqUBJ3cheopo9QiT8qYIWUJniS1BkXXI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DgvTAjUFTO2NGNW57meyXCn5hINWtcJ8Y0cW+bfpBUJl2C4qsvngjh88gLYYlyUpNRwze77exEx9ldOgUVbS3WnHLTIUEeVtd5Oa2eLuEUT67wG+p4CC9ZkX0jh77FAeyDppuIe3TS/xHPVXcDZa0dmco2IBOldbv7o/9PBY6BI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KndyN7Ix; 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="KndyN7Ix" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75915C4CED3; Mon, 23 Dec 2024 10:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948373; bh=ZKed6Z6Ub38fqUBJ3cheopo9QiT8qYIWUJniS1BkXXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KndyN7Ixa1JUdNXrbCDfgBWfBw0lRIb5kwAvfFauDCCMYkppFxK6l9zBBVEp7EO4J ctg3d9FRK6yXN8QKtkzrSQACujQ4ExO2b6WJikh4DHH4hUgpQNtHDqpL1Ac/DYVZOt uyrWCOERQoSL8h7Ud7V9Op9h3fJZ5Ntlono4bVnNABdPRVs0c8mtx4sCyApe7asNgJ j7Cl35MNTsZcHxbxwrQz2/hRsDbbT2+iTWziRHZzDbMtN2SyClXXWdG3QB3/6KqQba R92RTIaoCQZTBIClsFSFfXOSpkhqTBS3b817EfnU9yiMs/HOI0nu6KKboojoYPfFYZ kaLGPvDnI9buA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 05/10] Squash to "bpf: Export mptcp packet scheduler helpers" Date: Mon, 23 Dec 2024 18:05:47 +0800 Message-ID: <5557033ced24659b2f9c6dd6eae841389497ac16.1734947922.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Remove bpf_mptcp_subflow_ctx_by_pos from BPF kfunc set. Drop bpf_mptcp_sched_kfunc_set, use bpf_mptcp_common_kfunc_set instead. Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index ea8098c6add9..de6d61d47211 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -317,6 +317,15 @@ __bpf_kfunc static void bpf_mptcp_sock_release(struct = mptcp_sock *msk) WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt)); } =20 +__bpf_kfunc static struct sock * +bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) +{ + if (!subflow) + return NULL; + + return mptcp_subflow_tcp_sock(subflow); +} + __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk) { return tcp_rtx_queue_empty(sk); @@ -331,27 +340,19 @@ BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_IT= ER_NEXT | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY) BTF_ID_FLAGS(func, bpf_mptcp_sock_acquire, KF_ACQUIRE | KF_RET_NULL) BTF_ID_FLAGS(func, bpf_mptcp_sock_release, KF_RELEASE) -BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids) - -static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set =3D { - .owner =3D THIS_MODULE, - .set =3D &bpf_mptcp_common_kfunc_ids, -}; - -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) BTF_ID_FLAGS(func, tcp_stream_memory_free) BTF_ID_FLAGS(func, bpf_mptcp_subflow_queues_empty) +BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock, KF_RET_NULL) BTF_ID_FLAGS(func, mptcp_pm_subflow_chk_stale, KF_SLEEPABLE) -BTF_KFUNCS_END(bpf_mptcp_sched_kfunc_ids) +BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids) =20 -static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set =3D { +static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set =3D { .owner =3D THIS_MODULE, - .set =3D &bpf_mptcp_sched_kfunc_ids, + .set =3D &bpf_mptcp_common_kfunc_ids, }; =20 static int __init bpf_mptcp_kfunc_init(void) @@ -362,7 +363,7 @@ static int __init bpf_mptcp_kfunc_init(void) ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCKOPT, &bpf_mptcp_common_kfunc_set); ret =3D ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, - &bpf_mptcp_sched_kfunc_set); + &bpf_mptcp_common_kfunc_set); #ifdef CONFIG_BPF_JIT ret =3D ret ?: register_bpf_struct_ops(&bpf_mptcp_sched_ops, mptcp_sched_= ops); #endif --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 1057F2207A for ; Mon, 23 Dec 2024 10:06:15 +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=1734948376; cv=none; b=ZwJJv/mzr9uWZ94Ztg2z4/e5jsXX9sqVCw28lGobIPwZcdJ2m9vWM/h4Q0KmxyBO2+jTcDOupVlPE8gxhXu1Tn7EZHFoHtsXNcgEyCwHiWI+n9CnpmHY+/1+qiO8qg0/Iwf7rtKnzdeil0aJ36v2omMg0cIz9MoSQ8jvikfApKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948376; c=relaxed/simple; bh=LJhaTlZ5GsjCDXTz1dPDa7TeCGrkb38zGlBFJkhX+3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mSKYlQqVZqclsBXmJkjMO+xVrwQyIdrvf/D33/Qs9+sFvvSO167YW6L9zImzGbu1XoMIp7Hm2Xk9pRZKsWYZljbOEY6AYUo0v8v/0K+6IuUlKwafuqw+nV+XHpRVGtmw1osXUVEDoQ2HSa29xQMBvOIPk5wbDzuU1nPYnk6Ns0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PNWOdeVp; 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="PNWOdeVp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AF70C4CED3; Mon, 23 Dec 2024 10:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948375; bh=LJhaTlZ5GsjCDXTz1dPDa7TeCGrkb38zGlBFJkhX+3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNWOdeVpWFfv4QHXRwwqWxw1Vz3F81qQkEwyWZfczBzqVCe7zjUn9OQV3gozAoEZW ltXlsHKJcwRCVOq0UdkwdMnt508uNCvajw/Kyjudv7lOTFHvAjn7+Bmzhyta4I86ce ZUHTcC5RSQ9v/7jJhGkoOFNU5ZnIvGgTtsYrpUm4Dtk0Co1YxCJpx1zRMxgeS2KKI2 LrA5F2dJFeO2F4YIBupuJmmpAA96kNmkSrjmmWOUPffR1qy6nOi2okZQ/a6foPPVRL F6mgmoN4EZPvcczHWvA87Fms/CJgca4xU6DY20SQ8CUI7sy9vJDw5k54z+SzhlvRPH HdHS/4uMRd7PA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 06/10] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Mon, 23 Dec 2024 18:05:48 +0800 Message-ID: <79255b64a33bda9a5caeab0156f9b2dc760c16fe.1734947922.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Drop bpf_mptcp_subflow_ctx_by_pos declaration. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf.h | 3 --- tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 11 ++++++++--- 2 files changed, 8 insertions(+), 6 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_con= text *subflow) __ksym; extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subf= low, bool scheduled) __ksym; =20 -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/te= sting/selftests/bpf/progs/mptcp_bpf_first.c index ab71ae3c6506..d71c50c7f441 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c @@ -17,10 +17,15 @@ void BPF_PROG(mptcp_sched_first_release, struct mptcp_s= ock *msk) } =20 SEC("struct_ops") -int BPF_PROG(bpf_first_get_send, struct mptcp_sock *msk, - struct mptcp_sched_data *data) +int BPF_PROG(bpf_first_get_send, struct mptcp_sock *msk) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, 0), true); + struct mptcp_subflow_context *subflow; + + subflow =3D bpf_mptcp_subflow_ctx(msk->first); + if (!subflow) + return -1; + + mptcp_subflow_set_scheduled(subflow, true); return 0; } =20 --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 D304E2207A for ; Mon, 23 Dec 2024 10:06:17 +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=1734948377; cv=none; b=m5h44PIRkfD4EiAcauU+vXAmOY711mjje7dCYsV72zj8fAb3wBszJAM7EN+VlCu+FW1tHdv6TnRLD2mxoNcdiNPXAx+3aDSsa6R5+VaryP7qnfUAEC78VCsdHBO68pHctYbQXcRj5SdQxw6t5Fx+hnFgUYLrND1Ubq5bC0lfnG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948377; c=relaxed/simple; bh=g/RFvGsYBmo4RSbWo9lMIqqOLlqVRpcPLjjcw8/OC3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uog1ilb3swwcUMasj+J9nFZedXU2T11G8sMbcbBe8pksO1yceLros92b7gw9J/wFu9W6cKu/7DlF/T8Ijy5+49B/PXntX8ez4uFUcVJ0+ricFZb5vFq/G/eDooHxmVGH3tWAiy3teCjJlc6QT7aFj5jVeNV6mJBUNqouC61g7cY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qxLsAx6Z; 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="qxLsAx6Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 567BFC4CEDC; Mon, 23 Dec 2024 10:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948377; bh=g/RFvGsYBmo4RSbWo9lMIqqOLlqVRpcPLjjcw8/OC3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qxLsAx6ZIjEj7B2JlF6R6/q2RDojw0iGmlaIhFaGI/WaNZ5EMMMrqOj7UekcnezOT KKH3bAom/zeeWCMskT0q8w8AFze+Q9Q3neiKyQY+xl/2evXt4qI5ywHVeTRgagdmTQ KUtA/wgpVUo/e23g5vz2qQrHs67QVdR+DBYIEkQmjlYnpjIZp488hz0o8hLlQQj+zG 5LTg+i5jcVExNBwB6VfPYGNICpDtzkTYza8nI3zygEnzGWZgiXI7bYKwdRF7y6+QMC cksCWxSzRmvPvdnri4Y+mR7NcSZWTxUvdB3Hrnzpj6Ip9YCXQCMBjCIJD2PPvrKqsx m/FWfJM7saevQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 07/10] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Mon, 23 Dec 2024 18:05:49 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_bkup.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c b/tools/tes= ting/selftests/bpf/progs/mptcp_bpf_bkup.c index 29be67e2f2ef..789701f5da6f 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c @@ -17,29 +17,18 @@ void BPF_PROG(mptcp_sched_bkup_release, struct mptcp_so= ck *msk) } =20 SEC("struct_ops") -int BPF_PROG(bpf_bkup_get_send, struct mptcp_sock *msk, - struct mptcp_sched_data *data) +int BPF_PROG(bpf_bkup_get_send, struct mptcp_sock *msk) { - int nr =3D -1; - - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - struct mptcp_subflow_context *subflow; - - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + struct mptcp_subflow_context *subflow; =20 + bpf_for_each(mptcp_subflow, subflow, msk) { if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) || !BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) { - nr =3D i; + mptcp_subflow_set_scheduled(subflow, true); break; } } =20 - if (nr !=3D -1) { - mptcp_subflow_set_scheduled(bpf_mptcp_subflow_ctx_by_pos(data, nr), true= ); - return -1; - } return 0; } =20 --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 10DB92207A for ; Mon, 23 Dec 2024 10:06: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=1734948380; cv=none; b=VFsbZop126QDLDiD+HIyVkQqvEBWg/HOIq+5JU4TgcVc1O9P3bSYI/LrQhb4vAPbWYZBs6GG5THWzOlUxeNbYnSSZ/i+YqOEn8nreHbQhHworqIQH37zCGVCodNjzw28PuZcRRTFPDOY80hoYIy2wVUSj9mmtXez7nLhwyNHAtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948380; c=relaxed/simple; bh=oR0peKmfqca0fvKExvf8faZVSJRPeERCeeaXqBeiE2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mCM3nxKXxRqe12vdJCbP9HYhgvKPZ2/p9f0wF22ai2En8Y7299+0URnVQhOOGFGW83yEr4PxKucwXAHB6RaFTzdBeN8icM1ngAhjYjMauQR/ezFBcPP1Lm0Tb6yILNCSJAxHoRmTjxIRdkUicJosopB9zdIPS+k29xxbIimtQL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TmO3NjFz; 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="TmO3NjFz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EDEFC4CED3; Mon, 23 Dec 2024 10:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948379; bh=oR0peKmfqca0fvKExvf8faZVSJRPeERCeeaXqBeiE2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TmO3NjFzwi6q4R4SWeXcFHmWoO79C1b2SJ8BBCJhTQEmYOxI/Xb/GZFS6I8HvR5nW LvCWhYs8bKdSOtF0JqYjIwlN3ksM3NnIWqnHkU41IFV9UK0CdiyH02kjjx74P0WYpi 4dzaTYM6CZL8Noo50VjrKIRbkn0e13uvoW+guddGJdpngLtDHVlmOnMDMPswFNN6HQ 8tL3c/nA27jW+O3r03OztpVE1mtXuWHxH83G9MULBBRCkbI8IA+UDriYdtE6c+9e0Z MpxIBS+DOLIu0s1Ae6xpDc9GXfnjgBpYRuSAU2i+JN0mY1uUt45UTzwBuA/XNx7qb4 DB3/9RFxZLFbQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 08/10] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Mon, 23 Dec 2024 18:05:50 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testi= ng/selftests/bpf/progs/mptcp_bpf_rr.c index 405e96c116d5..88abe7a0c391 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -31,41 +31,37 @@ void BPF_PROG(mptcp_sched_rr_release, struct mptcp_sock= *msk) } =20 SEC("struct_ops") -int BPF_PROG(bpf_rr_get_send, struct mptcp_sock *msk, - struct mptcp_sched_data *data) +int BPF_PROG(bpf_rr_get_send, struct mptcp_sock *msk) { - struct mptcp_subflow_context *subflow; + struct mptcp_subflow_context *subflow, *next; struct mptcp_rr_storage *ptr; - struct sock *last_snd =3D NULL; - int nr =3D 0; =20 ptr =3D bpf_sk_storage_get(&mptcp_rr_map, msk, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); if (!ptr) return -1; =20 - last_snd =3D ptr->last_snd; + next =3D bpf_mptcp_subflow_ctx(msk->first); + if (!next) + return -1; =20 - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!last_snd || !subflow) - break; + if (!ptr->last_snd) + goto out; =20 - if (mptcp_subflow_tcp_sock(subflow) =3D=3D last_snd) { - if (i + 1 =3D=3D MPTCP_SUBFLOWS_MAX || - !bpf_mptcp_subflow_ctx_by_pos(data, i + 1)) + bpf_for_each(mptcp_subflow, subflow, msk) { + if (mptcp_subflow_tcp_sock(subflow) =3D=3D ptr->last_snd) { + subflow =3D bpf_iter_mptcp_subflow_next(&___it); + if (!subflow) break; =20 - nr =3D i + 1; + next =3D subflow; break; } } =20 - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, nr); - if (!subflow) - return -1; - mptcp_subflow_set_scheduled(subflow, true); - ptr->last_snd =3D mptcp_subflow_tcp_sock(subflow); +out: + mptcp_subflow_set_scheduled(next, true); + ptr->last_snd =3D mptcp_subflow_tcp_sock(next); return 0; } =20 --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 C33072207A for ; Mon, 23 Dec 2024 10:06: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=1734948381; cv=none; b=VL/uxGAxGLlJCNaOehRYOJFaBOOg6V7NGq+SwESRLb2zDlNgv/uFMHHpG8ZcLkfzrntVH5L1ElPyv7niKH/cprNxowhwvd1rLP4ckCSVva6o23sLdYf5IDJa+W+ZxPO6TUQkjSuCWot8bbVgjHnUYI7/cBws0LVC3XX2FTT1474= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948381; c=relaxed/simple; bh=U2N8A0Rut7m0u19ShzGRPoIhW+J8LxRiu3bxhLHbgDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B1Jw6YdbLWT/zX7DzfFzoKJ9r+elHiC6ImNhLqIxA3NjgUYWUVk8AitVEB4O/EbiI7yOvcM3PjBK95uh0/Mns3buLjcN/54I3uRyPg5fSl22IBFvenLOHRjvQQXSkk6g4sXVKDQVCK7b0pTzESYR+DVPvX5aTEs/LA3dlrO9+d4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V/0bAt6w; 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="V/0bAt6w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53824C4AF0B; Mon, 23 Dec 2024 10:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948381; bh=U2N8A0Rut7m0u19ShzGRPoIhW+J8LxRiu3bxhLHbgDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/0bAt6wVsJ7r6obTyHUjjEOVVhPtwd5fUh2ku3UwNu18GLnbiWrEzTTQrVr5zhnb 5/jhsc+BMupbhRyGHORj47xE7NK9ld11mL9u3KY167PGpXgEHItpjTUb6jL+6lJhhw M28qLkDivAH9EZ1L3PoKZam5xfoM1bbWh7jovw0OQRkpR3LH8VrEpSkfMqz13iaS1U 8L0nzWhY3hVfn0I+JQXYa5vZBKTuDkJXondcrrbPAZey3vOD3EcPQ/xjrlCX4g+UHa lLsyKkVOD2u3bdElFsxtwoHQtXv9LbClVeNoF5FgfJ/uuFwlOlquycqlSQ+Bzwepj7 uiit1oB41rboQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 09/10] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Mon, 23 Dec 2024 18:05:51 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c b/tools/test= ing/selftests/bpf/progs/mptcp_bpf_red.c index 627502e3c851..a37390276eba 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c @@ -17,15 +17,12 @@ void BPF_PROG(mptcp_sched_red_release, struct mptcp_soc= k *msk) } =20 SEC("struct_ops") -int BPF_PROG(bpf_red_get_send, struct mptcp_sock *msk, - struct mptcp_sched_data *data) +int BPF_PROG(bpf_red_get_send, struct mptcp_sock *msk) { - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - if (!bpf_mptcp_subflow_ctx_by_pos(data, i)) - break; + struct mptcp_subflow_context *subflow; =20 - 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); =20 return 0; } --=20 2.45.2 From nobody Sun Jan 5 00:26:45 2025 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 DA0B62207A for ; Mon, 23 Dec 2024 10:06:23 +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=1734948383; cv=none; b=pt8UvfsOUjjH6rm/K+BiB3WAho1LhOh37X4T16XbzTr0neoyXdbpA3oGhY/e6oPsAmsbvbosvwDGiK7OE06Y90MJfggJ4XuMNqBkIyWZhb90fTVqfO5S+HhNIYwtU0/xhAx55+Aq7oLBfhuxkGEleBDsb00pJFFkIYSgFm1LhyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734948383; c=relaxed/simple; bh=I9ih24Wn5nxLDHWk9KOMY35fDvWUZbWxOpMl0ccGzTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dwpIzWar0jJT4cmW4/ULcP144oT+EjdHhe+pERQ6GpXJJQR1k0XhEeOrxBe3yqn3BVJtR6uHVz9T9dMpVI50rEIy3obVkQK4f61MwsbkQhtfmi8IYdn5WvpzYJJaZewaPwl6AIOlLoKyNPsWPU3xltblSpQlNKInkMSQwMIGjLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BBpcnOgm; 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="BBpcnOgm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE9EDC4CED3; Mon, 23 Dec 2024 10:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734948383; bh=I9ih24Wn5nxLDHWk9KOMY35fDvWUZbWxOpMl0ccGzTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBpcnOgm54c8K7n+t+1LyIk68B8zWm55EUyKi92OSI8rKsgmDhmsjgoGaK39ASiNj n6atWruZy/6B16ngc7AOp3Zcy1tmyK605hWckH1OTb/DYcCRTnIQBD3dn01WW7TXim GE6Ma3E1fBXac3lOgSEuSO1Hj5J0VG2fe9MMHjLSuiXjf04H8mTvsD/z82GihAlXAf +UbkPPQ+ueU+GIyZfyLtp0BY837tZqvGl2PvMQDHSNA7B9BVY9UA1SkBg7TJcdEG+z rwDxJHQV0EzL4RQuy7eDVVg9ewx1lRaiDu8mVp4Mz5146ziocKJRsRpvhKNvK3zNxc RiQPp86+WmVgQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 10/10] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Mon, 23 Dec 2024 18:05:52 +0800 Message-ID: <66a4b211db4f06b8c6fddf62bc900d886d8b707b.1734947922.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use the newly added bpf_for_each() helper to walk the conn_list. Use bpf_mptcp_send_info_to_ssk() helper. Drop bpf_subflow_send_info, use subflow_send_info instead. Signed-off-by: Geliang Tang --- .../selftests/bpf/progs/mptcp_bpf_burst.c | 68 +++++++------------ 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/te= sting/selftests/bpf/progs/mptcp_bpf_burst.c index 5743601df9dc..a33c5f302b76 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -11,11 +11,6 @@ char _license[] SEC("license") =3D "GPL"; =20 #define min(a, b) ((a) < (b) ? (a) : (b)) =20 -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; @@ -68,10 +63,9 @@ void BPF_PROG(mptcp_sched_burst_release, struct mptcp_so= ck *msk) } =20 SEC("struct_ops") -int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk, - struct mptcp_sched_data *data) +int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk) { - struct bpf_subflow_send_info send_info[SSK_MODE_MAX]; + struct subflow_send_info send_info[SSK_MODE_MAX]; struct mptcp_subflow_context *subflow; struct sock *sk =3D (struct sock *)msk; __u32 pace, burst, wmem; @@ -81,18 +75,12 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk, =20 /* pick the subflow with the lower wmem/wspace ratio */ for (i =3D 0; i < SSK_MODE_MAX; ++i) { - send_info[i].subflow_id =3D MPTCP_SUBFLOWS_MAX; + send_info[i].ssk =3D NULL; send_info[i].linger_time =3D -1; } =20 - for (i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - bool backup; - - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; - - backup =3D subflow->backup || subflow->request_bkup; + bpf_for_each(mptcp_subflow, subflow, msk) { + bool backup =3D subflow->backup || subflow->request_bkup; =20 ssk =3D mptcp_subflow_tcp_sock(subflow); if (!mptcp_subflow_active(subflow)) @@ -110,7 +98,7 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk, =20 linger_time =3D div_u64((__u64)ssk->sk_wmem_queued << 32, pace); if (linger_time < send_info[backup].linger_time) { - send_info[backup].subflow_id =3D i; + send_info[backup].ssk =3D ssk; send_info[backup].linger_time =3D linger_time; } } @@ -118,15 +106,16 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *m= sk, =20 /* pick the best backup if no other subflow is active */ if (!nr_active) - send_info[SSK_MODE_ACTIVE].subflow_id =3D send_info[SSK_MODE_BACKUP].sub= flow_id; + send_info[SSK_MODE_ACTIVE].ssk =3D send_info[SSK_MODE_BACKUP].ssk; =20 - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, send_info[SSK_MODE_ACTIVE]= .subflow_id); - if (!subflow) - return -1; - ssk =3D mptcp_subflow_tcp_sock(subflow); + ssk =3D bpf_mptcp_send_info_to_ssk(&send_info[SSK_MODE_ACTIVE]); if (!ssk || !sk_stream_memory_free(ssk)) return -1; =20 + subflow =3D bpf_mptcp_subflow_ctx(ssk); + if (!subflow) + return -1; + burst =3D min(MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt); wmem =3D ssk->sk_wmem_queued; if (!burst) @@ -143,23 +132,18 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *m= sk, } =20 SEC("struct_ops") -int BPF_PROG(bpf_burst_get_retrans, struct mptcp_sock *msk, - struct mptcp_sched_data *data) +int BPF_PROG(bpf_burst_get_retrans, struct mptcp_sock *msk) { - int backup =3D MPTCP_SUBFLOWS_MAX, pick =3D MPTCP_SUBFLOWS_MAX, subflow_i= d; + struct sock *backup =3D NULL, *pick =3D NULL; struct mptcp_subflow_context *subflow; int min_stale_count =3D INT_MAX; - struct sock *ssk; =20 - for (int i =3D 0; i < data->subflows && i < MPTCP_SUBFLOWS_MAX; i++) { - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, i); - if (!subflow) - break; + bpf_for_each(mptcp_subflow, subflow, msk) { + struct sock *ssk =3D bpf_mptcp_subflow_tcp_sock(subflow); =20 - if (!mptcp_subflow_active(subflow)) + if (!ssk || !mptcp_subflow_active(subflow)) continue; =20 - ssk =3D 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); @@ -168,23 +152,23 @@ int BPF_PROG(bpf_burst_get_retrans, struct mptcp_sock= *msk, } =20 if (subflow->backup || subflow->request_bkup) { - if (backup =3D=3D MPTCP_SUBFLOWS_MAX) - backup =3D i; + if (!backup) + backup =3D ssk; continue; } =20 - if (pick =3D=3D MPTCP_SUBFLOWS_MAX) - pick =3D i; + if (!pick) + pick =3D ssk; } =20 - if (pick < MPTCP_SUBFLOWS_MAX) { - subflow_id =3D pick; + if (pick) goto out; - } - subflow_id =3D min_stale_count > 1 ? backup : MPTCP_SUBFLOWS_MAX; + pick =3D min_stale_count > 1 ? backup : NULL; =20 out: - subflow =3D bpf_mptcp_subflow_ctx_by_pos(data, subflow_id); + if (!pick) + return -1; + subflow =3D bpf_mptcp_subflow_ctx(pick); if (!subflow) return -1; mptcp_subflow_set_scheduled(subflow, true); --=20 2.45.2