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

Geliang Tang posted 8 patches 13 hours ago
[PATCH mptcp-next 4/8] Squash to "selftests/bpf: Add bpf_rr scheduler & test"
Posted by Geliang Tang 13 hours 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_rr.c        | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 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..ec7853a9716c 100644
--- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c
+++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c
@@ -30,9 +30,8 @@ void BPF_PROG(mptcp_sched_rr_release, struct mptcp_sock *msk)
 	bpf_sk_storage_delete(&mptcp_rr_map, msk);
 }
 
-SEC("struct_ops")
-int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk,
-	     struct mptcp_sched_data *data)
+static int bpf_rr_get_subflow(struct mptcp_sock *msk,
+			      struct mptcp_sched_data *data)
 {
 	struct mptcp_subflow_context *subflow;
 	struct mptcp_rr_storage *ptr;
@@ -69,10 +68,25 @@ int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk,
 	return 0;
 }
 
-SEC(".struct_ops")
+SEC("struct_ops")
+int BPF_PROG(bpf_rr_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
+{
+	return bpf_rr_get_subflow(msk, data);
+}
+
+SEC("struct_ops")
+int BPF_PROG(bpf_rr_get_retrans, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
+{
+	return bpf_rr_get_subflow(msk, data);
+}
+
+SEC(".struct_ops.link")
 struct mptcp_sched_ops rr = {
 	.init		= (void *)mptcp_sched_rr_init,
 	.release	= (void *)mptcp_sched_rr_release,
-	.get_subflow	= (void *)bpf_rr_get_subflow,
+	.get_send	= (void *)bpf_rr_get_send,
+	.get_retrans	= (void *)bpf_rr_get_retrans,
 	.name		= "bpf_rr",
 };
-- 
2.43.0