@@ -34,38 +34,35 @@ SEC("struct_ops")
3434int BPF_PROG (bpf_rr_get_subflow , struct mptcp_sock * msk ,
3535 struct mptcp_sched_data * data )
3636{
37- struct mptcp_subflow_context * subflow ;
37+ struct mptcp_subflow_context * subflow , * next ;
3838 struct mptcp_rr_storage * ptr ;
39- struct sock * last_snd = NULL ;
40- int nr = 0 ;
4139
4240 ptr = bpf_sk_storage_get (& mptcp_rr_map , msk , 0 ,
4341 BPF_LOCAL_STORAGE_GET_F_CREATE );
4442 if (!ptr )
4543 return -1 ;
4644
47- last_snd = ptr -> last_snd ;
45+ next = bpf_mptcp_subflow_ctx (msk -> first );
46+ if (!next )
47+ return -1 ;
4848
49- for (int i = 0 ; i < data -> subflows && i < MPTCP_SUBFLOWS_MAX ; i ++ ) {
50- subflow = bpf_mptcp_subflow_ctx_by_pos (data , i );
51- if (!last_snd || !subflow )
52- break ;
49+ if (!ptr -> last_snd )
50+ goto out ;
5351
54- if (mptcp_subflow_tcp_sock (subflow ) == last_snd ) {
55- if (i + 1 == MPTCP_SUBFLOWS_MAX ||
56- !bpf_mptcp_subflow_ctx_by_pos (data , i + 1 ))
52+ bpf_for_each (mptcp_subflow , subflow , msk ) {
53+ if (mptcp_subflow_tcp_sock (subflow ) == ptr -> last_snd ) {
54+ subflow = bpf_iter_mptcp_subflow_next (& ___it );
55+ if (!subflow )
5756 break ;
5857
59- nr = i + 1 ;
58+ next = subflow ;
6059 break ;
6160 }
6261 }
6362
64- subflow = bpf_mptcp_subflow_ctx_by_pos (data , nr );
65- if (!subflow )
66- return -1 ;
67- mptcp_subflow_set_scheduled (subflow , true);
68- ptr -> last_snd = mptcp_subflow_tcp_sock (subflow );
63+ out :
64+ mptcp_subflow_set_scheduled (next , true);
65+ ptr -> last_snd = mptcp_subflow_tcp_sock (next );
6966 return 0 ;
7067}
7168
0 commit comments