@@ -37,7 +37,7 @@ int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk,
struct mptcp_subflow_context *subflow;
struct mptcp_rr_storage *ptr;
struct sock *last_snd = NULL;
- int nr = 0;
+ int id = 1;
ptr = bpf_sk_storage_get(&mptcp_rr_map, msk, 0,
BPF_LOCAL_STORAGE_GET_F_CREATE);
@@ -46,22 +46,24 @@ int BPF_PROG(bpf_rr_get_subflow, struct mptcp_sock *msk,
last_snd = ptr->last_snd;
- 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))
+ struct mptcp_subflow_context *next;
+
+ next = bpf_core_cast(list_next_entry(subflow, node),
+ struct mptcp_subflow_context);
+ if (list_entry_is_head(next, &msk->conn_list, node))
break;
- nr = i + 1;
+ id = next->subflow_id;
break;
}
}
- subflow = bpf_mptcp_subflow_ctx_by_pos(data, nr);
+ subflow = bpf_mptcp_lookup_subflow_by_id(msk, id);
if (!subflow)
return -1;
mptcp_subflow_set_scheduled(subflow, true);