@@ -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;
}