[PATCH mptcp-next 5/8] Squash to "selftests/bpf: Add bpf_red scheduler & test"

Geliang Tang posted 8 patches 2 months, 1 week ago
There is a newer version of this series
[PATCH mptcp-next 5/8] Squash to "selftests/bpf: Add bpf_red scheduler & test"
Posted by Geliang Tang 2 months, 1 week ago
From: Geliang Tang <tanggeliang@kylinos.cn>

Split get_subflow() interface into two: get_send() and get_retrans().

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../selftests/bpf/progs/mptcp_bpf_red.c       | 24 +++++++++++++++----
 1 file changed, 19 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..acd0b03378f2 100644
--- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c
+++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c
@@ -16,9 +16,8 @@ void BPF_PROG(mptcp_sched_red_release, struct mptcp_sock *msk)
 {
 }
 
-SEC("struct_ops")
-int BPF_PROG(bpf_red_get_subflow, struct mptcp_sock *msk,
-	     struct mptcp_sched_data *data)
+static int 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))
@@ -30,10 +29,25 @@ int BPF_PROG(bpf_red_get_subflow, struct mptcp_sock *msk,
 	return 0;
 }
 
-SEC(".struct_ops")
+SEC("struct_ops")
+int BPF_PROG(bpf_red_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
+{
+	return bpf_red_get_subflow(msk, data);
+}
+
+SEC("struct_ops")
+int BPF_PROG(bpf_red_get_retrans, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
+{
+	return bpf_red_get_subflow(msk, data);
+}
+
+SEC(".struct_ops.link")
 struct mptcp_sched_ops red = {
 	.init		= (void *)mptcp_sched_red_init,
 	.release	= (void *)mptcp_sched_red_release,
-	.get_subflow	= (void *)bpf_red_get_subflow,
+	.get_send	= (void *)bpf_red_get_send,
+	.get_retrans	= (void *)bpf_red_get_retrans,
 	.name		= "bpf_red",
 };
-- 
2.43.0