From: Geliang Tang <tanggeliang@kylinos.cn>
Use the newly added bpf_for_each() helper to walk the conn_list.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../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/testing/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_sock *msk)
}
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 = -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;
}
--
2.45.2